[mousetweaks] Fix synthetic clicks for left-handed mouse orientation - bgo#582319



commit 0f67d1b001c01c97671ab67b30e75bb62d49af5f
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Fri May 15 19:41:47 2009 +0200

    Fix synthetic clicks for left-handed mouse orientation - bgo#582319
---
 src/mt-common.h |    3 +++
 src/mt-main.c   |   23 +++++++++++++++++++++++
 src/mt-main.h   |    1 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/mt-common.h b/src/mt-common.h
index 5256603..3dc7bdc 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -45,6 +45,9 @@ G_BEGIN_DECLS
 #define OPT_STYLE     MT_GCONF_HOME "/button_layout"
 #define OPT_ANIMATE   MT_GCONF_HOME "/animate_cursor"
 
+#define GNOME_MOUSE_DIR "/desktop/gnome/peripherals/mouse"
+#define GNOME_MOUSE_ORIENT GNOME_MOUSE_DIR "/left_handed"
+
 #define GNOME_A11Y_KEY "/desktop/gnome/interface/accessibility"
 
 enum {
diff --git a/src/mt-main.c b/src/mt-main.c
index 48cd14a..d69a895 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -72,12 +72,26 @@ mt_main_generate_motion_event (GdkScreen *screen, gint x, gint y)
     gdk_error_trap_pop ();
 }
 
+static guint
+mt_main_check_mouse_orientation (MtData *mt, guint button)
+{
+    if (mt->left_handed) {
+	if (button == 1)
+	    return 3;
+	else if (button == 3)
+	    return 1;
+    }
+    return button;
+}
+
 static void
 mt_main_generate_button_event (MtData *mt,
 			       guint   button,
 			       gint    type,
 			       gulong  delay)
 {
+    button = mt_main_check_mouse_orientation (mt, button);
+
     gdk_error_trap_push ();
     switch (type) {
 	case PRESS:
@@ -682,6 +696,10 @@ gconf_value_changed (GConfClient *client,
 	else
 	    mt_cursor_manager_restore_all (manager);
     }
+    else if (g_str_equal (key, GNOME_MOUSE_ORIENT) &&
+	     value->type == GCONF_VALUE_BOOL) {
+	mt->left_handed = gconf_value_get_bool (value);
+    }
 }
 
 static void
@@ -710,6 +728,9 @@ get_gconf_options (MtData *mt)
 	gconf_client_get_int (mt->client, OPT_G_DRAG, NULL);
     mt->dwell_dirs[DWELL_CLICK_TYPE_RIGHT] =
 	gconf_client_get_int (mt->client, OPT_G_RIGHT, NULL);
+
+    /* mouse orientation */
+    mt->left_handed = gconf_client_get_bool (mt->client, GNOME_MOUSE_ORIENT, NULL);
 }
 
 static void
@@ -785,6 +806,8 @@ mt_data_init (void)
     }
 
     mt->client = gconf_client_get_default ();
+    gconf_client_add_dir (mt->client, GNOME_MOUSE_DIR,
+			  GCONF_CLIENT_PRELOAD_NONE, NULL);
     gconf_client_add_dir (mt->client, MT_GCONF_HOME,
 			  GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
     g_signal_connect (mt->client, "value_changed",
diff --git a/src/mt-main.h b/src/mt-main.h
index e6d988e..beedd94 100644
--- a/src/mt-main.h
+++ b/src/mt-main.h
@@ -56,6 +56,7 @@ struct _MtData {
     guint        animate_cursor : 1;
 
     /* state flags */
+    guint        left_handed           : 1;
     guint        dwell_drag_started    : 1;
     guint        dwell_gesture_started : 1;
     guint        override_cursor       : 1;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]