[mousetweaks] Fix secondary clicks
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Fix secondary clicks
- Date: Sat, 6 Mar 2010 14:08:57 +0000 (UTC)
commit d117f069f942dc40b7425d0383b2c56a2b537c03
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Sat Mar 6 14:43:57 2010 +0100
Fix secondary clicks
Newer X Server versions ignore unexpected ("out-of-sequence")
button-release events. Instead of sending our synthetic
secondary-click immediately after the timer has finished,
we wait until the primary button is released.
src/mt-main.c | 54 +++++++++++++++++++++++-------------------------------
src/mt-main.h | 1 +
2 files changed, 24 insertions(+), 31 deletions(-)
---
diff --git a/src/mt-main.c b/src/mt-main.c
index c92d1e8..85cffce 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -408,40 +408,23 @@ mt_main_use_move_release (MtData *mt)
return FALSE;
}
-static gboolean
-right_click_timeout (gpointer data)
+static void
+delay_timer_finished (MtTimer *timer, MtData *mt)
{
- MtData *mt = data;
+ /* set secondary-click flag */
+ mt->delay_finished = TRUE;
- mt_main_generate_button_event (mt, 3, CLICK, CurrentTime);
-
- return FALSE;
+ if (mt->move_release) {
+ mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
+ mt_main_generate_button_event (mt, 3, CLICK, CurrentTime);
+ }
}
static void
-delay_timer_finished (MtTimer *timer, gpointer data)
+mt_main_do_secondary_click (MtData *mt)
{
- MtData *mt = data;
- GdkScreen *screen;
-
- mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
-
- if (mt->move_release || mt_main_use_move_release (mt)) {
- /* release the click outside of the focused object to
- * abort any action started by button-press.
- */
- screen = mt_main_current_screen (mt);
- mt_main_generate_motion_event (screen, 0, 0);
- mt_main_generate_button_event (mt, 1, RELEASE, CurrentTime);
- mt_main_generate_motion_event (screen, mt->pointer_x, mt->pointer_y);
- }
- else {
- mt_main_generate_button_event (mt, 1, RELEASE, CurrentTime);
- }
- /* wait 100 msec before releasing the button again -
- * gives apps some time to release active grabs, eg: gnome-panel 'move'
- */
- g_timeout_add (100, right_click_timeout, data);
+ mt->delay_finished = FALSE;
+ mt_main_generate_button_event (mt, 3, CLICK, CurrentTime);
}
static void
@@ -471,10 +454,15 @@ global_motion_event (MtListener *listener,
{
MtData *mt = data;
- if (mt_timer_is_running (mt->delay_timer)) {
+ if (mt->delay_enabled) {
if (!below_threshold (mt, event->x, event->y)) {
- mt_timer_stop (mt->delay_timer);
mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
+
+ if (mt_timer_is_running (mt->delay_timer))
+ mt_timer_stop (mt->delay_timer);
+
+ if (mt->delay_finished)
+ mt->delay_finished = FALSE;
}
}
@@ -515,8 +503,12 @@ global_button_event (MtListener *listener,
mt_timer_start (mt->delay_timer);
}
else {
- mt_timer_stop (mt->delay_timer);
mt_cursor_manager_restore_all (mt_cursor_manager_get_default ());
+
+ if (mt->delay_finished)
+ mt_main_do_secondary_click (mt);
+ else
+ mt_timer_stop (mt->delay_timer);
}
}
/*
diff --git a/src/mt-main.h b/src/mt-main.h
index beedd94..c3d7807 100644
--- a/src/mt-main.h
+++ b/src/mt-main.h
@@ -61,6 +61,7 @@ struct _MtData {
guint dwell_gesture_started : 1;
guint override_cursor : 1;
guint move_release : 1;
+ guint delay_finished : 1;
};
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]