summaryrefslogtreecommitdiffstats
path: root/src/kernel/qeventloop_x11_glib.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-01 15:09:36 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-05-01 15:09:36 -0500
commit5faba37f113b6a4d75d7526cbbc1f363a465c39f (patch)
tree6ac6c5d5b405e8ead8e42e5f1e50b1735cedb070 /src/kernel/qeventloop_x11_glib.cpp
parent33e2cf2d1ceff1515b2d7d2a2c29a48de63181b3 (diff)
downloadtqt3-5faba37f113b6a4d75d7526cbbc1f363a465c39f.tar.gz
tqt3-5faba37f113b6a4d75d7526cbbc1f363a465c39f.zip
Automated update from Qt3
Diffstat (limited to 'src/kernel/qeventloop_x11_glib.cpp')
-rw-r--r--src/kernel/qeventloop_x11_glib.cpp85
1 files changed, 42 insertions, 43 deletions
diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp
index 5db73a8fb..f19f02f1e 100644
--- a/src/kernel/qeventloop_x11_glib.cpp
+++ b/src/kernel/qeventloop_x11_glib.cpp
@@ -54,6 +54,7 @@
#include <errno.h>
#include <glib.h>
+#include <sys/syscall.h>
// #define DEBUG_QT_GLIBMAINLOOP 1
@@ -109,7 +110,7 @@ static gboolean qt_gsource_check ( GSource *source )
}
}
-static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data )
+static gboolean qt_gsource_dispatch ( GSource *source, GSourceFunc callback, gpointer user_data )
{
Q_UNUSED(callback);
Q_UNUSED(user_data);
@@ -195,7 +196,7 @@ void qt_remove_postselect_handler( VFPTR handler )
void TQEventLoop::init()
{
// initialize ProcessEventFlags (all events & wait for more)
- d->pev_flags = AllEvents | WaitForMore;
+ d->pev_flags = AllEvents | WaitForMore;
// initialize the common parts of the event loop
if (pipe( d->thread_pipe ) < 0) {
@@ -239,13 +240,12 @@ void TQEventLoop::init()
// poll thread-pipe
d->threadPipe_gPollFD.fd = d->thread_pipe[0];
d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
-
+
g_source_add_poll(d->gSource, &d->threadPipe_gPollFD);
-
+
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(2)\n");
#endif
-
}
void TQEventLoop::cleanup()
@@ -266,25 +266,24 @@ void TQEventLoop::cleanup()
bool TQEventLoop::processEvents( ProcessEventsFlags flags )
{
-
#ifdef DEBUG_QT_GLIBMAINLOOP
- printf("inside processEvents(1) looplevel=%d\n", d->looplevel );
+ printf("inside processEvents(1) looplevel=%d eventloop=%p d->ctx=%p this=%p\n", d->looplevel, TQApplication::eventLoop(), d->ctx, this ); fflush(stdout);
#endif
-
+
ProcessEventsFlags save_flags;
int rval;
save_flags = d->pev_flags;
-
+
d->pev_flags = flags;
-
+
rval = g_main_context_iteration(d->ctx, flags & WaitForMore ? TRUE : FALSE);
-
+
d->pev_flags = save_flags;
-
+
#ifdef DEBUG_QT_GLIBMAINLOOP
- printf("inside processEvents(2) looplevel=%d rval=%d\n", d->looplevel, rval );
-#endif
-
+ printf("inside processEvents(2) looplevel=%d eventloop=%p d->ctx=%p this=%p rval=%d\n", d->looplevel, TQApplication::eventLoop(), d->ctx, this, rval ); fflush(stdout);
+#endif
+
return rval; // were events processed?
}
@@ -312,9 +311,9 @@ bool TQEventLoop::processX11Events()
if ( d->shortcut ) {
return FALSE;
}
-
+
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
-
+
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
case ButtonPress:
@@ -325,31 +324,31 @@ bool TQEventLoop::processX11Events()
case EnterNotify:
case LeaveNotify:
continue;
-
+
case ClientMessage:
{
// from qapplication_x11.cpp
extern Atom tqt_wm_protocols;
extern Atom tqt_wm_take_focus;
extern Atom qt_qt_scrolldone;
-
+
// only keep the wm_take_focus and
// qt_qt_scrolldone protocols, discard all
// other client messages
if ( event.xclient.format != 32 )
continue;
-
+
if ( event.xclient.message_type == tqt_wm_protocols ||
(Atom) event.xclient.data.l[0] == tqt_wm_take_focus )
break;
if ( event.xclient.message_type == qt_qt_scrolldone )
break;
}
-
+
default: break;
}
}
-
+
nevents++;
if ( tqApp->x11ProcessEvent( &event ) == 1 ) {
return TRUE;
@@ -358,13 +357,13 @@ bool TQEventLoop::processX11Events()
}
}
}
-
+
if ( d->shortcut ) {
return FALSE;
}
TQApplication::sendPostedEvents();
-
+
const uint exclude_all = ExcludeSocketNotifiers | 0x08;
// 0x08 == ExcludeTimers for X11 only
if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && ( flags & WaitForMore ) ) {
@@ -372,27 +371,27 @@ bool TQEventLoop::processX11Events()
}
return FALSE;
}
-
-
+
+
bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
{
Q_UNUSED(gs);
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(1)\n");
-#endif
+#endif
ProcessEventsFlags flags = d->pev_flags;
-
+
#if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex );
#endif
-
+
// don't block if exitLoop() or exit()/quit() has been called.
bool canWait = d->exitloop || d->quitnow ? FALSE : (flags & WaitForMore);
-
+
// Process timers and socket notifiers - the common UNIX stuff
-
+
// return the maximum time we can wait for an event.
static timeval zerotm;
timeval *tm = 0;
@@ -406,13 +405,13 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
tm->tv_usec = 0;
}
}
-
+
// include or exclude SocketNotifiers (by setting or cleaning poll events)
if ( ! ( flags & ExcludeSocketNotifiers ) ) {
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
- ++it;
+ ++it;
sn->gPollFD.events = sn->events; // restore poll events
}
}
@@ -420,7 +419,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
TQPtrListIterator<TQSockNotGPollFD> it( d->sn_list );
TQSockNotGPollFD *sn;
while ( (sn=it.current()) ) {
- ++it;
+ ++it;
sn->gPollFD.events = 0; // delete poll events
}
}
@@ -428,7 +427,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2) canwait=%d\n", canWait);
#endif
-
+
if ( canWait ) {
emit aboutToBlock();
}
@@ -442,7 +441,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(2.1) canwait=%d\n", canWait);
#endif
-
+
// do we have to dispatch events?
if (hasPendingEvents()) {
*timeout = 0; // no time to stay in poll
@@ -451,7 +450,7 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#endif
return FALSE;
}
-
+
// stay in poll until something happens?
if (!tm) { // fixme
*timeout = -1; // wait forever
@@ -460,10 +459,10 @@ bool TQEventLoop::gsourcePrepare(GSource *gs, int * timeout)
#endif
return FALSE;
}
-
+
// else timeout >=0
*timeout = tm->tv_sec * 1000 + tm->tv_usec/1000;
-
+
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourcePrepare(3c) timeout=%d \n", *timeout);
#endif
@@ -519,7 +518,7 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n");
#endif
-
+
return TRUE;
}
@@ -553,10 +552,10 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
// we are awake, broadcast it
emit awake();
emit tqApp->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;
if (::read( d->thread_pipe[0], &c, 1 ) < 0) {
@@ -666,4 +665,4 @@ void TQEventLoop::setSingleToolkitEventHandling(bool enabled) {
d->ctx_is_default = true;
}
}
-} \ No newline at end of file
+}