summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-11-10 18:16:49 +0000
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:24 +0200
commit1fedc1c38a141bf071c707fda6a3ae1a5bf8fd41 (patch)
tree746cde94a532d5bf4faf48f14a37e9b03f012e66 /vcl/unx
parentbe04f9e3dcbab2dacb63cfaa2e787db9f1aa16dc (diff)
KDE4 handle timers via queued custom events
Post the system timer as a custom event to the event queue and also changes the PostUserEvent froom a timer to a posted custom event. Change-Id: I0b77e0c64fce04b20e82ba8bbf72b7a99b1339af
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/kde4/KDEXLib.cxx45
-rw-r--r--vcl/unx/kde4/KDEXLib.hxx9
2 files changed, 20 insertions, 34 deletions
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 8031f05d1cd7..abcc47510dca 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -50,8 +50,12 @@
KDEXLib::KDEXLib() :
SalXLib(), m_bStartupDone(false),
m_pFreeCmdLineArgs(nullptr), m_pAppCmdLineArgs(nullptr), m_nFakeCmdLineArgs( 0 ),
- m_isGlibEventLoopType(false), m_allowKdeDialogs(false)
+ m_isGlibEventLoopType(false), m_allowKdeDialogs(false),
+ m_timerEventId( -1 ), m_postUserEventId( -1 )
{
+ m_timerEventId = QEvent::registerEventType();
+ m_postUserEventId = QEvent::registerEventType();
+
// the timers created here means they belong to the main thread.
// As the timeoutTimer runs the LO event queue, which may block on a dialog,
// the timer has to use a Qt::QueuedConnection, otherwise the nested event
@@ -59,12 +63,10 @@ KDEXLib::KDEXLib() :
// freezing LO X11 processing.
timeoutTimer.setSingleShot( true );
connect( &timeoutTimer, SIGNAL( timeout()), this, SLOT( timeoutActivated()), Qt::QueuedConnection );
- connect( &userEventTimer, SIGNAL( timeout()), this, SLOT( userEventActivated()), Qt::QueuedConnection );
// QTimer::start() can be called only in its (here main) thread, so this will
// forward between threads if needed
connect( this, SIGNAL( startTimeoutTimerSignal()), this, SLOT( startTimeoutTimer()), Qt::QueuedConnection );
- connect( this, SIGNAL( startUserEventTimerSignal()), this, SLOT( startUserEventTimer()), Qt::QueuedConnection );
// this one needs to be blocking, so that the handling in main thread is processed before
// the thread emitting the signal continues
@@ -339,17 +341,16 @@ void KDEXLib::StopTimer()
void KDEXLib::timeoutActivated()
{
- // HACK? Always process posted events before timer timeouts.
- // There are places that may watch both (for example, there's a posted
- // event about change of the current active window and there's a timeout
- // event informing that a document has finished loading). This is of course
- // racy, but both generic and gtk event loops manage to deliver posted events
- // first, so it's at least consistent, and it probably kind of makes at least
- // some sense (timeouts should be more ok to wait and be triggered somewhen).
- while( SalKDEDisplay::self()->HasUserEvents() )
+ // don't potentially wait in timeout, as QTimer is non-recursive
+ QApplication::postEvent(this, new QEvent(QEvent::Type( m_timerEventId )));
+}
+
+void KDEXLib::customEvent(QEvent* e)
+{
+ if( e->type() == m_timerEventId )
+ X11SalData::Timeout();
+ else if( e->type() == m_postUserEventId )
SalKDEDisplay::self()->DispatchInternalEvent();
- X11SalData::Timeout();
- // QTimer is not single shot, so will be restarted immediately
}
void KDEXLib::Wakeup()
@@ -363,23 +364,7 @@ void KDEXLib::PostUserEvent()
{
if( !m_isGlibEventLoopType )
return SalXLib::PostUserEvent();
- if( qApp->thread() == QThread::currentThread())
- startUserEventTimer();
- else
- Q_EMIT startUserEventTimerSignal();
-}
-
-void KDEXLib::startUserEventTimer()
-{
- userEventTimer.start( 0 );
-}
-
-void KDEXLib::userEventActivated()
-{
- if( ! SalKDEDisplay::self()->HasUserEvents() )
- userEventTimer.stop();
- SalKDEDisplay::self()->DispatchInternalEvent();
- // QTimer is not single shot, so will be restarted immediately
+ QApplication::postEvent(this, new QEvent(QEvent::Type( m_postUserEventId )));
}
void KDEXLib::doStartup()
diff --git a/vcl/unx/kde4/KDEXLib.hxx b/vcl/unx/kde4/KDEXLib.hxx
index 1242d4542ac6..6d5f3b8232ef 100644
--- a/vcl/unx/kde4/KDEXLib.hxx
+++ b/vcl/unx/kde4/KDEXLib.hxx
@@ -52,9 +52,10 @@ class KDEXLib : public QObject, public SalXLib
};
QHash< int, SocketData > socketData; // key is fd
QTimer timeoutTimer;
- QTimer userEventTimer;
bool m_isGlibEventLoopType;
bool m_allowKdeDialogs;
+ int m_timerEventId;
+ int m_postUserEventId;
private:
void setupEventLoop();
@@ -62,13 +63,11 @@ class KDEXLib : public QObject, public SalXLib
private Q_SLOTS:
void socketNotifierActivated( int fd );
void timeoutActivated();
- void userEventActivated();
void startTimeoutTimer();
- void startUserEventTimer();
static bool processYield( bool bWait, bool bHandleAllCurrentEvents );
+
Q_SIGNALS:
void startTimeoutTimerSignal();
- void startUserEventTimerSignal();
void processYieldSignal( bool bWait, bool bHandleAllCurrentEvents );
css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePickerSignal( const css::uno::Reference< css::uno::XComponentContext >& );
@@ -89,6 +88,8 @@ class KDEXLib : public QObject, public SalXLib
void doStartup();
bool allowKdeDialogs() { return m_allowKdeDialogs; }
+ virtual void customEvent(QEvent* e) override;
+
public Q_SLOTS:
css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& );