! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Shortcut editor doesn't accept several modifiers
Status:
CLOSED: FIXED

Comments

Description Benedikt Meurer editbugs 2004-10-08 10:09:04 CEST
The shortcut editor doesn't accept modifiers like Super_L, Super_R and some Meta
keys. Why not use the Gdk functions to translate the keys instead of doing by
hand? E.g. heres what I use with Terminal:

static gboolean
is_modifier (guint keycode)
{
  XModifierKeymap *keymap;
  gboolean         result = FALSE;
  gint             n;

  keymap = XGetModifierMapping (gdk_display);
  for (n = 0; n < keymap->max_keypermod * 8; ++n)
    if (keycode == keymap->modifiermap[n])
      {
        result = TRUE;
        break;
      }

  XFreeModifiermap (keymap);

  return result;
}

static gboolean
terminal_shortcut_editor_compose (GtkWidget              *dialog,
                                  GdkEventKey            *event,
                                  TerminalShortcutEditor *editor)
{
  GdkModifierType consumed_modifiers = 0;
  guint           keyval;
  gchar          *accelerator;
  gchar          *property;

  if (is_modifier (event->hardware_keycode))
    return TRUE;

  gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
                                       event->hardware_keycode,
                                       event->state,
                                       event->group,
                                       NULL, NULL, NULL,
                                       &consumed_modifiers);

  keyval = gdk_keyval_to_lower (event->keyval);
  if (keyval == GDK_ISO_Left_Tab)
    keyval = GDK_Tab;

  if (keyval != event->keyval && (consumed_modifiers & GDK_SHIFT_MASK))
    consumed_modifiers &= ~GDK_SHIFT_MASK;

  accelerator = gtk_accelerator_name (keyval, event->state & ~consumed_modifiers);
  property = g_object_get_data (G_OBJECT (dialog), "property-name");
  g_object_set (G_OBJECT (editor->preferences), property, accelerator, NULL);
  g_free (accelerator);

  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

  return TRUE;
}

This would also fix the modifier problem I reported earlier.
Comment 1 Jean-François Wauthy editbugs 2004-10-08 16:41:02 CEST
should be fixed in CVS, can you try it benny ?

Bug #378

Reported by:
Benedikt Meurer
Reported on: 2004-10-08
Last modified on: 2009-07-14

People

Assignee:
Jean-François Wauthy
CC List:
0 users

Version

Version:
unspecified

Attachments

Additional information