summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-06-13 09:20:18 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-06-13 10:43:49 +0900
commitd4981524d7cb87bf2e100ee981ac0d082b79790b (patch)
treede8fe914df12775163341fd319cb70676ac03dfb
parentd7d6cb215181eaa02e5aea89149fc2c6d702ddc5 (diff)
downloadtqt-d4981524d7cb87bf2e100ee981ac0d082b79790b.tar.gz
tqt-d4981524d7cb87bf2e100ee981ac0d082b79790b.zip
Improve X11 'ProcessEvents()' with some code from the equivalent glib version
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 9735ca1c135526e713a529640ed1ee2d1cdf48ca)
-rw-r--r--src/kernel/qeventloop_x11.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/kernel/qeventloop_x11.cpp b/src/kernel/qeventloop_x11.cpp
index 163f8d771..a907a11e1 100644
--- a/src/kernel/qeventloop_x11.cpp
+++ b/src/kernel/qeventloop_x11.cpp
@@ -207,8 +207,7 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
TQApplication::sendPostedEvents();
const uint exclude_all = ExcludeSocketNotifiers | ExcludeTimers;
- if ( nevents > 0 && ( flags & exclude_all ) == exclude_all &&
- ( flags & WaitForMore ) ) {
+ if ( nevents > 0 && ( flags & exclude_all ) == exclude_all && ( flags & WaitForMore ) ) {
return TRUE;
}
@@ -221,12 +220,14 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
static timeval zerotm;
timeval *tm = 0;
if ( ! ( flags & ExcludeTimers ) ) {
- tm = qt_wait_timer(); // wait for TQt timers
- if ( !canWait ) {
- if ( !tm )
- tm = &zerotm;
- tm->tv_sec = 0; // no time to wait
- tm->tv_usec = 0;
+ if (TQApplication::isGuiThread()) {
+ tm = qt_wait_timer(); // wait for TQt timers
+ if ( !canWait ) {
+ if ( !tm )
+ tm = &zerotm;
+ tm->tv_sec = 0; // no time to wait
+ tm->tv_usec = 0;
+ }
}
}
@@ -391,7 +392,9 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
// activate timers
if ( ! ( flags & ExcludeTimers ) ) {
- nevents += activateTimers();
+ if (TQApplication::isGuiThread()) {
+ nevents += activateTimers();
+ }
}
// color approx. optimization - only on X11
@@ -403,8 +406,12 @@ bool TQEventLoop::processEvents( ProcessEventsFlags flags )
bool TQEventLoop::hasPendingEvents() const
{
+#ifdef TQT_THREAD_SUPPORT
+ TQMutexLocker locker( TQApplication::tqt_mutex );
+#endif // TQT_THREAD_SUPPORT
+
extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
- return ( qGlobalPostedEventsCount() || XPending( TQPaintDevice::x11AppDisplay() ) );
+ return ( qGlobalPostedEventsCount() || ( (tqt_is_gui_used && TQApplication::isGuiThread()) ? XPending( TQPaintDevice::x11AppDisplay() ) : 0));
}
void TQEventLoop::appStartingUp()