[gimp/metadata-browser] app: make gimp_window_key_press_event() do the right thing on a Mac
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] app: make gimp_window_key_press_event() do the right thing on a Mac
- Date: Wed, 28 Sep 2011 10:47:50 +0000 (UTC)
commit 127dded7084ebfeabb5593efdb89ae29198f79a1
Author: Michael Natterer <mitch gimp org>
Date: Sat Sep 17 23:23:30 2011 +0200
app: make gimp_window_key_press_event() do the right thing on a Mac
which is look at the right modifier when checking if a key event
can invoke an accelerator. Also get the mnemonic modifier from
GTK instead of hardcoding it, and don't check for it if mnemonics
are disabled, which is the right thing to do on all platforms.
app/widgets/gimpwindow.c | 39 ++++++++++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/app/widgets/gimpwindow.c b/app/widgets/gimpwindow.c
index 7ec90b6..eed13a8 100644
--- a/app/widgets/gimpwindow.c
+++ b/app/widgets/gimpwindow.c
@@ -54,9 +54,13 @@ static gboolean
gimp_window_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
- GtkWindow *window = GTK_WINDOW (widget);
- GtkWidget *focus = gtk_window_get_focus (window);
- gboolean handled = FALSE;
+ GtkWindow *window = GTK_WINDOW (widget);
+ GtkWidget *focus = gtk_window_get_focus (window);
+ GdkDisplay *display = gtk_widget_get_display (widget);
+ GdkModifierType state = event->state;
+ GdkModifierType accel_mods;
+ gboolean enable_mnemonics;
+ gboolean handled = FALSE;
/* we're overriding the GtkWindow implementation here to give
* the focus widget precedence over unmodified accelerators
@@ -75,8 +79,29 @@ gimp_window_key_press_event (GtkWidget *widget,
"handled by gtk_window_propagate_key_event(text_widget)");
}
- /* invoke control/alt accelerators */
- if (! handled && event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
+ /* we process raw key events here, and they contain only real
+ * modifiers; call the mapping function in order to get virtual
+ * modifiers added (e.g. META) in case the accel modifier is virtual
+ */
+ gdk_keymap_add_virtual_modifiers (gdk_keymap_get_for_display (display),
+ &state);
+
+ /* FIXME: get this from GTK API */
+#ifndef GDK_WINDOWING_QUARTZ
+ accel_mods = GDK_CONTROL_MASK;
+#else
+ accel_mods = GDK_META_MASK;
+#endif
+
+ g_object_get (gtk_widget_get_settings (widget),
+ "gtk-enable-mnemonics", &enable_mnemonics,
+ NULL);
+
+ if (enable_mnemonics)
+ accel_mods |= gtk_window_get_mnemonic_modifier (window);
+
+ /* invoke modified accelerators */
+ if (! handled && state & accel_mods)
{
handled = gtk_window_activate_key (window, event);
@@ -95,8 +120,8 @@ gimp_window_key_press_event (GtkWidget *widget,
"handled by gtk_window_propagate_key_event(other_widget)");
}
- /* invoke non-(control/alt) accelerators */
- if (! handled && ! (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
+ /* invoke non-modified accelerators */
+ if (! handled && ! (state & accel_mods))
{
handled = gtk_window_activate_key (window, event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]