Ejemplo n.º 1
0
int
xcb_refresh_keyboard_mapping (xcb_key_symbols_t         *syms,
			   xcb_mapping_notify_event_t *event)
{
  if (event->request == XCB_MAPPING_KEYBOARD && syms && !xcb_connection_has_error(syms->c)) {
    if (syms->tag == TAG_VALUE) {
      xcb_keycode_t     min_keycode;
      xcb_keycode_t     max_keycode;

      if (syms->u.reply) {
	free (syms->u.reply);
	syms->u.reply = NULL;
      }
      syms->tag = TAG_COOKIE;
      min_keycode = xcb_get_setup (syms->c)->min_keycode;
      max_keycode = xcb_get_setup (syms->c)->max_keycode;
  
      syms->u.cookie = xcb_get_keyboard_mapping(syms->c,
					     min_keycode,
					     max_keycode - min_keycode + 1);
      
    }
    return 1;
  } 
  return 0;
}
Ejemplo n.º 2
0
xcb_key_symbols_t *
xcb_key_symbols_alloc (xcb_connection_t *c)
{
  xcb_key_symbols_t *syms;
  xcb_keycode_t     min_keycode;
  xcb_keycode_t     max_keycode;

  if (!c || xcb_connection_has_error(c))
    return NULL;

  syms = malloc (sizeof (xcb_key_symbols_t));
  if (!syms)
    return NULL;

  syms->c = c;
  syms->tag = TAG_COOKIE;

  min_keycode = xcb_get_setup (c)->min_keycode;
  max_keycode = xcb_get_setup (c)->max_keycode;
  
  syms->u.cookie = xcb_get_keyboard_mapping(c,
					 min_keycode,
					 max_keycode - min_keycode + 1);
  
  return syms;
}
Ejemplo n.º 3
0
KeySym XKeycodeToKeysym(Display *display, KeyCode keycode, int index) {
	xcb_get_keyboard_mapping_cookie_t cookie;
	xcb_get_keyboard_mapping_reply_t *reply;
	xcb_keysym_t result = NoSymbol;

	cookie = xcb_get_keyboard_mapping(display, keycode, 1);
	reply = xcb_get_keyboard_mapping_reply(display, cookie, NULL);

	if (reply == NULL)
		fatal("Error in X11 communication\n");

	result = xcb_get_keyboard_mapping_keysyms(reply)[index];
	free(reply);
	return result;
}