Darrell Anderson 12 years ago
commit 2524057909

@ -0,0 +1 @@
../../src/kernel/qeventloop_glib_p.h

@ -44,9 +44,12 @@
#include "ntqsocketnotifier.h" #include "ntqsocketnotifier.h"
#endif // QT_H #endif // QT_H
#ifdef Q_QDOC
#else // Q_QDOC
#if defined(QT_USE_GLIBMAINLOOP) #if defined(QT_USE_GLIBMAINLOOP)
#include <glib.h> #include <glib.h>
#endif // QT_USE_GLIBMAINLOOP #endif // QT_USE_GLIBMAINLOOP
#endif // Q_QDOC
class TQEventLoopPrivate; class TQEventLoopPrivate;
class TQSocketNotifier; class TQSocketNotifier;
@ -99,7 +102,9 @@ public:
virtual void wakeUp(); virtual void wakeUp();
#if defined(QT_USE_GLIBMAINLOOP) #ifdef Q_QDOC
#else // Q_QDOC
#if defined(QT_USE_GLIBMAINLOOP)
// glib main loop support // glib main loop support
@ -114,7 +119,10 @@ public:
// end glib main loop support // end glib main loop support
#endif //QT_USE_GLIBMAINLOOP #endif //QT_USE_GLIBMAINLOOP
#endif // Q_QDOC
void setSingleToolkitEventHandling(bool enabled);
signals: signals:
void awake(); void awake();
void aboutToBlock(); void aboutToBlock();

@ -95,6 +95,7 @@ public:
quitnow = FALSE; quitnow = FALSE;
exitloop = FALSE; exitloop = FALSE;
shortcut = FALSE; shortcut = FALSE;
singletoolkit = TRUE;
} }
int looplevel; int looplevel;
@ -124,6 +125,7 @@ public:
// My GSource // My GSource
GSource * gSource; GSource * gSource;
bool singletoolkit;
}; };

@ -415,3 +415,7 @@ void TQEventLoop::appClosingDown()
{ {
d->xfd = -1; d->xfd = -1;
} }
void TQEventLoop::setSingleToolkitEventHandling(bool enabled) {
// Do nothing
}

@ -96,6 +96,9 @@ static gboolean qt_gsource_check ( GSource *source )
static gboolean qt_gsource_dispatch ( GSource *source, static gboolean qt_gsource_dispatch ( GSource *source,
GSourceFunc callback, gpointer user_data ) GSourceFunc callback, gpointer user_data )
{ {
Q_UNUSED(callback);
Q_UNUSED(user_data);
TQtGSource * qtGSource = (TQtGSource*) source; TQtGSource * qtGSource = (TQtGSource*) source;
return qtGSource->qeventLoop->gsourceDispatch(source); return qtGSource->qeventLoop->gsourceDispatch(source);
} }
@ -166,7 +169,9 @@ void TQEventLoop::init()
d->pev_flags = AllEvents | WaitForMore; d->pev_flags = AllEvents | WaitForMore;
// initialize the common parts of the event loop // 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[0], F_SETFD, FD_CLOEXEC);
fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC); fcntl(d->thread_pipe[1], F_SETFD, FD_CLOEXEC);
@ -341,7 +346,8 @@ bool TQEventLoop::processX11Events()
bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout) bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
{ {
Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n"); printf("inside gsourcePrepare(1)\n");
#endif #endif
@ -447,78 +453,80 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
bool TQEventLoop::gsourceCheck(GSource *gs) { bool TQEventLoop::gsourceCheck(GSource *gs) {
Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(1)\n"); printf("inside gsourceCheck(1)\n");
#endif #endif
// Socketnotifier events? // Socketnotifier events?
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list; TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
//if ( list ) { //if ( list ) {
TQSockNotGPollFD *sn = list->first(); TQSockNotGPollFD *sn = list->first();
while ( sn ) { while ( sn ) {
if ( sn->gPollFD.revents ) if ( sn->gPollFD.revents )
return TRUE; return TRUE;
sn = list->next(); sn = list->next();
} }
//} //}
if (d->x_gPollFD.revents) { if (d->x_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) xfd!\n"); printf("inside gsourceCheck(2) xfd!\n");
#endif #endif
return TRUE; // we got events! return TRUE; // we got events!
} }
if (d->threadPipe_gPollFD.revents) { if (d->threadPipe_gPollFD.revents) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) threadpipe!!\n"); printf("inside gsourceCheck(2) threadpipe!!\n");
#endif #endif
return TRUE; // we got events! return TRUE; // we got events!
} }
if (hasPendingEvents()) { if (hasPendingEvents()) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) pendingEvents!\n"); printf("inside gsourceCheck(2) pendingEvents!\n");
#endif #endif
return TRUE; // we got more X11 events! return TRUE; // we got more X11 events!
} }
// check if we have timers to activate? // check if we have timers to activate?
timeval * tm =qt_wait_timer(); timeval * tm =qt_wait_timer();
if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) { if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n"); printf("inside gsourceCheck(2) qtwaittimer!\n");
#endif #endif
return TRUE; return TRUE;
} }
// nothing to dispatch // nothing to dispatch
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) nothing to dispatch!\n"); printf("inside gsourceCheck(2) nothing to dispatch!\n");
#endif #endif
return FALSE; return FALSE;
} }
bool TQEventLoop::gsourceDispatch(GSource *gs) { bool TQEventLoop::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) #if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex ); TQMutexLocker locker( TQApplication::tqt_mutex );
#endif #endif
#if defined(QT_THREAD_SUPPORT) #if defined(QT_THREAD_SUPPORT)
locker.mutex()->lock(); locker.mutex()->lock();
#endif #endif
int nevents=0; int nevents=0;
@ -527,18 +535,20 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(1)\n"); printf("inside gsourceDispatch(1)\n");
#endif #endif
// we are awake, broadcast it // we are awake, broadcast it
emit awake(); emit awake();
emit tqApp->guiThreadAwake(); emit tqApp->guiThreadAwake();
// some other thread woke us up... consume the data on the thread pipe so that // some other thread woke us up... consume the data on the thread pipe so that
// select doesn't immediately return next time // select doesn't immediately return next time
if ( d->threadPipe_gPollFD.revents) { if ( d->threadPipe_gPollFD.revents) {
char c; char c;
::read( d->thread_pipe[0], &c, 1 ); if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
// Error!
}
} }
if ( qt_postselect_handler ) { if ( qt_postselect_handler ) {
@ -552,8 +562,8 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
// if select says data is ready on any socket, then set the socket notifier // if select says data is ready on any socket, then set the socket notifier
// to pending // to pending
// if ( &d->sn_list ) { // if ( &d->sn_list ) {
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list; TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
TQSockNotGPollFD *sn = list->first(); TQSockNotGPollFD *sn = list->first();
while ( sn ) { while ( sn ) {
@ -562,7 +572,7 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
sn = list->next(); sn = list->next();
} }
// } // }
nevents += activateSocketNotifiers(); nevents += activateSocketNotifiers();
} }
@ -574,30 +584,35 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
// return true if we handled events, false otherwise // return true if we handled events, false otherwise
//return (nevents > 0); //return (nevents > 0);
// now process x11 events! // now process x11 events!
#ifdef DEBUG_QT_GLIBMAINLOOP #ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceDispatch(2) hasPendingEvents=%d\n", hasPendingEvents()); printf("inside gsourceDispatch(2) hasPendingEvents=%d\n", hasPendingEvents());
#endif #endif
if (hasPendingEvents()) { if (hasPendingEvents()) {
// color approx. optimization - only on X11 // color approx. optimization - only on X11
qt_reset_color_avail(); qt_reset_color_avail();
processX11Events(); processX11Events();
} }
#if defined(QT_THREAD_SUPPORT) #if defined(QT_THREAD_SUPPORT)
locker.mutex()->unlock(); locker.mutex()->unlock();
#endif #endif
return TRUE; if (d->singletoolkit) {
return TRUE; // Eat the event
}
else {
return FALSE; // Pass the event on to GTK
}
} }
bool TQEventLoop::hasPendingEvents() const bool TQEventLoop::hasPendingEvents() const
@ -616,3 +631,7 @@ void TQEventLoop::appClosingDown()
{ {
d->xfd = -1; d->xfd = -1;
} }
void TQEventLoop::setSingleToolkitEventHandling(bool enabled) {
d->singletoolkit = enabled;
}

@ -23,6 +23,7 @@ kernel {
$$KERNEL_H/ntqevent.h \ $$KERNEL_H/ntqevent.h \
$$KERNEL_H/ntqeventloop.h \ $$KERNEL_H/ntqeventloop.h \
$$KERNEL_P/qeventloop_p.h \ $$KERNEL_P/qeventloop_p.h \
$$KERNEL_P/qeventloop_glib_p.h \
$$KERNEL_H/ntqfocusdata.h \ $$KERNEL_H/ntqfocusdata.h \
$$KERNEL_H/ntqfont.h \ $$KERNEL_H/ntqfont.h \
$$KERNEL_P/qfontdata_p.h \ $$KERNEL_P/qfontdata_p.h \

Loading…
Cancel
Save