summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2016-06-07 14:03:44 +0300
committerLászló Németh <laszlo.nemeth@collabora.com>2016-06-10 16:30:05 +0200
commit30104ff4c76b7f31450f525b4a6d7ebad9823aad (patch)
tree2acb9d7ff08a286c88841943b4cc1bdec2ca2aad
parente9fadde3c56a1e8bbb1ffe3ded861fbcd3252407 (diff)
Add a pause() method to XToolkitExperimental
Pauses the main thread of LibreOffice for the requested amount of time. Change-Id: I5978a3a9b9561623c698526d8c29695d71df3d03
-rw-r--r--offapi/com/sun/star/awt/XToolkitExperimental.idl5
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx35
2 files changed, 39 insertions, 1 deletions
diff --git a/offapi/com/sun/star/awt/XToolkitExperimental.idl b/offapi/com/sun/star/awt/XToolkitExperimental.idl
index 89828b2864e1..5764ef5fc44f 100644
--- a/offapi/com/sun/star/awt/XToolkitExperimental.idl
+++ b/offapi/com/sun/star/awt/XToolkitExperimental.idl
@@ -23,7 +23,6 @@ interface XToolkitExperimental : XToolkit2
*/
void processEventsToIdle();
-
/** Get the number of OpenGL buffer swaps.
*/
hyper getOpenGLBufferSwapCounter();
@@ -31,6 +30,10 @@ interface XToolkitExperimental : XToolkit2
/** Turn on or off deterministic scheduling (off is the default).
*/
void setDeterministicScheduling([in] boolean bDeterministicMode);
+
+ /** Pause the main thread of LibreOffice for the requested amount of time.
+ */
+ void pause([in] long nMilliseconds);
};
}; }; }; };
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 2dfa25cf13cb..7916de775756 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -143,6 +143,32 @@ extern "C" typedef vcl::Window* (SAL_CALL *FN_SvtCreateWindow)(
vcl::Window* pParent,
WinBits nWinBits );
+class Pause : public Idle
+{
+public:
+ Pause(sal_Int32 nPauseMilliseconds) :
+ Idle("pause"),
+ m_nPauseMilliseconds(nPauseMilliseconds)
+ {
+ SetPriority(SchedulerPriority::HIGHEST);
+ Start();
+ }
+
+ virtual ~Pause()
+ {
+ }
+
+ virtual void Invoke() override
+ {
+ SolarMutexGuard aSolarGuard;
+ osl::Thread::wait(std::chrono::milliseconds(m_nPauseMilliseconds));
+ Stop();
+ delete this;
+ }
+
+ sal_Int32 m_nPauseMilliseconds;
+};
+
class VCLXToolkitMutexHelper
{
protected:
@@ -205,6 +231,9 @@ public:
virtual void SAL_CALL setDeterministicScheduling(sal_Bool bDeterministicMode)
throw (css::uno::RuntimeException, std::exception) override;
+ virtual void SAL_CALL pause(sal_Int32 nMilliseconds)
+ throw (css::uno::RuntimeException, std::exception) override;
+
// css::awt::XToolkit
css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getDesktopWindow( ) throw(css::uno::RuntimeException, std::exception) override;
css::awt::Rectangle SAL_CALL getWorkArea( ) throw(css::uno::RuntimeException, std::exception) override;
@@ -1942,6 +1971,12 @@ void SAL_CALL VCLXToolkit::setDeterministicScheduling(sal_Bool bDeterministicMod
Scheduler::SetDeterministicMode(bDeterministicMode);
}
+void SAL_CALL VCLXToolkit::pause(sal_Int32 nMilliseconds)
+ throw (css::uno::RuntimeException, std::exception)
+{
+ new Pause(nMilliseconds);
+}
+
// css:awt:XToolkitRobot
void SAL_CALL VCLXToolkit::keyPress( const css::awt::KeyEvent & aKeyEvent )