summaryrefslogtreecommitdiffstats
path: root/src/kernel
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-12-09 16:34:42 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-12-09 16:34:42 -0600
commite863a01b9b25bb426f1475d8e1e7a05f10f75177 (patch)
treebe4b9f0abd55eb267680fd8bfa936925df70dac1 /src/kernel
parent3289e9c0d823a61384976d2c356b7523f093b886 (diff)
downloadtqt3-e863a01b9b25bb426f1475d8e1e7a05f10f75177.tar.gz
tqt3-e863a01b9b25bb426f1475d8e1e7a05f10f75177.zip
Automated update from Qt3
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/qeventloop_glib_p.h10
-rw-r--r--src/kernel/qeventloop_x11_glib.cpp116
2 files changed, 70 insertions, 56 deletions
diff --git a/src/kernel/qeventloop_glib_p.h b/src/kernel/qeventloop_glib_p.h
index c67fdbd85..537406854 100644
--- a/src/kernel/qeventloop_glib_p.h
+++ b/src/kernel/qeventloop_glib_p.h
@@ -86,6 +86,10 @@ class TQEventLoopPrivate
public:
TQEventLoopPrivate()
{
+#if defined(Q_WS_X11)
+ xfd = -1;
+ x_gPollFD.fd = -1;
+#endif // Q_WS_X11
reset();
}
@@ -106,9 +110,7 @@ public:
#if defined(Q_WS_X11)
int xfd;
-
- GPollFD x_gPollFD;
-
+ GPollFD x_gPollFD;
#endif // Q_WS_X11
int thread_pipe[2];
@@ -119,7 +121,7 @@ public:
TQPtrList<TQSockNotGPollFD> sn_pending_list;
// store flags for one iteration
- uint pev_flags;
+ uint pev_flags;
// My GSource
GSource * gSource;
diff --git a/src/kernel/qeventloop_x11_glib.cpp b/src/kernel/qeventloop_x11_glib.cpp
index 5c7b98b2a..40205f805 100644
--- a/src/kernel/qeventloop_x11_glib.cpp
+++ b/src/kernel/qeventloop_x11_glib.cpp
@@ -82,15 +82,32 @@ static GSourceFuncs qt_gsource_funcs = {
static gboolean qt_gsource_prepare ( GSource *source,
gint *timeout )
{
- TQtGSource * qtGSource;
- qtGSource = (TQtGSource*) source;
- return qtGSource->qeventLoop->gsourcePrepare(source, timeout);
+ TQtGSource * qtGSource = (TQtGSource*) source;
+ TQEventLoop* candidateEventLoop = qtGSource->qeventLoop;
+ TQEventLoop* activeThreadEventLoop = TQApplication::eventLoop();
+
+ if (candidateEventLoop == activeThreadEventLoop) {
+ return candidateEventLoop->gsourcePrepare(source, timeout);
+ }
+ else {
+ // Prepare failed
+ return FALSE;
+ }
}
static gboolean qt_gsource_check ( GSource *source )
{
TQtGSource * qtGSource = (TQtGSource*) source;
- return qtGSource->qeventLoop->gsourceCheck(source);
+ TQEventLoop* candidateEventLoop = qtGSource->qeventLoop;
+ TQEventLoop* activeThreadEventLoop = TQApplication::eventLoop();
+
+ if (candidateEventLoop == activeThreadEventLoop) {
+ return candidateEventLoop->gsourceCheck(source);
+ }
+ else {
+ // Check failed
+ return FALSE;
+ }
}
static gboolean qt_gsource_dispatch ( GSource *source,
@@ -205,25 +222,24 @@ void TQEventLoop::init()
qtGSource->qeventLoop = this;
// init main loop and attach gsource
-
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside init(1)\n");
#endif
g_main_loop_new (d->ctx, 1);
g_source_attach( (GSource*)qtGSource, d->ctx );
- d->gSource = (GSource*) qtGSource;
+ d->gSource = (GSource*)qtGSource;
// poll for X11 events
if ( tqt_is_gui_used && TQApplication::isGuiThread() ) {
d->x_gPollFD.fd = d->xfd;
- d->x_gPollFD.events = G_IO_IN | G_IO_HUP;
+ d->x_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->x_gPollFD);
}
// poll thread-pipe
d->threadPipe_gPollFD.fd = d->thread_pipe[0];
- d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP;
+ d->threadPipe_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
g_source_add_poll(d->gSource, &d->threadPipe_gPollFD);
@@ -279,7 +295,7 @@ bool TQEventLoop::processX11Events()
ProcessEventsFlags flags = d->pev_flags;
// process events from the X server
XEvent event;
- int nevents = 0;
+ int nevents = 0;
#if defined(QT_THREAD_SUPPORT)
TQMutexLocker locker( TQApplication::tqt_mutex );
@@ -295,49 +311,50 @@ bool TQEventLoop::processX11Events()
// also flushes output buffer
while ( XPending( TQPaintDevice::x11AppDisplay() ) ) {
if ( d->shortcut ) {
- return FALSE;
+ return FALSE;
}
XNextEvent( TQPaintDevice::x11AppDisplay(), &event );
if ( flags & ExcludeUserInput ) {
switch ( event.type ) {
- case ButtonPress:
- case ButtonRelease:
- case MotionNotify:
- case XKeyPress:
- case XKeyRelease:
- 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 )
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ case XKeyPress:
+ case XKeyRelease:
+ case EnterNotify:
+ case LeaveNotify:
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;
+
+ 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;
+ if ( tqApp->x11ProcessEvent( &event ) == 1 ) {
+ return TRUE;
+ }
}
}
}
@@ -463,14 +480,9 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
printf("inside gsourceCheck(1)\n");
#endif
-
// Socketnotifier events?
-
TQPtrList<TQSockNotGPollFD> *list = &d->sn_list;
-
//if ( list ) {
-
-
TQSockNotGPollFD *sn = list->first();
while ( sn ) {
if ( sn->gPollFD.revents )
@@ -500,10 +512,9 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
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();
-
if (tm && (tm->tv_sec == 0 && tm->tv_usec == 0 )) {
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) qtwaittimer!\n");
@@ -513,7 +524,6 @@ bool TQEventLoop::gsourceCheck(GSource *gs) {
}
// nothing to dispatch
-
#ifdef DEBUG_QT_GLIBMAINLOOP
printf("inside gsourceCheck(2) nothing to dispatch!\n");
#endif
@@ -534,7 +544,6 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
#endif
int nevents=0;
-
ProcessEventsFlags flags = d->pev_flags;
#ifdef DEBUG_QT_GLIBMAINLOOP
@@ -588,12 +597,10 @@ bool TQEventLoop::gsourceDispatch(GSource *gs) {
//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();
@@ -627,6 +634,11 @@ void TQEventLoop::appStartingUp()
{
if ( tqt_is_gui_used ) {
d->xfd = XConnectionNumber( TQPaintDevice::x11AppDisplay() );
+ if ( (d->x_gPollFD.fd == -1) && TQApplication::isGuiThread() ) {
+ d->x_gPollFD.fd = d->xfd;
+ d->x_gPollFD.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
+ g_source_add_poll(d->gSource, &d->x_gPollFD);
+ }
}
}