summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-24 12:03:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-04-24 12:12:23 +0100
commit658954e8b50fc264428402dc5a95b0d6f690d191 (patch)
tree3971bc9f3b87dc82f32ea979d6530e71dca76d4d
parentdfc7c67e464e57f5442365e193c56033af564d84 (diff)
Resolves: fdo#48011 writer idle-callbacks are halting when events pending
Writer does a lot of work, e.g. spell-checking, word counting etc. in idle-callbacks. It halts work by checking for AnyInput, and if any input or paint etc is pending the idle-callbacks stop. With gtk3 rework pending events don't seem to be available quite right.
-rw-r--r--vcl/unx/generic/app/salinst.cxx3
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx54
2 files changed, 43 insertions, 14 deletions
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index 9bf80c45655e..cb1140603e4b 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -147,9 +147,8 @@ bool X11SalInstance::AnyInput(sal_uInt16 nType)
Display *pDisplay = pData->GetSalDisplay()->GetDisplay();
sal_Bool bRet = sal_False;
- if( (nType & VCL_INPUT_TIMER) && mpXLib->CheckTimeout( false ) )
+ if( (nType & VCL_INPUT_TIMER) && (mpXLib && mpXLib->CheckTimeout(false)) )
bRet = sal_True;
-
else if (XPending(pDisplay) )
{
PredicateReturn aInput;
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index 8cc92da01fa6..c78de14b9fba 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -27,6 +27,7 @@
************************************************************************/
+#include <stack>
#include <string.h>
#include <osl/module.h>
#define GLIB_DISABLE_DEPRECATION_WARNINGS
@@ -264,12 +265,11 @@ extern "C" {
return GDK_FILTER_CONTINUE;
}
- // And then again as they pop out of gdk and into gtk+
-
- static void _sal_gtk_event_handler_fn (GdkEvent *pEvent, gpointer data)
+ static sal_uInt16 categorizeEvent(const GdkEvent *pEvent)
{
sal_uInt16 nType = 0;
- switch( pEvent->type ) {
+ switch( pEvent->type )
+ {
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
@@ -291,8 +291,16 @@ extern "C" {
nType = VCL_INPUT_OTHER;
break;
}
- ((GtkInstance *)data)->subtractEvent( nType );
+ return nType;
+ }
+
+ // And then again as they pop out of gdk and into gtk+
+
+ static void _sal_gtk_event_handler_fn (GdkEvent *pEvent, gpointer data)
+ {
+ sal_uInt16 nType = categorizeEvent(pEvent);
+ ((GtkInstance *)data)->subtractEvent( nType );
gtk_main_do_event( pEvent );
}
}
@@ -623,16 +631,38 @@ bool GtkInstance::AnyInput( sal_uInt16 nType )
{
if( (nType & VCL_INPUT_TIMER) && IsTimerExpired() )
return true;
- else
+#if !GTK_CHECK_VERSION(3,0,0)
+ bool bRet = X11SalInstance::AnyInput(nType);
+#else
+ if (!gdk_events_pending())
+ return false;
+
+ if (nType == VCL_INPUT_ANY)
+ return true;
+
+ bool bRet = false;
+ std::stack<GdkEvent*> aEvents;
+ GdkEvent *pEvent = NULL;
+ while ((pEvent = gdk_event_get()))
{
- bool bRet = false;
- sal_uInt16 nShift = 1;
- for (int i = 0; i < 16; i++) {
- bRet |= (nType & nShift) && m_nAnyInput[i] > 0;
- nShift <<= 1;
+ aEvents.push(pEvent);
+ sal_uInt16 nEventType = categorizeEvent(pEvent);
+ if ( (nEventType & nType) || ( ! nEventType && (nType & VCL_INPUT_OTHER) ) )
+ {
+ bRet = true;
+ break;
}
- return bRet;
}
+
+ while (!aEvents.empty())
+ {
+ pEvent = aEvents.top();
+ gdk_event_put(pEvent);
+ gdk_event_free(pEvent);
+ aEvents.pop();
+ }
+#endif
+ return bRet;
}
GenPspGraphics *GtkInstance::CreatePrintGraphics()