[mousetweaks] Add support for middle mouse button dwell-clicks



commit 4cab918f8b2b9dfb47fa64ccd91e654d04ee9f59
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Sun Feb 19 08:39:02 2012 +0100

    Add support for middle mouse button dwell-clicks

 src/mt-common.h |    5 ++---
 src/mt-ctw.c    |   12 +++++++++---
 src/mt-main.c   |   10 ++++++----
 3 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/mt-common.h b/src/mt-common.h
index 36bf2c8..c7cafe8 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -54,14 +54,13 @@ G_BEGIN_DECLS
 #define KEY_SSC_TIME                "secondary-click-time"
 #define KEY_CTW_VISIBLE             "click-type-window-visible"
 
-#define N_CLICK_TYPES 4
-
 typedef enum
 {
     MT_DWELL_CLICK_TYPE_RIGHT,
     MT_DWELL_CLICK_TYPE_DRAG,
     MT_DWELL_CLICK_TYPE_DOUBLE,
-    MT_DWELL_CLICK_TYPE_SINGLE
+    MT_DWELL_CLICK_TYPE_SINGLE,
+    MT_DWELL_CLICK_TYPE_MIDDLE
 } MtDwellClickType;
 
 typedef enum
diff --git a/src/mt-ctw.c b/src/mt-ctw.c
index 119d808..4f13454 100644
--- a/src/mt-ctw.c
+++ b/src/mt-ctw.c
@@ -32,9 +32,15 @@ service_click_type_changed (MtService *service, GParamSpec *pspec)
 {
     GSList *group;
     GtkWidget *button;
+    MtDwellClickType ct;
+
+    ct = mt_service_get_click_type (service);
+
+    if (ct == MT_DWELL_CLICK_TYPE_MIDDLE)
+        return;
 
     group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (O ("single")));
-    button = g_slist_nth_data (group, mt_service_get_click_type (service));
+    button = g_slist_nth_data (group, ct);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
     gtk_widget_grab_focus (button);
 }
@@ -61,7 +67,7 @@ ctw_style_changed (MtSettings *ms, GParamSpec *pspec)
     const gchar *icon_names[] = { "single_i", "double_i", "drag_i", "right_i" };
     gint i;
 
-    for (i = 0; i < N_CLICK_TYPES; i++)
+    for (i = 0; i < 4; i++)
     {
         label = W (label_names[i]);
         icon = W (icon_names[i]);
@@ -225,7 +231,7 @@ mt_ctw_init (void)
     gtk_window_set_keep_above (GTK_WINDOW (ctw), TRUE);
 
     /* init buttons */
-    for (i = 0; i < N_CLICK_TYPES; i++)
+    for (i = 0; i < 4; i++)
     {
         obj = O (button_names[i]);
         gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (obj), FALSE);
diff --git a/src/mt-main.c b/src/mt-main.c
index 8ed82d7..b3e1b78 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -165,10 +165,10 @@ mt_main_do_dwell_click (MtData *mt)
     switch (click_type)
     {
         case MT_DWELL_CLICK_TYPE_SINGLE:
-            mt_main_generate_button_event (mt, 1, CLICK, 60);
+            mt_main_generate_button_event (mt, 1, CLICK, 80);
             break;
         case MT_DWELL_CLICK_TYPE_DOUBLE:
-            mt_main_generate_button_event (mt, 1, DOUBLE_CLICK, 10);
+            mt_main_generate_button_event (mt, 1, DOUBLE_CLICK, 40);
             mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
             break;
         case MT_DWELL_CLICK_TYPE_DRAG:
@@ -183,14 +183,16 @@ mt_main_do_dwell_click (MtData *mt)
                 mt_main_generate_button_event (mt, 1, RELEASE, CurrentTime);
                 mt_main_set_cursor (mt, GDK_LEFT_PTR);
                 mt->dwell_drag_started = FALSE;
-
                 mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
             }
             break;
         case MT_DWELL_CLICK_TYPE_RIGHT:
-            mt_main_generate_button_event (mt, 3, CLICK, 10);
+            mt_main_generate_button_event (mt, 3, CLICK, 80);
             mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
             break;
+        case MT_DWELL_CLICK_TYPE_MIDDLE:
+            mt_main_generate_button_event (mt, 2, CLICK, 80);
+            mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
         default:
             g_warning ("Unknown click-type.");
             break;



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