From bab240bdfe0688c3236ab6474f6dfb10b4a268c3 Mon Sep 17 00:00:00 2001 From: Nick Schermer Date: Mon, 29 Jul 2013 18:59:38 +0200 Subject: Tasklist: Make middle-click action configurable. Allow the set different actions to middle-click: Nothing: Nothing happens. Close Window: Do i have to explain? Minimize Window: Only minimize the window, this also means button-1 events never minimize, only activate. So you never get lost in minimized windows anymore. --- plugins/tasklist/tasklist-dialog.glade | 293 +++++++++++++++++++++++---------- plugins/tasklist/tasklist-widget.c | 71 ++++---- plugins/tasklist/tasklist-widget.h | 12 ++ plugins/tasklist/tasklist.c | 4 +- 4 files changed, 261 insertions(+), 119 deletions(-) diff --git a/plugins/tasklist/tasklist-dialog.glade b/plugins/tasklist/tasklist-dialog.glade index 8fa64c45..ec57311b 100644 --- a/plugins/tasklist/tasklist-dialog.glade +++ b/plugins/tasklist/tasklist-dialog.glade @@ -1,41 +1,129 @@ - + - + + + + + + + + + Never + + + Always + + + When space is limited + + + + + + + + + + + Timestamp + + + Group title and timestamp + + + Window title + + + Group title and window title + + + None, allow drag-and-drop + + + + False Window Buttons gtk-properties normal True - vertical + False 2 + + + True + False + end + + + gtk-close + False + True + True + True + True + + + False + False + 0 + + + + + gtk-help + False + True + True + True + True + + + False + False + 1 + True + + + + + False + True + end + 0 + + True + False 6 - vertical 6 True + False 0 none True + False 12 True + False 6 - vertical 6 Show button _labels + False True True False @@ -43,12 +131,15 @@ True + True + True 0 Show _flat buttons + False True True False @@ -56,12 +147,15 @@ True + True + True 1 Show _handle + False True True False @@ -69,28 +163,34 @@ True + True + True 2 True + False 12 True + False Sorting _order: True sort-order False + True 0 True + False sort-order-model @@ -101,11 +201,14 @@ False + True 1 + True + True 3 @@ -116,6 +219,7 @@ True + False Appearance @@ -125,31 +229,36 @@ False + True 0 True + False 0 none True + False 12 True + False 6 - vertical 6 True + False 12 True + False 0 Window _grouping: True @@ -157,12 +266,14 @@ False + True 0 True + False grouping-model @@ -173,30 +284,66 @@ False + True 1 + True + True 0 - - Restore minimized windows to current _workspace + True - True - False - True - True + False + 12 + + + True + False + 0 + Mi_ddle click action: + True + middle-click + + + False + True + 0 + + + + + True + False + middle-click-model + + + + 0 + + + + + False + True + 1 + + + True + True 1 - - D_raw window frame when hovering a button + + Restore minimized windows to current _workspace + False True True False @@ -204,12 +351,15 @@ True + True + True 2 - - _Switch windows using the mouse wheel + + D_raw window frame when hovering a button + False True True False @@ -217,12 +367,15 @@ True + True + True 3 - - _Close windows using middle mouse button + + _Switch windows using the mouse wheel + False True True False @@ -230,6 +383,8 @@ True + True + True 4 @@ -240,6 +395,7 @@ True + False Behaviour @@ -249,27 +405,31 @@ False + True 1 True + False 0 none True + False 12 True + False 6 - vertical 6 Show windows from _all workspaces or viewports + False True True False @@ -277,12 +437,15 @@ True + True + True 0 - - Show only _minimized windows + + Show windows from all mo_nitors + False True True False @@ -290,12 +453,15 @@ True + True + True 1 - - Show windows from all mo_nitors + + Show only _minimized windows + False True True False @@ -303,6 +469,8 @@ True + True + True 1 @@ -313,6 +481,7 @@ True + False Filtering @@ -321,55 +490,18 @@ + True + True 2 False + True 1 - - - True - end - - - gtk-close - True - True - True - True - - - False - False - 0 - - - - - gtk-help - True - True - True - True - - - False - False - 1 - True - - - - - False - end - 0 - - @@ -377,44 +509,27 @@ help-button - + - Never + Nothing - Always + Close Window - When space is limited + Minimize Window - - - - - - - - Timestamp - - - Group title and timestamp - - - Window title - - - Group title and window title - - - None, allow drag-and-drop - - + + + + + diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c index d818e0a6..9d35d854 100644 --- a/plugins/tasklist/tasklist-widget.c +++ b/plugins/tasklist/tasklist-widget.c @@ -96,7 +96,7 @@ enum PROP_SORT_ORDER, PROP_WINDOW_SCROLLING, PROP_INCLUDE_ALL_BLINKING, - PROP_MIDDLE_BUTTON_CLOSE + PROP_MIDDLE_CLICK }; struct _XfceTasklistClass @@ -161,8 +161,8 @@ struct _XfceTasklist * or only the active workspace */ guint all_blinking : 1; - /* close window with the mouse middle button */ - guint middle_button_close : 1; + /* action to preform when middle clicking */ + XfceTasklistMClick middle_click; /* whether we only show windows that are in the geometry of * the monitor the tasklist is on */ @@ -477,11 +477,13 @@ xfce_tasklist_class_init (XfceTasklistClass *klass) EXO_PARAM_READWRITE)); g_object_class_install_property (gobject_class, - PROP_MIDDLE_BUTTON_CLOSE, - g_param_spec_boolean ("middle-button-close", - NULL, NULL, - FALSE, - EXO_PARAM_READWRITE)); + PROP_MIDDLE_CLICK, + g_param_spec_uint ("middle-click", + NULL, NULL, + XFCE_TASKLIST_MIDDLE_CLICK_MIN, + XFCE_TASKLIST_MIDDLE_CLICK_MAX, + XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT, + EXO_PARAM_READWRITE)); gtk_widget_class_install_style_property (gtkwidget_class, g_param_spec_int ("max-button-length", @@ -560,7 +562,7 @@ xfce_tasklist_init (XfceTasklist *tasklist) tasklist->all_monitors = TRUE; tasklist->window_scrolling = TRUE; tasklist->all_blinking = TRUE; - tasklist->middle_button_close = FALSE; + tasklist->middle_click = XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT; xfce_tasklist_geometry_set_invalid (tasklist); #ifdef GDK_WINDOWING_X11 tasklist->wireframe_window = 0; @@ -651,8 +653,8 @@ xfce_tasklist_get_property (GObject *object, g_value_set_boolean (value, tasklist->all_blinking); break; - case PROP_MIDDLE_BUTTON_CLOSE: - g_value_set_boolean (value, tasklist->middle_button_close); + case PROP_MIDDLE_CLICK: + g_value_set_uint (value, tasklist->middle_click); break; default: @@ -729,8 +731,8 @@ xfce_tasklist_set_property (GObject *object, tasklist->all_blinking = g_value_get_boolean (value); break; - case PROP_MIDDLE_BUTTON_CLOSE: - tasklist->middle_button_close = g_value_get_boolean (value); + case PROP_MIDDLE_CLICK: + tasklist->middle_click= g_value_get_uint (value); break; default: @@ -2728,25 +2730,35 @@ xfce_tasklist_button_button_release_event (GtkWidget *button, /* only respond to in-button events */ if (event->type == GDK_BUTTON_RELEASE && !xfce_taskbar_is_locked (child->tasklist) - && event->button == 1 && !(event->x == 0 && event->y == 0) /* 0,0 = outside the widget in Gtk */ && event->x >= 0 && event->x < button->allocation.width && event->y >= 0 && event->y < button->allocation.height) { - xfce_tasklist_button_activate (child, event->time); - } + if (event->button == 1) + { + /* press the button */ + xfce_tasklist_button_activate (child, event->time); - /* close the window on middle mouse button */ - if (event->type == GDK_BUTTON_RELEASE - && !xfce_taskbar_is_locked (child->tasklist) - && event->button == 2 - && child->tasklist->middle_button_close - && !(event->x == 0 && event->y == 0) /* 0,0 = outside the widget in Gtk */ - && event->x >= 0 && event->x < button->allocation.width - && event->y >= 0 && event->y < button->allocation.height) - { - wnck_window_close (child->window, event->time); - return TRUE; + /* if the window is still active, don't toggle the button */ + return wnck_window_is_active (child->window); + } + else if (event->button == 2) + { + switch (child->tasklist->middle_click) + { + case XFCE_TASKLIST_MIDDLE_CLICK_NOTHING: + break; + + case XFCE_TASKLIST_MIDDLE_CLICK_CLOSE_WINDOW: + wnck_window_close (child->window, event->time); + return TRUE; + + case XFCE_TASKLIST_MIDDLE_CLICK_MINIMIZE_WINDOW: + if (!wnck_window_is_minimized (child->window)) + wnck_window_minimize (child->window); + return FALSE; + } + } } return FALSE; @@ -2844,7 +2856,10 @@ xfce_tasklist_button_activate (XfceTasklistChild *child, if (wnck_window_is_active (child->window) || wnck_window_transient_is_most_recently_activated (child->window)) { - wnck_window_minimize (child->window); + /* minimize does not work when this is assigned to the + * middle mouse button */ + if (child->tasklist->middle_click != XFCE_TASKLIST_MIDDLE_CLICK_MINIMIZE_WINDOW) + wnck_window_minimize (child->window); } else { diff --git a/plugins/tasklist/tasklist-widget.h b/plugins/tasklist/tasklist-widget.h index 5b4fc015..d3321c82 100644 --- a/plugins/tasklist/tasklist-widget.h +++ b/plugins/tasklist/tasklist-widget.h @@ -27,6 +27,7 @@ typedef struct _XfceTasklistClass XfceTasklistClass; typedef struct _XfceTasklist XfceTasklist; typedef enum _XfceTasklistGrouping XfceTasklistGrouping; typedef enum _XfceTasklistSortOrder XfceTasklistSortOrder; +typedef enum _XfceTasklistMClick XfceTasklistMClick; #define XFCE_TYPE_TASKLIST (xfce_tasklist_get_type ()) #define XFCE_TASKLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_TASKLIST, XfceTasklist)) @@ -61,6 +62,17 @@ enum _XfceTasklistSortOrder XFCE_TASKLIST_SORT_ORDER_DEFAULT = XFCE_TASKLIST_SORT_ORDER_GROUP_TIMESTAMP }; +enum _XfceTasklistMClick +{ + XFCE_TASKLIST_MIDDLE_CLICK_NOTHING, /* do nothing */ + XFCE_TASKLIST_MIDDLE_CLICK_CLOSE_WINDOW, /* close the window */ + XFCE_TASKLIST_MIDDLE_CLICK_MINIMIZE_WINDOW, /* minimize, never minimize with button 1 */ + + XFCE_TASKLIST_MIDDLE_CLICK_MIN = XFCE_TASKLIST_MIDDLE_CLICK_NOTHING, + XFCE_TASKLIST_MIDDLE_CLICK_MAX = XFCE_TASKLIST_MIDDLE_CLICK_MINIMIZE_WINDOW, + XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT = XFCE_TASKLIST_MIDDLE_CLICK_NOTHING +}; + GType xfce_tasklist_get_type (void) G_GNUC_CONST; diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c index b705c4db..49ab8945 100644 --- a/plugins/tasklist/tasklist.c +++ b/plugins/tasklist/tasklist.c @@ -141,7 +141,7 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin) { "sort-order", G_TYPE_UINT }, { "window-scrolling", G_TYPE_BOOLEAN }, { "include-all-blinking", G_TYPE_BOOLEAN }, - { "middle-button-close", G_TYPE_BOOLEAN }, + { "middle-click", G_TYPE_UINT }, { NULL } }; @@ -254,7 +254,7 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin) TASKLIST_DIALOG_BIND ("show-handle", "active") TASKLIST_DIALOG_BIND ("sort-order", "active") TASKLIST_DIALOG_BIND ("window-scrolling", "active") - TASKLIST_DIALOG_BIND ("middle-button-close", "active") + TASKLIST_DIALOG_BIND ("middle-click", "active") #ifndef GDK_WINDOWING_X11 /* not functional in x11, so avoid confusion */ -- cgit v1.2.3