summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel/qeventloop.h12
-rw-r--r--src/kernel/qeventloop_glib_p.h2
-rw-r--r--src/kernel/qeventloop_x11.cpp4
-rw-r--r--src/kernel/qeventloop_x11_glib.cpp125
-rw-r--r--src/kernel/qt_kernel.pri1
5 files changed, 89 insertions, 55 deletions
diff --git a/src/kernel/qeventloop.h b/src/kernel/qeventloop.h
index 9a79f6c..25f80cd 100644
--- a/src/kernel/qeventloop.h
+++ b/src/kernel/qeventloop.h
@@ -44,9 +44,12 @@
#include "qsocketnotifier.h"
#endif // QT_H
+#ifdef Q_QDOC
+#else // Q_QDOC
#if defined(QT_USE_GLIBMAINLOOP)
#include <glib.h>
#endif // QT_USE_GLIBMAINLOOP
+#endif // Q_QDOC
class QEventLoopPrivate;
class QSocketNotifier;
@@ -99,7 +102,9 @@ public:
virtual void wakeUp();
-#if defined(QT_USE_GLIBMAINLOOP)
+#ifdef Q_QDOC
+#else // Q_QDOC
+#if defined(QT_USE_GLIBMAINLOOP)
// glib main loop support
@@ -114,7 +119,10 @@ public:
// end glib main loop support
#endif //QT_USE_GLIBMAINLOOP
-
+#endif // Q_QDOC
+
+ void setSingleToolkitEventHandling(bool enabled);
+
signals:
void awake();
void aboutToBlock();
diff --git a/src/kernel/qeventloop_glib_p.h b/src/kernel/qeventloop_glib_p.h
index 8d1ead9..7de324d 100644
--- a/src/kernel/qeventloop_glib_p.h
+++ b/src/kernel/qeventloop_glib_p.h
@@ -95,6 +95,7 @@ public:
quitnow = FALSE;
exitloop = FALSE;
shortcut = FALSE;
+ singletoolkit = TRUE;
}
int looplevel;
@@ -124,6 +125,7 @@ public:
// My GSource
GSource * gSource;
+ bool singletoolkit;
};
diff --git a/src/kernel/qeventloop_x11.cpp b/src/kernel/qeventloop_x11.cpp
index e3b43a6..833be69 100644
--- a/src/kernel/qeventloop_x11.cpp
+++ b/src/kernel/qeventloop_x11.cpp
@@ -415,3 +415,7 @@ void QEventLoop::appClosingDown()
{
d->xfd = -1;
}
+
+void QEventLoop::setSingleToolkitEventHandling(bool enabled) {
+ // Do nothing
+} \ No newline at end of file
diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp
index 10ee007..59ab8a1 100644
--- a/src/kernel/qeventloop_x11_glib.cpp
+++ b/src/kernel/qeventloop_x11_glib.cpp
@@ -96,6 +96,9 @@ static gboolean qt_gsource_check ( GSource *source )
static gboolean qt_gsource_dispatch ( GSource *source,
GSourceFunc callback, gpointer user_data )
{
+ Q_UNUSED(callback);
+ Q_UNUSED(user_data);
+
QtGSource * qtGSource = (QtGSource*) source;
return qtGSource->qeventLoop->gsourceDispatch(source);
}
@@ -166,7 +169,9 @@ void QEventLoop::init()
d->pev_flags = AllEvents | WaitForMore;
// initialize the common parts of the event loop
- pipe( d->thread_pipe );
+ if (pipe( d->thread_pipe ) < 0) {
+ // Error!
+ }
fcntl(d->thread_pipe[0], F_SETFD, FD_CLOEXEC);
fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC);
@@ -341,7 +346,8 @@ bool QEventLoop::processX11Events()
bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout)
{
-
+ Q_UNUSED(gs);
+
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n");
#endif
@@ -447,78 +453,80 @@ bool QEventLoop::gsourcePrepare(GSource *gs, int * timeout)
bool QEventLoop::gsourceCheck(GSource *gs) {
-
+ Q_UNUSED(gs);
+
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(1)\n");
- #endif
-
-
+ #endif
+
+
// Socketnotifier events?
-
+
QPtrList<QSockNotGPollFD> *list = &d->sn_list;
-
+
//if ( list ) {
-
-
+
+
QSockNotGPollFD *sn = list->first();
while ( sn ) {
if ( sn->gPollFD.revents )
return TRUE;
sn = list->next();
}
- //}
-
- if (d->x_gPollFD.revents) {
+ //}
+
+ if (d->x_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) xfd!\n");
- #endif
-
+ #endif
+
return TRUE; // we got events!
}
- if (d->threadPipe_gPollFD.revents) {
+ if (d->threadPipe_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) threadpipe!!\n");
- #endif
-
+ #endif
+
return TRUE; // we got events!
}
if (hasPendingEvents()) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) pendingEvents!\n");
- #endif
-
+ #endif
+
return TRUE; // we got more X11 events!
}
// check if we have timers to activate?
-
+
timeval * tm =qt_wait_timer();
-
+
if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n");
- #endif
-
+ #endif
+
return TRUE;
}
-
- // nothing to dispatch
-
+
+ // nothing to dispatch
+
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) nothing to dispatch!\n");
- #endif
-
- return FALSE;
+ #endif
+
+ return FALSE;
}
bool QEventLoop::gsourceDispatch(GSource *gs) {
+ Q_UNUSED(gs);
- // relock the GUI mutex before processing any pending events
+ // relock the GUI mutex before processing any pending events
#if defined(QT_THREAD_SUPPORT)
- QMutexLocker locker( QApplication::qt_mutex );
-#endif
+ QMutexLocker locker( QApplication::qt_mutex );
+#endif
#if defined(QT_THREAD_SUPPORT)
- locker.mutex()->lock();
+ locker.mutex()->lock();
#endif
int nevents=0;
@@ -527,18 +535,20 @@ bool QEventLoop::gsourceDispatch(GSource *gs) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(1)\n");
- #endif
-
+ #endif
+
// we are awake, broadcast it
emit awake();
emit qApp->guiThreadAwake();
// some other thread woke us up... consume the data on the thread pipe so that
// select doesn't immediately return next time
-
+
if ( d->threadPipe_gPollFD.revents) {
char c;
- ::read( d->thread_pipe[0], &c, 1 );
+ if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
+ // Error!
+ }
}
if ( qt_postselect_handler ) {
@@ -552,8 +562,8 @@ bool QEventLoop::gsourceDispatch(GSource *gs) {
// if select says data is ready on any socket, then set the socket notifier
// to pending
// if ( &d->sn_list ) {
-
-
+
+
QPtrList<QSockNotGPollFD> *list = &d->sn_list;
QSockNotGPollFD *sn = list->first();
while ( sn ) {
@@ -562,7 +572,7 @@ bool QEventLoop::gsourceDispatch(GSource *gs) {
sn = list->next();
}
// }
-
+
nevents += activateSocketNotifiers();
}
@@ -574,30 +584,35 @@ bool QEventLoop::gsourceDispatch(GSource *gs) {
- // return true if we handled events, false otherwise
- //return (nevents > 0);
-
+ // return true if we handled events, false otherwise
+ //return (nevents > 0);
+
// now process x11 events!
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(2) hasPendingEvents=%d\n", hasPendingEvents());
#endif
-
+
+
if (hasPendingEvents()) {
// color approx. optimization - only on X11
- qt_reset_color_avail();
-
+ qt_reset_color_avail();
+
processX11Events();
-
+
}
-
+
#if defined(QT_THREAD_SUPPORT)
locker.mutex()->unlock();
-#endif
-
- return TRUE;
-
+#endif
+
+ if (d->singletoolkit) {
+ return TRUE; // Eat the event
+ }
+ else {
+ return FALSE; // Pass the event on to GTK
+ }
}
bool QEventLoop::hasPendingEvents() const
@@ -616,3 +631,7 @@ void QEventLoop::appClosingDown()
{
d->xfd = -1;
}
+
+void QEventLoop::setSingleToolkitEventHandling(bool enabled) {
+ d->singletoolkit = enabled;
+} \ No newline at end of file
diff --git a/src/kernel/qt_kernel.pri b/src/kernel/qt_kernel.pri
index b72220f..1b81a35 100644
--- a/src/kernel/qt_kernel.pri
+++ b/src/kernel/qt_kernel.pri
@@ -23,6 +23,7 @@ kernel {
$$KERNEL_H/qevent.h \
$$KERNEL_H/qeventloop.h \
$$KERNEL_P/qeventloop_p.h \
+ $$KERNEL_P/qeventloop_glib_p.h \
$$KERNEL_H/qfocusdata.h \
$$KERNEL_H/qfont.h \
$$KERNEL_P/qfontdata_p.h \