예제 #1
0
DasomEvent *
dasom_event_copy (DasomEvent *event)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  g_return_val_if_fail (event != NULL, NULL);

  DasomEvent *new_event;
  new_event = dasom_event_new (DASOM_EVENT_NOTHING);
  *new_event = *event;

  return new_event;
}
예제 #2
0
static DasomEvent *
translate_gdk_event_key (GdkEventKey *event)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  DasomEvent *dasom_event = dasom_event_new (DASOM_EVENT_NOTHING);

  if (event->type == GDK_KEY_PRESS)
    dasom_event->key.type = DASOM_EVENT_KEY_PRESS;
  else
    dasom_event->key.type = DASOM_EVENT_KEY_RELEASE;

  dasom_event->key.state  = event->state;
  dasom_event->key.keyval = event->keyval;
  dasom_event->key.hardware_keycode = event->hardware_keycode;

  return dasom_event;
}
예제 #3
0
static DasomEvent *
translate_xkey_event (XEvent *xevent)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  GdkKeymap *keymap = gdk_keymap_get_default ();
  GdkModifierType consumed, state;

  DasomEvent *dasom_event = dasom_event_new (DASOM_EVENT_NOTHING);

  if (xevent->type == KeyPress)
    dasom_event->key.type = DASOM_EVENT_KEY_PRESS;
  else
    dasom_event->key.type = DASOM_EVENT_KEY_RELEASE;

  dasom_event->key.state = (DasomModifierType) xevent->xkey.state;

#if GTK_CHECK_VERSION (3, 6, 0)
  gint group = gdk_x11_keymap_get_group_for_state (keymap, xevent->xkey.state);
#else
  gint group = XkbGroupForCoreState (xevent->xkey.state);
#endif

  dasom_event->key.hardware_keycode = xevent->xkey.keycode;
  dasom_event->key.keyval = DASOM_KEY_VoidSymbol;

  gdk_keymap_translate_keyboard_state (keymap,
                                       dasom_event->key.hardware_keycode,
                                       dasom_event->key.state,
                                       group,
                                       &dasom_event->key.keyval,
                                       NULL, NULL, &consumed);

  state = dasom_event->key.state & ~consumed;
  gdk_keymap_add_virtual_modifiers (keymap, &state);
  dasom_event->key.state |= (DasomModifierType) state;

  return dasom_event;
}