[gtk+] gtk: use the new modifier API instead of GTK_DEFAULT_ACCEL_MOD_MASK
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk: use the new modifier API instead of GTK_DEFAULT_ACCEL_MOD_MASK
- Date: Fri, 7 Oct 2011 07:34:25 +0000 (UTC)
commit 87cc0dc79fe77c46508e89d677bc52ff12915d9a
Author: Michael Natterer <mitch lanedo com>
Date: Fri Oct 7 09:29:43 2011 +0200
gtk: use the new modifier API instead of GTK_DEFAULT_ACCEL_MOD_MASK
in gtkimcontextsimple and gtktreeview, which are the easy places,
but also true bugfixes, because on OSX we can't use the virtual META
here, we needs MOD2 as delivered in key events.
gtk/gtkimcontextsimple.c | 9 +++++++--
gtk/gtktreeview.c | 10 +++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 7210824..ab721fe 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -628,7 +628,6 @@ check_algorithmically (GtkIMContextSimple *context_simple,
* with Ctrl-Shift-U, then release the modifiers before typing any
* digits, and enter the digits without modifiers.
*/
-#define HEX_MOD_MASK (GTK_DEFAULT_ACCEL_MOD_MASK | GDK_SHIFT_MASK)
static gboolean
check_hex (GtkIMContextSimple *context_simple,
@@ -814,8 +813,10 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
{
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
GtkIMContextSimplePrivate *priv = context_simple->priv;
+ GdkDisplay *display = gdk_window_get_display (event->window);
GSList *tmp_list;
int n_compose = 0;
+ GdkModifierType hex_mod_mask;
gboolean have_hex_mods;
gboolean is_hex_start;
gboolean is_hex_end;
@@ -868,10 +869,14 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
if (event->keyval == gtk_compose_ignore[i])
return FALSE;
+ hex_mod_mask = gdk_keymap_get_modifier_mask (gdk_keymap_get_for_display (display),
+ GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
+ hex_mod_mask |= GDK_SHIFT_MASK;
+
if (priv->in_hex_sequence && priv->modifiers_dropped)
have_hex_mods = TRUE;
else
- have_hex_mods = (event->state & (HEX_MOD_MASK)) == HEX_MOD_MASK;
+ have_hex_mods = (event->state & (hex_mod_mask)) == hex_mod_mask;
is_hex_start = event->keyval == GDK_KEY_U;
is_hex_end = (event->keyval == GDK_KEY_space ||
event->keyval == GDK_KEY_KP_Space ||
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 7c3c0b0..fe5f598 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -15157,7 +15157,8 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
GdkEventKey *event,
GtkTreeView *tree_view)
{
- gboolean retval = FALSE;
+ GdkModifierType default_accel;
+ gboolean retval = FALSE;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (GTK_IS_TREE_VIEW (tree_view), FALSE);
@@ -15174,6 +15175,9 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
return TRUE;
}
+ default_accel = gtk_widget_get_modifier_mask (widget,
+ GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
+
/* select previous matching iter */
if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up)
{
@@ -15183,7 +15187,7 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
retval = TRUE;
}
- if (((event->state & (GTK_DEFAULT_ACCEL_MOD_MASK | GDK_SHIFT_MASK)) == (GTK_DEFAULT_ACCEL_MOD_MASK | GDK_SHIFT_MASK))
+ if (((event->state & (default_accel | GDK_SHIFT_MASK)) == (default_accel | GDK_SHIFT_MASK))
&& (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
{
if (!gtk_tree_view_search_move (widget, tree_view, TRUE))
@@ -15201,7 +15205,7 @@ gtk_tree_view_search_key_press_event (GtkWidget *widget,
retval = TRUE;
}
- if (((event->state & (GTK_DEFAULT_ACCEL_MOD_MASK | GDK_SHIFT_MASK)) == GTK_DEFAULT_ACCEL_MOD_MASK)
+ if (((event->state & (default_accel | GDK_SHIFT_MASK)) == default_accel)
&& (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
{
if (!gtk_tree_view_search_move (widget, tree_view, FALSE))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]