Index: qt-everywhere-opensource-src-4.6.3/src/corelib/kernel/qeventdispatcher_glib.cpp
===================================================================
--- qt-everywhere-opensource-src-4.6.3.orig/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ qt-everywhere-opensource-src-4.6.3/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -253,20 +253,29 @@ struct GPostEventSource
     GSource source;
     QAtomicInt serialNumber;
     int lastSerialNumber;
+    QEventLoop::ProcessEventsFlags processEventsFlags;
+    QEventDispatcherGlibPrivate *d;
 };
 
 static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
 {
+    GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
     QThreadData *data = QThreadData::current();
     if (!data)
         return false;
 
+    QEventLoop::ProcessEventsFlags excludeAllFlags
+        = QEventLoop::ExcludeUserInputEvents
+        | QEventLoop::ExcludeSocketNotifiers
+        | QEventLoop::X11ExcludeTimers;
+    if ((source->processEventsFlags & excludeAllFlags) == excludeAllFlags)
+        return false;
+
     gint dummy;
     if (!timeout)
         timeout = &dummy;
     *timeout = data->canWait ? -1 : 0;
 
-    GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
     return (!data->canWait
             || (source->serialNumber != source->lastSerialNumber));
 }
@@ -280,7 +289,14 @@ static gboolean postEventSourceDispatch(
 {
     GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
     source->lastSerialNumber = source->serialNumber;
-    QCoreApplication::sendPostedEvents();
+    QEventLoop::ProcessEventsFlags excludeAllFlags
+        = QEventLoop::ExcludeUserInputEvents
+        | QEventLoop::ExcludeSocketNotifiers
+        | QEventLoop::X11ExcludeTimers;
+    if ((source->processEventsFlags & excludeAllFlags) != excludeAllFlags) {
+        QCoreApplication::sendPostedEvents();
+        source->d->runTimersOnceWithNormalPriority();
+    }
     return true; // i dunno, george...
 }
 
@@ -320,6 +336,8 @@ QEventDispatcherGlibPrivate::QEventDispa
     postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
                                                                         sizeof(GPostEventSource)));
     postEventSource->serialNumber = 1;
+    postEventSource->processEventsFlags = QEventLoop::AllEvents;
+    postEventSource->d = this;
     g_source_set_can_recurse(&postEventSource->source, true);
     g_source_attach(&postEventSource->source, mainContext);
 
@@ -410,6 +428,7 @@ bool QEventDispatcherGlib::processEvents
 
     // tell postEventSourcePrepare() and timerSource about any new flags
     QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
+    d->postEventSource->processEventsFlags = flags;
     d->timerSource->processEventsFlags = flags;
     d->socketNotifierSource->processEventsFlags = flags;
 
@@ -422,6 +441,7 @@ bool QEventDispatcherGlib::processEvents
     while (!result && canWait)
         result = g_main_context_iteration(d->mainContext, canWait);
 
+    d->postEventSource->processEventsFlags = savedFlags;
     d->timerSource->processEventsFlags = savedFlags;
     d->socketNotifierSource->processEventsFlags = savedFlags;
 
Index: qt-everywhere-opensource-src-4.6.3/src/corelib/kernel/qeventdispatcher_unix.cpp
===================================================================
--- qt-everywhere-opensource-src-4.6.3.orig/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ qt-everywhere-opensource-src-4.6.3/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -904,7 +904,15 @@ bool QEventDispatcherUNIX::processEvents
 
     // we are awake, broadcast it
     emit awake();
-    QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+
+    QEventLoop::ProcessEventsFlags excludeAllFlags
+        = QEventLoop::ExcludeUserInputEvents
+        | QEventLoop::ExcludeSocketNotifiers
+        | QEventLoop::X11ExcludeTimers;
+    if ((flags & excludeAllFlags) == excludeAllFlags)
+        return false;
+    if(( flags & excludeAllFlags ) != excludeAllFlags )
+        QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
 
     int nevents = 0;
     const bool canWait = (d->threadData->canWait
