Kevin Kofler 0da408
Author: Jan-Marek Glogowski <glogow@fbihome.de>
Kevin Kofler 0da408
Date:   Thu Mar 06 18:44:43 2014 +0100
Kevin Kofler 0da408
Kevin Kofler 0da408
    Honor QEventLoop::ExcludeSocketNotifiers in glib event loop.
Kevin Kofler 0da408
    
Kevin Kofler 0da408
    Implements QEventLoop::ExcludeSocketNotifiers in the same way 
Kevin Kofler 0da408
    QEventLoop::X11ExcludeTimers is already implemented for the glib
Kevin Kofler 0da408
    event loop.
Kevin Kofler 0da408
Kevin Kofler 0da408
--- qt4-x11-4.8.1.orig/src/corelib/kernel/qeventdispatcher_glib.cpp
Kevin Kofler 0da408
+++ qt4-x11-4.8.1/src/corelib/kernel/qeventdispatcher_glib.cpp
Kevin Kofler 0da408
@@ -65,6 +65,7 @@ struct GPollFDWithQSocketNotifier
Kevin Kofler 0da408
 struct GSocketNotifierSource
Kevin Kofler 0da408
 {
Kevin Kofler 0da408
     GSource source;
Kevin Kofler 0da408
+    QEventLoop::ProcessEventsFlags processEventsFlags;
Kevin Kofler 0da408
     QList<GPollFDWithQSocketNotifier *> pollfds;
Kevin Kofler 0da408
 };
Kevin Kofler 0da408
 
Kevin Kofler 0da408
@@ -80,6 +81,9 @@ static gboolean socketNotifierSourceChec
Kevin Kofler 0da408
     GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
     bool pending = false;
Kevin Kofler 0da408
+    if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
Kevin Kofler 0da408
+        return pending;
Kevin Kofler 0da408
+
Kevin Kofler 0da408
     for (int i = 0; !pending && i < src->pollfds.count(); ++i) {
Kevin Kofler 0da408
         GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
@@ -103,6 +107,9 @@ static gboolean socketNotifierSourceDisp
Kevin Kofler 0da408
     QEvent event(QEvent::SockAct);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
     GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource *>(source);
Kevin Kofler 0da408
+    if (src->processEventsFlags & QEventLoop::ExcludeSocketNotifiers)
Kevin Kofler 0da408
+        return true;
Kevin Kofler 0da408
+
Kevin Kofler 0da408
     for (int i = 0; i < src->pollfds.count(); ++i) {
Kevin Kofler 0da408
         GPollFDWithQSocketNotifier *p = src->pollfds.at(i);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
@@ -330,6 +337,7 @@ QEventDispatcherGlibPrivate::QEventDispa
Kevin Kofler 0da408
         reinterpret_cast<GSocketNotifierSource *>(g_source_new(&socketNotifierSourceFuncs,
Kevin Kofler 0da408
                                                                sizeof(GSocketNotifierSource)));
Kevin Kofler 0da408
     (void) new (&socketNotifierSource->pollfds) QList<GPollFDWithQSocketNotifier *>();
Kevin Kofler 0da408
+    socketNotifierSource->processEventsFlags = QEventLoop::AllEvents;
Kevin Kofler 0da408
     g_source_set_can_recurse(&socketNotifierSource->source, true);
Kevin Kofler 0da408
     g_source_attach(&socketNotifierSource->source, mainContext);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
@@ -415,6 +423,7 @@ bool QEventDispatcherGlib::processEvents
Kevin Kofler 0da408
     // tell postEventSourcePrepare() and timerSource about any new flags
Kevin Kofler 0da408
     QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
Kevin Kofler 0da408
     d->timerSource->processEventsFlags = flags;
Kevin Kofler 0da408
+    d->socketNotifierSource->processEventsFlags = flags;
Kevin Kofler 0da408
 
Kevin Kofler 0da408
     if (!(flags & QEventLoop::EventLoopExec)) {
Kevin Kofler 0da408
         // force timers to be sent at normal priority
Kevin Kofler 0da408
@@ -426,6 +435,7 @@ bool QEventDispatcherGlib::processEvents
Kevin Kofler 0da408
         result = g_main_context_iteration(d->mainContext, canWait);
Kevin Kofler 0da408
 
Kevin Kofler 0da408
     d->timerSource->processEventsFlags = savedFlags;
Kevin Kofler 0da408
+    d->socketNotifierSource->processEventsFlags = savedFlags;
Kevin Kofler 0da408
 
Kevin Kofler 0da408
     if (canWait)
Kevin Kofler 0da408
         emit awake();