[gnome-panel] panel, libpanel-applet: Correctly test for modifier keys
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] panel, libpanel-applet: Correctly test for modifier keys
- Date: Mon, 23 May 2011 21:45:32 +0000 (UTC)
commit 3ce3e099ef72627ff6c09681749edf419c13d1d5
Author: Vincent Untz <vuntz gnome org>
Date: Wed Apr 13 15:30:16 2011 +0200
panel, libpanel-applet: Correctly test for modifier keys
Using Alt to edit the panels doesn't always work; this is likely because
we were not using gtk_accelerator_get_default_mod_mask() to test the
modifier key.
Note that we double-check that the metacity modifier is in the mask
returned by gtk_accelerator_get_default_mod_mask(), to make sure it
always work -- if it's not there, we default to MOD1.
https://bugzilla.gnome.org/show_bug.cgi?id=649971
gnome-panel/applet.c | 2 +-
gnome-panel/panel-applet-frame.c | 2 +-
gnome-panel/panel-bindings.c | 9 ++++++++-
gnome-panel/panel-toplevel.c | 5 ++++-
gnome-panel/panel-util.c | 7 +++++--
gnome-panel/panel-widget.c | 2 +-
gnome-panel/panel.c | 2 +-
libpanel-applet/panel-applet-bindings.c | 16 +++++++++++++---
libpanel-applet/panel-applet.c | 2 +-
9 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index 11d9e4e..38338b7 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -685,7 +685,7 @@ applet_button_press (GtkWidget *widget,
if (applet_must_skip_menu (info))
return FALSE;
- modifiers = event->state & GDK_MODIFIER_MASK;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
if (modifiers == panel_bindings_get_mouse_button_modifier_keymask ())
applet_show_menu (info, panel_applet_get_edit_menu (info), FALSE, event);
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 0e9877a..025fe20 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -360,7 +360,7 @@ panel_applet_frame_button_changed (GtkWidget *widget,
if (event->window != gtk_widget_get_window (widget))
return FALSE;
- modifiers = event->state & GDK_MODIFIER_MASK;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
switch (event->button) {
case 1:
diff --git a/gnome-panel/panel-bindings.c b/gnome-panel/panel-bindings.c
index e9f1030..3bf3b97 100644
--- a/gnome-panel/panel-bindings.c
+++ b/gnome-panel/panel-bindings.c
@@ -297,10 +297,17 @@ panel_bindings_set_entries (GtkBindingSet *binding_set)
guint
panel_bindings_get_mouse_button_modifier_keymask (void)
{
+ guint mod;
+
g_assert (mouse_button_modifier_keymask != 0);
if (!initialised)
panel_bindings_initialise ();
- return panel_get_real_modifier_mask (mouse_button_modifier_keymask);
+ mod = panel_get_real_modifier_mask (mouse_button_modifier_keymask);
+
+ if (mod & gtk_accelerator_get_default_mod_mask ())
+ return mod;
+ else
+ return panel_get_real_modifier_mask (DEFAULT_MOUSE_MODIFIER);
}
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index 132373c..2ae7589 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -2942,6 +2942,7 @@ panel_toplevel_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
PanelToplevel *toplevel;
+ guint modifiers;
GtkWidget *event_widget;
g_return_val_if_fail (PANEL_IS_TOPLEVEL (widget), FALSE);
@@ -2954,11 +2955,13 @@ panel_toplevel_button_press_event (GtkWidget *widget,
if (toplevel->priv->animating)
return FALSE;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
+
/* Get the mouse-button modifier from metacity so that only intentional
* moves are considered. We don't this for non-expanded panels since we
* only have the handles that the user can grab. */
if (toplevel->priv->expand &&
- (event->state & GDK_MODIFIER_MASK) != panel_bindings_get_mouse_button_modifier_keymask ())
+ modifiers != panel_bindings_get_mouse_button_modifier_keymask ())
return FALSE;
gdk_window_get_user_data (event->window, (gpointer)&event_widget);
diff --git a/gnome-panel/panel-util.c b/gnome-panel/panel-util.c
index 4c0a3e6..8877ef1 100644
--- a/gnome-panel/panel-util.c
+++ b/gnome-panel/panel-util.c
@@ -1117,9 +1117,12 @@ panel_util_key_event_is_binding (GdkEventKey *event,
GtkBindingEntry *binding_entry;
gboolean popup = FALSE;
gboolean popup_modifier = FALSE;
+ guint modifiers;
char *signal_dash;
char *signal_underscore;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
+
signal_dash = g_strdup (signal_name);
g_strdelimit (signal_dash, "_", '-');
signal_underscore = g_strdup (signal_name);
@@ -1140,8 +1143,8 @@ panel_util_key_event_is_binding (GdkEventKey *event,
if (binding_entry->keyval != event->keyval)
break;
- popup = (event->state & GDK_MODIFIER_MASK) == binding_entry->modifiers;
- popup_modifier = (event->state & GDK_MODIFIER_MASK) == (panel_bindings_get_mouse_button_modifier_keymask ()|binding_entry->modifiers);
+ popup = modifiers == binding_entry->modifiers;
+ popup_modifier = modifiers == (panel_bindings_get_mouse_button_modifier_keymask ()|binding_entry->modifiers);
break;
}
}
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index 8d375b9..a18fed0 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -2138,7 +2138,7 @@ panel_widget_applet_button_press_event (GtkWidget *widget,
return TRUE;
}
- modifiers = event->state & GDK_MODIFIER_MASK;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
/* Begin drag if the middle mouse button and modifier are pressed,
* unless the panel is locked down or a grab is active (meaning a menu
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index 8874fe6..f3a4e91 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -363,7 +363,7 @@ panel_button_press_event (PanelToplevel *toplevel,
if (event->button != 3)
return FALSE;
- modifiers = event->state & GDK_MODIFIER_MASK;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
if (modifiers == panel_bindings_get_mouse_button_modifier_keymask ())
return panel_popup_menu (toplevel, event->button, event->time);
diff --git a/libpanel-applet/panel-applet-bindings.c b/libpanel-applet/panel-applet-bindings.c
index 8562fba..8f70392 100644
--- a/libpanel-applet/panel-applet-bindings.c
+++ b/libpanel-applet/panel-applet-bindings.c
@@ -237,10 +237,17 @@ panel_applet_bindings_init (GConfClient *client)
guint
panel_applet_bindings_get_mouse_button_modifier_keymask (void)
{
+ guint mod;
+
g_assert (initialised != 0);
g_assert (mouse_button_modifier_keymask != 0);
- return panel_applet_bindings_get_real_modifier_mask (mouse_button_modifier_keymask);
+ mod = panel_applet_bindings_get_real_modifier_mask (mouse_button_modifier_keymask);
+
+ if (mod & gtk_accelerator_get_default_mod_mask ())
+ return mod;
+ else
+ return panel_applet_bindings_get_real_modifier_mask (DEFAULT_MOUSE_MODIFIER);
}
/****************************\
@@ -258,9 +265,12 @@ panel_applet_bindings_key_event_is_binding (GdkEventKey *event,
GtkBindingEntry *binding_entry;
gboolean popup = FALSE;
gboolean popup_modifier = FALSE;
+ guint modifiers;
char *signal_dash;
char *signal_underscore;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
+
signal_dash = g_strdup (signal_name);
g_strdelimit (signal_dash, "_", '-');
signal_underscore = g_strdup (signal_name);
@@ -281,8 +291,8 @@ panel_applet_bindings_key_event_is_binding (GdkEventKey *event,
if (binding_entry->keyval != event->keyval)
break;
- popup = (event->state & GDK_MODIFIER_MASK) == binding_entry->modifiers;
- popup_modifier = (event->state & GDK_MODIFIER_MASK) == (panel_applet_bindings_get_mouse_button_modifier_keymask ()|binding_entry->modifiers);
+ popup = modifiers == binding_entry->modifiers;
+ popup_modifier = modifiers == (panel_applet_bindings_get_mouse_button_modifier_keymask ()|binding_entry->modifiers);
break;
}
}
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index 650e170..da56a9c 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -1266,7 +1266,7 @@ panel_applet_button_press (GtkWidget *widget,
if (event->button == 3) {
guint modifiers;
- modifiers = event->state & GDK_MODIFIER_MASK;
+ modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
if (modifiers == panel_applet_bindings_get_mouse_button_modifier_keymask ())
panel_applet_edit_menu_popup (applet, event->button, event->time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]