From 1cabe720eb48eb0fd29421b4dcdf8c3f58eaf71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20=C3=96gren?= Date: Thu, 28 Jul 2005 21:50:32 +0000 Subject: [PATCH] Avoid spurious core pointer events when the tablet pen is lifted. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-28 Robert Ögren Avoid spurious core pointer events when the tablet pen is lifted. (#167000) * gdk/win32/gdkinput-win32.c (set_ignore_core): New static function, handles delayed unsetting of _gdk_input_ignore_core. (_gdk_input_other_event): Call set_ignore_core instead of setting _gdk_input_ignore_core directly. --- ChangeLog | 12 +++++++++- ChangeLog.pre-2-10 | 12 +++++++++- ChangeLog.pre-2-8 | 12 +++++++++- gdk/win32/gdkinput-win32.c | 47 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3dd1091185..c763e7110b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-07-28 Robert Ögren + + Avoid spurious core pointer events when the tablet pen is lifted. + (#167000) + + * gdk/win32/gdkinput-win32.c (set_ignore_core): New static function, + handles delayed unsetting of _gdk_input_ignore_core. + (_gdk_input_other_event): Call set_ignore_core instead of setting + _gdk_input_ignore_core directly. + 2005-07-27 Tor Lillqvist * gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle @@ -52,7 +62,7 @@ them for staleness like the other caches. (#310221, Mark McLoughlin) -2005-07-13 Robert Ögren +2005-07-13 Robert Ögren Fix handling of Aiptek and Aiptek-like graphical tablets such as Trust on Windows. (#167004, thanks to "pnohant" for testing) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3dd1091185..c763e7110b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,13 @@ +2005-07-28 Robert Ögren + + Avoid spurious core pointer events when the tablet pen is lifted. + (#167000) + + * gdk/win32/gdkinput-win32.c (set_ignore_core): New static function, + handles delayed unsetting of _gdk_input_ignore_core. + (_gdk_input_other_event): Call set_ignore_core instead of setting + _gdk_input_ignore_core directly. + 2005-07-27 Tor Lillqvist * gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle @@ -52,7 +62,7 @@ them for staleness like the other caches. (#310221, Mark McLoughlin) -2005-07-13 Robert Ögren +2005-07-13 Robert Ögren Fix handling of Aiptek and Aiptek-like graphical tablets such as Trust on Windows. (#167004, thanks to "pnohant" for testing) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3dd1091185..c763e7110b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,13 @@ +2005-07-28 Robert Ögren + + Avoid spurious core pointer events when the tablet pen is lifted. + (#167000) + + * gdk/win32/gdkinput-win32.c (set_ignore_core): New static function, + handles delayed unsetting of _gdk_input_ignore_core. + (_gdk_input_other_event): Call set_ignore_core instead of setting + _gdk_input_ignore_core directly. + 2005-07-27 Tor Lillqvist * gdk/win32/gdkmain-win32.c (_gdk_win32_psstyle_to_string): Handle @@ -52,7 +62,7 @@ them for staleness like the other caches. (#310221, Mark McLoughlin) -2005-07-13 Robert Ögren +2005-07-13 Robert Ögren Fix handling of Aiptek and Aiptek-like graphical tablets such as Trust on Windows. (#167004, thanks to "pnohant" for testing) diff --git a/gdk/win32/gdkinput-win32.c b/gdk/win32/gdkinput-win32.c index 7596ad479d..ac382ddd92 100644 --- a/gdk/win32/gdkinput-win32.c +++ b/gdk/win32/gdkinput-win32.c @@ -45,6 +45,8 @@ #define DEBUG_WINTAB 1 /* Verbose debug messages enabled */ +#define PROXIMITY_OUT_DELAY 200 /* In milliseconds, see set_ignore_core */ + #endif #if defined(HAVE_WINTAB) || defined(HAVE_WHATEVER_OTHER) @@ -652,6 +654,47 @@ get_modifier_key_state (void) return state; } +#ifdef HAVE_WINTAB + +static guint ignore_core_timer = 0; + +static gboolean +ignore_core_timefunc (gpointer data) +{ + /* The delay has passed */ + _gdk_input_ignore_core = FALSE; + ignore_core_timer = 0; + + return FALSE; /* remove timeout */ +} + +/* + * Set or unset the _gdk_input_ignore_core variable that tells GDK + * to ignore events for the core pointer when the tablet is in proximity + * The unsetting is delayed slightly so that if a tablet event arrives + * just after proximity out, it does not cause a core pointer event + * which e.g. causes GIMP to switch tools. + */ +static void +set_ignore_core (gboolean ignore) +{ + if (ignore) + { + _gdk_input_ignore_core = TRUE; + /* Remove any pending clear */ + if (ignore_core_timer) + { + g_source_remove (ignore_core_timer); + ignore_core_timer = 0; + } + } + else + if (!ignore_core_timer) + ignore_core_timer = g_timeout_add (PROXIMITY_OUT_DELAY, + ignore_core_timefunc, NULL); +} +#endif /* HAVE_WINTAB */ + gboolean _gdk_input_other_event (GdkEvent *event, MSG *msg, @@ -934,12 +977,12 @@ _gdk_input_other_event (GdkEvent *event, if (LOWORD (msg->lParam) == 0) { event->proximity.type = GDK_PROXIMITY_OUT; - _gdk_input_ignore_core = FALSE; + set_ignore_core (FALSE); } else { event->proximity.type = GDK_PROXIMITY_IN; - _gdk_input_ignore_core = TRUE; + set_ignore_core (TRUE); } event->proximity.time = _gdk_win32_get_next_tick (msg->time); event->proximity.device = &gdkdev->info;