diff options
author | Brian J. Tarricone <bjt23@cornell.edu> | 2008-08-30 23:25:26 -0700 |
---|---|---|
committer | Brian J. Tarricone <brian@tarricone.org> | 2009-08-13 19:33:25 -0700 |
commit | 4c8f55b63a6c50f7dca88754ce7507f569186b8a (patch) | |
tree | 2e2540fb6fa25cb6ead32cc6dfcc35ee5e2f2ab5 | |
parent | eebe64cc5ea7f56c18007ace69c71cbeecb1b079 (diff) | |
download | xfdesktop-menu-diff-button.tar.gz |
first attempt at changing mouse button for menus, with modifiers; has issuesmenu-diff-button
-rw-r--r-- | settings/main.c | 26 | ||||
-rw-r--r-- | settings/xfdesktop-settings.glade | 23 | ||||
-rw-r--r-- | src/xfce-desktop.c | 128 | ||||
-rw-r--r-- | src/xfce-desktop.h | 16 |
4 files changed, 175 insertions, 18 deletions
diff --git a/settings/main.c b/settings/main.c index 9bc5d6e5..d75b46a5 100644 --- a/settings/main.c +++ b/settings/main.c @@ -59,8 +59,12 @@ #define SHOW_DESKTOP_MENU_PROP "/desktop-menu/show" #define DESKTOP_MENU_SHOW_ICONS_PROP "/desktop-menu/show-icons" +#define DESKTOP_MENU_BUTTON_PROP "/desktop-menu/activate-button" +#define DESKTOP_MENU_MODIFIER_PROP "/desktop-menu/activate-modifier" + #define WINLIST_SHOW_WINDOWS_MENU_PROP "/windowlist-menu/show" -#define WINLIST_SHOW_APP_ICONS_PROP "/windowlist-menu/show-icons" +#define WINLIST_BUTTON_PROP "/windowlist-menu/activate-button" +#define WINLIST_MODIFIER_PROP "/windowlist-menu/activate-modifier" #define WINLIST_SHOW_STICKY_WIN_ONCE_PROP "/windowlist-menu/show-sticky-once" #define WINLIST_SHOW_WS_NAMES_PROP "/windowlist-menu/show-workspace-names" #define WINLIST_SHOW_WS_SUBMENUS_PROP "/windowlist-menu/show-submenus" @@ -1420,11 +1424,31 @@ xfdesktop_settings_dialog_new(GladeXML *main_gxml, G_CALLBACK(suboptions_set_sensitive), box); suboptions_set_sensitive(GTK_TOGGLE_BUTTON(w), box); + w = glade_xml_get_widget(main_gxml, "combo_menu_btn"); + gtk_combo_box_set_active(GTK_COMBO_BOX(w), 2); + xfconf_g_property_bind(channel, DESKTOP_MENU_BUTTON_PROP, G_TYPE_INT, + G_OBJECT(w), "active"); + + w = glade_xml_get_widget(main_gxml, "combo_menu_modifier"); + gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); + xfconf_g_property_bind(channel, DESKTOP_MENU_MODIFIER_PROP, G_TYPE_INT, + G_OBJECT(w), "active"); + xfconf_g_property_bind(channel, WINLIST_SHOW_APP_ICONS_PROP, G_TYPE_BOOLEAN, G_OBJECT(glade_xml_get_widget(main_gxml, "chk_winlist_show_app_icons")), "active"); + w = glade_xml_get_widget(main_gxml, "combo_windowlist_btn"); + gtk_combo_box_set_active(GTK_COMBO_BOX(w), 1); + xfconf_g_property_bind(channel, WINLIST_BUTTON_PROP, G_TYPE_INT, + G_OBJECT(w), "active"); + + w = glade_xml_get_widget(main_gxml, "combo_windowlist_modifier"); + gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); + xfconf_g_property_bind(channel, WINLIST_MODIFIER_PROP, G_TYPE_INT, + G_OBJECT(w), "active"); + xfconf_g_property_bind(channel, WINLIST_SHOW_STICKY_WIN_ONCE_PROP, G_TYPE_BOOLEAN, G_OBJECT(glade_xml_get_widget(main_gxml, diff --git a/settings/xfdesktop-settings.glade b/settings/xfdesktop-settings.glade index 021f73f4..024f4fbb 100644 --- a/settings/xfdesktop-settings.glade +++ b/settings/xfdesktop-settings.glade @@ -594,14 +594,14 @@ Transparent</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">_Button:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">combobox1</property> + <property name="mnemonic_widget">combo_menu_btn</property> </widget> <packing> <property name="expand">False</property> </packing> </child> <child> - <widget class="GtkComboBox" id="combobox1"> + <widget class="GtkComboBox" id="combo_menu_btn"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="items" translatable="yes">Left @@ -619,7 +619,7 @@ Right</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Mo_difier:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">combobox2</property> + <property name="mnemonic_widget">combo_menu_modifier</property> </widget> <packing> <property name="expand">False</property> @@ -627,13 +627,14 @@ Right</property> </packing> </child> <child> - <widget class="GtkComboBox" id="combobox2"> + <widget class="GtkComboBox" id="combo_menu_modifier"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="items" translatable="yes">None Shift Alt -Control</property> +Control +Super</property> </widget> <packing> <property name="expand">False</property> @@ -749,6 +750,7 @@ Control</property> <property name="spacing">6</property> <child> <widget class="GtkHBox" id="hbox14"> + <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="spacing">12</property> <child> @@ -757,14 +759,14 @@ Control</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">B_utton:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">combobox8</property> + <property name="mnemonic_widget">combo_windowlist_btn</property> </widget> <packing> <property name="expand">False</property> </packing> </child> <child> - <widget class="GtkComboBox" id="combobox8"> + <widget class="GtkComboBox" id="combo_windowlist_btn"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="items" translatable="yes">Left @@ -782,7 +784,7 @@ Right</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="label" translatable="yes">Modi_fier:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">combobox9</property> + <property name="mnemonic_widget">combo_windowlist_modifier</property> </widget> <packing> <property name="expand">False</property> @@ -790,13 +792,14 @@ Right</property> </packing> </child> <child> - <widget class="GtkComboBox" id="combobox9"> + <widget class="GtkComboBox" id="combo_windowlist_modifier"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="items" translatable="yes">None Shift Alt -Control</property> +Control +Super</property> </widget> <packing> <property name="expand">False</property> diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c index 1bc7727e..d6a5617c 100644 --- a/src/xfce-desktop.c +++ b/src/xfce-desktop.c @@ -89,6 +89,11 @@ struct _XfceDesktopPriv XfconfChannel *channel; gchar *property_prefix; + + XfceDesktopButton menu_button; + XfceDesktopModifier menu_modifier; + XfceDesktopButton secondary_menu_button; + XfceDesktopModifier secondary_menu_modifier; GdkPixmap *bg_pixmap; @@ -120,6 +125,10 @@ enum { PROP_0 = 0, PROP_XINERAMA_STRETCH, + PROP_MENU_BUTTON, + PROP_MENU_MODIFIER, + PROP_SECONDARY_MENU_BUTTON, + PROP_SECONDARY_MENU_MODIFIER, #ifdef ENABLE_DESKTOP_ICONS PROP_ICON_STYLE, PROP_ICON_SIZE, @@ -574,6 +583,36 @@ xfce_desktop_class_init(XfceDesktopClass *klass) FALSE, XFDESKTOP_PARAM_FLAGS)); + g_object_class_install_property(gobject_class, PROP_MENU_BUTTON, + g_param_spec_enum("menu-button", + "menu button", + "menu button", + XFCE_TYPE_DESKTOP_BUTTON, + XFCE_DESKTOP_BUTTON_RIGHT, + XFDESKTOP_PARAM_FLAGS)); + g_object_class_install_property(gobject_class, PROP_MENU_MODIFIER, + g_param_spec_enum("menu-modifier", + "menu modifier", + "menu modifier", + XFCE_TYPE_DESKTOP_MODIFIER, + 0, + XFDESKTOP_PARAM_FLAGS)); + + g_object_class_install_property(gobject_class, PROP_SECONDARY_MENU_BUTTON, + g_param_spec_enum("secondary-menu-button", + "secondary menu button", + "secondary menu button", + XFCE_TYPE_DESKTOP_BUTTON, + XFCE_DESKTOP_BUTTON_MIDDLE, + XFDESKTOP_PARAM_FLAGS)); + g_object_class_install_property(gobject_class, PROP_SECONDARY_MENU_MODIFIER, + g_param_spec_enum("secondary-menu-modifier", + "secondary menu modifier", + "secondary menu modifier", + XFCE_TYPE_DESKTOP_MODIFIER, + 0, + XFDESKTOP_PARAM_FLAGS)); + #ifdef ENABLE_DESKTOP_ICONS g_object_class_install_property(gobject_class, PROP_ICON_STYLE, g_param_spec_enum("icon-style", @@ -647,6 +686,22 @@ xfce_desktop_set_property(GObject *object, g_value_get_boolean(value)); break; + case PROP_MENU_BUTTON: + desktop->priv->menu_button = g_value_get_enum(value); + break; + + case PROP_MENU_MODIFIER: + desktop->priv->menu_modifier = g_value_get_enum(value); + break; + + case PROP_SECONDARY_MENU_BUTTON: + desktop->priv->secondary_menu_button = g_value_get_enum(value); + break; + + case PROP_SECONDARY_MENU_MODIFIER: + desktop->priv->secondary_menu_modifier = g_value_get_enum(value); + break; + #ifdef ENABLE_DESKTOP_ICONS case PROP_ICON_STYLE: xfce_desktop_set_icon_style(desktop, @@ -688,6 +743,22 @@ xfce_desktop_get_property(GObject *object, g_value_set_boolean(value, desktop->priv->xinerama_stretch); break; + case PROP_MENU_BUTTON: + g_value_set_enum(value, desktop->priv->menu_button); + break; + + case PROP_MENU_MODIFIER: + g_value_set_enum(value, desktop->priv->menu_modifier); + break; + + case PROP_SECONDARY_MENU_BUTTON: + g_value_set_enum(value, desktop->priv->secondary_menu_button); + break; + + case PROP_SECONDARY_MENU_MODIFIER: + g_value_set_enum(value, desktop->priv->secondary_menu_modifier); + break; + #ifdef ENABLE_DESKTOP_ICONS case PROP_ICON_STYLE: g_value_set_enum(value, desktop->priv->icons_style); @@ -845,28 +916,57 @@ xfce_desktop_unrealize(GtkWidget *widget) GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED); } +static inline GdkModifierType +enum_to_modmask(XfceDesktopModifier modifier) +{ + switch(modifier) { + case XFCE_DESKTOP_MOD_NONE: + return 0; + case XFCE_DESKTOP_MOD_SHIFT: + return GDK_SHIFT_MASK; + case XFCE_DESKTOP_MOD_ALT: + return GDK_MOD1_MASK|GDK_META_MASK; + case XFCE_DESKTOP_MOD_CONTROL: + return GDK_CONTROL_MASK; + case XFCE_DESKTOP_MOD_SUPER: + return GDK_SUPER_MASK|GDK_MOD4_MASK; + default: + return 0; + } +} + static gboolean xfce_desktop_button_press_event(GtkWidget *w, GdkEventButton *evt) { +#define ALLOWED_MASK (GDK_SHIFT_MASK |GDK_MOD1_MASK | GDK_META_MASK \ + | GDK_CONTROL_MASK | GDK_SUPER_MASK | GDK_MOD4_MASK) + XfceDesktop *desktop = XFCE_DESKTOP(w); guint button = evt->button; - guint state = evt->state; - + GdkModifierType state = (evt->state & ALLOWED_MASK); + GdkModifierType state1 = enum_to_modmask(desktop->priv->menu_modifier); + GdkModifierType state2 = enum_to_modmask(desktop->priv->secondary_menu_modifier); + + DBG("click modmask: 0x%08x", state); if(evt->type == GDK_BUTTON_PRESS) { - if(button == 2 || (button == 1 && (state & GDK_SHIFT_MASK) - && (state & GDK_CONTROL_MASK))) + if(desktop->priv->secondary_menu_button + 1 == button + && !(state & ~state2) && ((state & state2) || (state == state2))) { - xfce_desktop_popup_secondary_root_menu(XFCE_DESKTOP(w), + xfce_desktop_popup_secondary_root_menu(desktop, button, evt->time); return TRUE; - } else if(button == 3 || (button == 1 && (state & GDK_SHIFT_MASK))) { - xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), + } else if(desktop->priv->menu_button + 1 == button + && !(state & ~state1) && ((state & state1) + || (state == state1))) + { + xfce_desktop_popup_root_menu(desktop, button, evt->time); return TRUE; } } return FALSE; +#undef ALLOWED_MASK } static gboolean @@ -951,6 +1051,20 @@ xfce_desktop_connect_settings(XfceDesktop *desktop) xfconf_g_property_bind(channel, buf, G_TYPE_BOOLEAN, G_OBJECT(desktop), "xinerama-stretch"); + xfconf_g_property_bind(channel, "/desktop-menu/activate-button", + G_TYPE_INT, + G_OBJECT(desktop), "menu-button"); + xfconf_g_property_bind(channel, "/desktop-menu/activate-modifier", + G_TYPE_INT, + G_OBJECT(desktop), "menu-modifier"); + + xfconf_g_property_bind(channel, "/windowlist-menu/activate-button", + G_TYPE_INT, + G_OBJECT(desktop), "secondary-menu-button"); + xfconf_g_property_bind(channel, "/windowlist-menu/activate-modifier", + G_TYPE_INT, + G_OBJECT(desktop), "secondary-menu-modifier"); + #ifdef ENABLE_DESKTOP_ICONS #define ICONS_PREFIX "/desktop-icons/" diff --git a/src/xfce-desktop.h b/src/xfce-desktop.h index 8fa80a64..a1ab3fe0 100644 --- a/src/xfce-desktop.h +++ b/src/xfce-desktop.h @@ -48,6 +48,22 @@ typedef enum XFCE_DESKTOP_ICON_STYLE_FILES, } XfceDesktopIconStyle; +typedef enum +{ + XFCE_DESKTOP_BUTTON_LEFT = 0, + XFCE_DESKTOP_BUTTON_MIDDLE, + XFCE_DESKTOP_BUTTON_RIGHT, +} XfceDesktopButton; + +typedef enum +{ + XFCE_DESKTOP_MOD_NONE = 0, + XFCE_DESKTOP_MOD_SHIFT, + XFCE_DESKTOP_MOD_ALT, + XFCE_DESKTOP_MOD_CONTROL, + XFCE_DESKTOP_MOD_SUPER, +} XfceDesktopModifier; + struct _XfceDesktop { GtkWindow window; |