summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-24 12:03:27 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-04-24 18:03:20 +0100
commit8ceb098374284d4ab78a6e6e649b0674dcae40d4 (patch)
tree67c23b7232e5706d13053d6f20c8771bb251d232
parentc5282a72180ab7747c923cdc2b1988d15d3956b1 (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. Signed-off-by: Michael Meeks <michael.meeks@suse.com>
-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 33e4ede840e6..64e29e5c9573 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -148,9 +148,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 b6eacc9b3449..f409bfa60619 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>
#include <unx/gtk/gtkdata.hxx>
@@ -263,12 +264,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:
@@ -290,8 +290,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 );
}
}
@@ -622,16 +630,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()