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