[mousetweaks/gnome-2-26] Fix synthetic clicks for left-handed mouse orientation - bgo#582319



commit 6e1160e9f8d9d4d90372210ff58d0b4e59d545bf
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Fri May 15 20:00:44 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 cf1e193..519800c 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 fef5954..f3d2022 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 (MTClosure *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 (MTClosure *mt,
 			       guint      button,
 			       gint       type,
 			       gulong     delay)
 {
+    button = mt_main_check_mouse_orientation (mt, button);
+
     gdk_error_trap_push ();
     switch (type) {
 	case PRESS:
@@ -657,6 +671,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
@@ -685,6 +703,9 @@ get_gconf_options (MTClosure *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
@@ -760,6 +781,8 @@ mt_closure_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 5722af2..8f3414c 100644
--- a/src/mt-main.h
+++ b/src/mt-main.h
@@ -42,6 +42,7 @@ struct _MTClosure {
     Display *xtst_display;
     gint     n_screens;
 
+    gboolean left_handed;
     gboolean dwell_drag_started;
     gboolean dwell_gesture_started;
     gboolean override_cursor;



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