コード例 #1
0
ファイル: KeyBind.c プロジェクト: MisPresident/libX11
static void
ResetModMap(
    Display *dpy)
{
    register XModifierKeymap *map;
    register int i, j, n;
    KeySym sym;
    register struct _XKeytrans *p;

    map = dpy->modifiermap;
    /* If any Lock key contains Caps_Lock, then interpret as Caps_Lock,
     * else if any contains Shift_Lock, then interpret as Shift_Lock,
     * else ignore Lock altogether.
     */
    dpy->lock_meaning = NoSymbol;
    /* Lock modifiers are in the second row of the matrix */
    n = 2 * map->max_keypermod;
    for (i = map->max_keypermod; i < n; i++) {
	for (j = 0; j < dpy->keysyms_per_keycode; j++) {
	    sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
	    if (sym == XK_Caps_Lock) {
		dpy->lock_meaning = XK_Caps_Lock;
		break;
	    } else if (sym == XK_Shift_Lock) {
		dpy->lock_meaning = XK_Shift_Lock;
	    }
	    else if (sym == XK_ISO_Lock) {
		dpy->lock_meaning = XK_Caps_Lock;
		break;
	    }
	}
    }
    /* Now find any Mod<n> modifier acting as the Group or Numlock modifier */
    dpy->mode_switch = 0;
    dpy->num_lock = 0;
    n *= 4;
    for (i = 3*map->max_keypermod; i < n; i++) {
	for (j = 0; j < dpy->keysyms_per_keycode; j++) {
	    sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
	    if (sym == XK_Mode_switch)
		dpy->mode_switch |= 1 << (i / map->max_keypermod);
	    if (sym == XK_Num_Lock)
		dpy->num_lock |= 1 << (i / map->max_keypermod);
	}
    }
    for (p = dpy->key_bindings; p; p = p->next)
	ComputeMaskFromKeytrans(dpy, p);
}
コード例 #2
0
ファイル: KeyBind.c プロジェクト: MisPresident/libX11
KeySym
XLookupKeysym(
    register XKeyEvent *event,
    int col)
{
    if ((! event->display->keysyms) && (! _XKeyInitialize(event->display)))
	return NoSymbol;
    return KeyCodetoKeySym(event->display, event->keycode, col);
}
コード例 #3
0
KeySym XKeycodeToKeysym(Display *dpy,
#if NeedWidePrototypes
		 unsigned int kc,
#else
		 KeyCode kc,
#endif
		 int col)
{
    if ((!dpy->keysyms) && (!_XKeyInitialize(dpy)))
	return NoSymbol;
    return KeyCodetoKeySym(dpy, kc, col);
}
コード例 #4
0
ファイル: KeyBind.c プロジェクト: MisPresident/libX11
KeyCode
XKeysymToKeycode(
    Display *dpy,
    KeySym ks)
{
    register int i, j;

    if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
	return (KeyCode) 0;
    for (j = 0; j < dpy->keysyms_per_keycode; j++) {
	for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
	    if (KeyCodetoKeySym(dpy, (KeyCode) i, j) == ks)
		return i;
	}
    }
    return 0;
}