From: Dana Jansens Date: Fri, 27 Jul 2007 02:05:53 +0000 (-0400) Subject: change openbox to use the libotk's keyboard.[ch] stuff instead of the old modkeys... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=759e9f58a8cc02b78bc85b4454f133544e3ac36e;p=chaz%2Fopenbox change openbox to use the libotk's keyboard.[ch] stuff instead of the old modkeys.[ch] and some of translate.[ch] --- diff --git a/Makefile.am b/Makefile.am index 770f587e..bf6c8c01 100644 --- a/Makefile.am +++ b/Makefile.am @@ -256,8 +256,6 @@ openbox_openbox_SOURCES = \ openbox/menu.c \ openbox/menu.h \ openbox/misc.h \ - openbox/modkeys.c \ - openbox/modkeys.h \ openbox/mouse.c \ openbox/mouse.h \ openbox/moveresize.c \ diff --git a/obt/keyboard.c b/obt/keyboard.c index 94429680..397504fb 100644 --- a/obt/keyboard.c +++ b/obt/keyboard.c @@ -40,7 +40,7 @@ static XModifierKeymap *modmap; static KeySym *keymap; static gint min_keycode, max_keycode, keysyms_per_keycode; /* This is a bitmask of the different masks for each modifier key */ -static guchar modkeys_keys[OBT_MODKEY_NUM_KEYS]; +static guchar modkeys_keys[OBT_KEYBOARD_NUM_MODKEYS]; static gboolean alt_l = FALSE; static gboolean meta_l = FALSE; @@ -57,7 +57,7 @@ void obt_keyboard_reload() started = TRUE; /* reset the keys to not be bound to any masks */ - for (i = 0; i < OBT_MODKEY_NUM_KEYS; ++i) + for (i = 0; i < OBT_KEYBOARD_NUM_MODKEYS; ++i) modkeys_keys[i] = 0; modmap = XGetModifierMapping(obt_display); @@ -92,9 +92,9 @@ void obt_keyboard_reload() } /* CapsLock, Shift, and Control are special and hard-coded */ - modkeys_keys[OBT_MODKEY_KEY_CAPSLOCK] = LockMask; - modkeys_keys[OBT_MODKEY_KEY_SHIFT] = ShiftMask; - modkeys_keys[OBT_MODKEY_KEY_CONTROL] = ControlMask; + modkeys_keys[OBT_KEYBOARD_MODKEY_CAPSLOCK] = LockMask; + modkeys_keys[OBT_KEYBOARD_MODKEY_SHIFT] = ShiftMask; + modkeys_keys[OBT_KEYBOARD_MODKEY_CONTROL] = ControlMask; } void obt_keyboard_shutdown() @@ -133,8 +133,8 @@ guint obt_keyboard_only_modmasks(guint mask) because you could bind it to something else and it should work as that modifier then. i think capslock is weird in xkb. */ - mask &= ~obt_keyboard_modkey_to_modmask(OBT_MODKEY_KEY_NUMLOCK); - mask &= ~obt_keyboard_modkey_to_modmask(OBT_MODKEY_KEY_SCROLLLOCK); + mask &= ~obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_NUMLOCK); + mask &= ~obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SCROLLLOCK); return mask; } @@ -148,39 +148,39 @@ static void set_modkey_mask(guchar mask, KeySym sym) /* find what key this is, and bind it to the mask */ if (sym == XK_Num_Lock) - modkeys_keys[OBT_MODKEY_KEY_NUMLOCK] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_NUMLOCK] |= mask; else if (sym == XK_Scroll_Lock) - modkeys_keys[OBT_MODKEY_KEY_SCROLLLOCK] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_SCROLLLOCK] |= mask; else if (sym == XK_Super_L && super_l) - modkeys_keys[OBT_MODKEY_KEY_SUPER] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] |= mask; else if (sym == XK_Super_L && !super_l) /* left takes precident over right, so erase any masks the right key may have set */ - modkeys_keys[OBT_MODKEY_KEY_SUPER] = mask, super_l = TRUE; + modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] = mask, super_l = TRUE; else if (sym == XK_Super_R && !super_l) - modkeys_keys[OBT_MODKEY_KEY_SUPER] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_SUPER] |= mask; else if (sym == XK_Hyper_L && hyper_l) - modkeys_keys[OBT_MODKEY_KEY_HYPER] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] |= mask; else if (sym == XK_Hyper_L && !hyper_l) - modkeys_keys[OBT_MODKEY_KEY_HYPER] = mask, hyper_l = TRUE; + modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] = mask, hyper_l = TRUE; else if (sym == XK_Hyper_R && !hyper_l) - modkeys_keys[OBT_MODKEY_KEY_HYPER] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_HYPER] |= mask; else if (sym == XK_Alt_L && alt_l) - modkeys_keys[OBT_MODKEY_KEY_ALT] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] |= mask; else if (sym == XK_Alt_L && !alt_l) - modkeys_keys[OBT_MODKEY_KEY_ALT] = mask, alt_l = TRUE; + modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] = mask, alt_l = TRUE; else if (sym == XK_Alt_R && !alt_l) - modkeys_keys[OBT_MODKEY_KEY_ALT] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_ALT] |= mask; else if (sym == XK_Meta_L && meta_l) - modkeys_keys[OBT_MODKEY_KEY_META] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_META] |= mask; else if (sym == XK_Meta_L && !meta_l) - modkeys_keys[OBT_MODKEY_KEY_META] = mask, meta_l = TRUE; + modkeys_keys[OBT_KEYBOARD_MODKEY_META] = mask, meta_l = TRUE; else if (sym == XK_Meta_R && !meta_l) - modkeys_keys[OBT_MODKEY_KEY_META] |= mask; + modkeys_keys[OBT_KEYBOARD_MODKEY_META] |= mask; /* CapsLock, Shift, and Control are special and hard-coded */ } @@ -220,5 +220,6 @@ gunichar obt_keyboard_keycode_to_unichar(guint keycode) if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0) unikey = 0; } + g_free(key); return unikey; } diff --git a/obt/keyboard.h b/obt/keyboard.h index 348433fb..bfe0e925 100644 --- a/obt/keyboard.h +++ b/obt/keyboard.h @@ -27,17 +27,17 @@ G_BEGIN_DECLS /*! These keys are bound to the modifier masks in any fashion, except for CapsLock, Shift, and Control. */ typedef enum { - OBT_MODKEY_KEY_CAPSLOCK, - OBT_MODKEY_KEY_NUMLOCK, - OBT_MODKEY_KEY_SCROLLLOCK, - OBT_MODKEY_KEY_SHIFT, - OBT_MODKEY_KEY_CONTROL, - OBT_MODKEY_KEY_SUPER, - OBT_MODKEY_KEY_HYPER, - OBT_MODKEY_KEY_META, - OBT_MODKEY_KEY_ALT, - - OBT_MODKEY_NUM_KEYS + OBT_KEYBOARD_MODKEY_CAPSLOCK, + OBT_KEYBOARD_MODKEY_NUMLOCK, + OBT_KEYBOARD_MODKEY_SCROLLLOCK, + OBT_KEYBOARD_MODKEY_SHIFT, + OBT_KEYBOARD_MODKEY_CONTROL, + OBT_KEYBOARD_MODKEY_SUPER, + OBT_KEYBOARD_MODKEY_HYPER, + OBT_KEYBOARD_MODKEY_META, + OBT_KEYBOARD_MODKEY_ALT, + + OBT_KEYBOARD_NUM_MODKEYS } ObtModkeysKey; void obt_keyboard_reload(); diff --git a/openbox/event.c b/openbox/event.c index 83be0541..79ead346 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -31,17 +31,16 @@ #include "menu.h" #include "menuframe.h" #include "keyboard.h" -#include "modkeys.h" #include "mouse.h" #include "focus.h" #include "focus_cycle.h" #include "moveresize.h" #include "group.h" #include "stacking.h" -#include "translate.h" #include "ping.h" #include "obt/display.h" #include "obt/prop.h" +#include "obt/keyboard.h" #include #include @@ -259,10 +258,10 @@ static void event_hack_mods(XEvent *e) switch (e->type) { case ButtonPress: case ButtonRelease: - e->xbutton.state = modkeys_only_modifier_masks(e->xbutton.state); + e->xbutton.state = obt_keyboard_only_modmasks(e->xbutton.state); break; case KeyPress: - e->xkey.state = modkeys_only_modifier_masks(e->xkey.state); + e->xkey.state = obt_keyboard_only_modmasks(e->xkey.state); break; case KeyRelease: #ifdef XKB @@ -274,14 +273,14 @@ static void event_hack_mods(XEvent *e) else #endif { - e->xkey.state = modkeys_only_modifier_masks(e->xkey.state); + e->xkey.state = obt_keyboard_only_modmasks(e->xkey.state); /* remove from the state the mask of the modifier key being released, if it is a modifier key being released that is */ - e->xkey.state &= ~modkeys_keycode_to_mask(e->xkey.keycode); + e->xkey.state &= ~obt_keyboard_keycode_to_modmask(e->xkey.keycode); } break; case MotionNotify: - e->xmotion.state = modkeys_only_modifier_masks(e->xmotion.state); + e->xmotion.state = obt_keyboard_only_modmasks(e->xmotion.state); /* compress events */ { XEvent ce; @@ -1676,7 +1675,7 @@ static gboolean event_handle_menu_keyboard(XEvent *ev) keycode = ev->xkey.keycode; state = ev->xkey.state; - unikey = translate_unichar(keycode); + unikey = obt_keyboard_keycode_to_unichar(keycode); frame = find_active_or_last_menu(); if (frame == NULL) diff --git a/openbox/grab.c b/openbox/grab.c index bc9d4cca..4207b37d 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -18,12 +18,12 @@ */ #include "grab.h" -#include "modkeys.h" #include "openbox.h" #include "event.h" #include "screen.h" #include "debug.h" #include "obt/display.h" +#include "obt/keyboard.h" #include #include @@ -146,9 +146,9 @@ void grab_startup(gboolean reconfig) guint i = 0; guint num, caps, scroll; - num = modkeys_key_to_mask(OB_MODKEY_KEY_NUMLOCK); - caps = modkeys_key_to_mask(OB_MODKEY_KEY_CAPSLOCK); - scroll = modkeys_key_to_mask(OB_MODKEY_KEY_SCROLLLOCK); + num = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_NUMLOCK); + caps = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CAPSLOCK); + scroll = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SCROLLLOCK); mask_list[i++] = 0; mask_list[i++] = num; diff --git a/openbox/modkeys.c b/openbox/modkeys.c deleted file mode 100644 index 3ac70c13..00000000 --- a/openbox/modkeys.c +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - modkeys.c for the Openbox window manager - Copyright (c) 2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#include "modkeys.h" -#include "openbox.h" - -#include -#include - -/* These masks are constants and the modifier keys are bound to them as - anyone sees fit: - ShiftMask (1<<0), LockMask (1<<1), ControlMask (1<<2), Mod1Mask (1<<3), - Mod2Mask (1<<4), Mod3Mask (1<<5), Mod4Mask (1<<6), Mod5Mask (1<<7) -*/ -#define NUM_MASKS 8 -#define ALL_MASKS 0xff /* an or'ing of all 8 keyboard masks */ - -/* Get the bitflag for the n'th modifier mask */ -#define nth_mask(n) (1 << n) - -static void set_modkey_mask(guchar mask, KeySym sym); - -static XModifierKeymap *modmap; -static KeySym *keymap; -static gint min_keycode, max_keycode, keysyms_per_keycode; -/* This is a bitmask of the different masks for each modifier key */ -static guchar modkeys_keys[OB_MODKEY_NUM_KEYS]; - -static gboolean alt_l = FALSE; -static gboolean meta_l = FALSE; -static gboolean super_l = FALSE; -static gboolean hyper_l = FALSE; - -void modkeys_startup(gboolean reconfigure) -{ - gint i, j, k; - - /* reset the keys to not be bound to any masks */ - for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i) - modkeys_keys[i] = 0; - - modmap = XGetModifierMapping(obt_display); - g_assert(modmap->max_keypermod > 0); - - XDisplayKeycodes(obt_display, &min_keycode, &max_keycode); - keymap = XGetKeyboardMapping(obt_display, min_keycode, - max_keycode - min_keycode + 1, - &keysyms_per_keycode); - - alt_l = meta_l = super_l = hyper_l = FALSE; - - /* go through each of the modifier masks (eg ShiftMask, CapsMask...) */ - for (i = 0; i < NUM_MASKS; ++i) { - /* go through each keycode that is bound to the mask */ - for (j = 0; j < modmap->max_keypermod; ++j) { - KeySym sym; - /* get a keycode that is bound to the mask (i) */ - KeyCode keycode = modmap->modifiermap[i*modmap->max_keypermod + j]; - if (keycode) { - /* go through each keysym bound to the given keycode */ - for (k = 0; k < keysyms_per_keycode; ++k) { - sym = keymap[(keycode-min_keycode) * keysyms_per_keycode + - k]; - if (sym != NoSymbol) { - /* bind the key to the mask (e.g. Alt_L => Mod1Mask) */ - set_modkey_mask(nth_mask(i), sym); - } - } - } - } - } - - /* CapsLock, Shift, and Control are special and hard-coded */ - modkeys_keys[OB_MODKEY_KEY_CAPSLOCK] = LockMask; - modkeys_keys[OB_MODKEY_KEY_SHIFT] = ShiftMask; - modkeys_keys[OB_MODKEY_KEY_CONTROL] = ControlMask; -} - -void modkeys_shutdown(gboolean reconfigure) -{ - XFreeModifiermap(modmap); - XFree(keymap); -} - -guint modkeys_keycode_to_mask(guint keycode) -{ - gint i, j; - guint mask = 0; - - if (keycode == NoSymbol) return 0; - - /* go through each of the modifier masks (eg ShiftMask, CapsMask...) */ - for (i = 0; i < NUM_MASKS; ++i) { - /* go through each keycode that is bound to the mask */ - for (j = 0; j < modmap->max_keypermod; ++j) { - /* compare with a keycode that is bound to the mask (i) */ - if (modmap->modifiermap[i*modmap->max_keypermod + j] == keycode) - mask |= nth_mask(i); - } - } - return mask; -} - -guint modkeys_only_modifier_masks(guint mask) -{ - mask &= ALL_MASKS; - /* strip off these lock keys. they shouldn't affect key bindings */ - mask &= ~LockMask; /* use the LockMask, not what capslock is bound to, - because you could bind it to something else and it - should work as that modifier then. i think capslock - is weird in xkb. */ - mask &= ~modkeys_key_to_mask(OB_MODKEY_KEY_NUMLOCK); - mask &= ~modkeys_key_to_mask(OB_MODKEY_KEY_SCROLLLOCK); - return mask; -} - -guint modkeys_key_to_mask(ObModkeysKey key) -{ - return modkeys_keys[key]; -} - -static void set_modkey_mask(guchar mask, KeySym sym) -{ - /* find what key this is, and bind it to the mask */ - - if (sym == XK_Num_Lock) - modkeys_keys[OB_MODKEY_KEY_NUMLOCK] |= mask; - else if (sym == XK_Scroll_Lock) - modkeys_keys[OB_MODKEY_KEY_SCROLLLOCK] |= mask; - - else if (sym == XK_Super_L && super_l) - modkeys_keys[OB_MODKEY_KEY_SUPER] |= mask; - else if (sym == XK_Super_L && !super_l) - /* left takes precident over right, so erase any masks the right - key may have set */ - modkeys_keys[OB_MODKEY_KEY_SUPER] = mask, super_l = TRUE; - else if (sym == XK_Super_R && !super_l) - modkeys_keys[OB_MODKEY_KEY_SUPER] |= mask; - - else if (sym == XK_Hyper_L && hyper_l) - modkeys_keys[OB_MODKEY_KEY_HYPER] |= mask; - else if (sym == XK_Hyper_L && !hyper_l) - modkeys_keys[OB_MODKEY_KEY_HYPER] = mask, hyper_l = TRUE; - else if (sym == XK_Hyper_R && !hyper_l) - modkeys_keys[OB_MODKEY_KEY_HYPER] |= mask; - - else if (sym == XK_Alt_L && alt_l) - modkeys_keys[OB_MODKEY_KEY_ALT] |= mask; - else if (sym == XK_Alt_L && !alt_l) - modkeys_keys[OB_MODKEY_KEY_ALT] = mask, alt_l = TRUE; - else if (sym == XK_Alt_R && !alt_l) - modkeys_keys[OB_MODKEY_KEY_ALT] |= mask; - - else if (sym == XK_Meta_L && meta_l) - modkeys_keys[OB_MODKEY_KEY_META] |= mask; - else if (sym == XK_Meta_L && !meta_l) - modkeys_keys[OB_MODKEY_KEY_META] = mask, meta_l = TRUE; - else if (sym == XK_Meta_R && !meta_l) - modkeys_keys[OB_MODKEY_KEY_META] |= mask; - - /* CapsLock, Shift, and Control are special and hard-coded */ -} - -KeyCode modkeys_sym_to_code(KeySym sym) -{ - gint i, j; - - /* go through each keycode and look for the keysym */ - for (i = min_keycode; i <= max_keycode; ++i) - for (j = 0; j < keysyms_per_keycode; ++j) - if (sym == keymap[(i-min_keycode) * keysyms_per_keycode + j]) - return i; - return 0; -} - diff --git a/openbox/modkeys.h b/openbox/modkeys.h deleted file mode 100644 index dc72f28e..00000000 --- a/openbox/modkeys.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - masks.h for the Openbox window manager - Copyright (c) 2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#ifndef ob__modkeys_h -#define ob__modkeys_h - -#include -#include - -/*! These keys are bound to the modifier masks in any fashion, - except for CapsLock, Shift, and Control. */ -typedef enum { - OB_MODKEY_KEY_CAPSLOCK, - OB_MODKEY_KEY_NUMLOCK, - OB_MODKEY_KEY_SCROLLLOCK, - OB_MODKEY_KEY_SHIFT, - OB_MODKEY_KEY_CONTROL, - OB_MODKEY_KEY_SUPER, - OB_MODKEY_KEY_HYPER, - OB_MODKEY_KEY_META, - OB_MODKEY_KEY_ALT, - - OB_MODKEY_NUM_KEYS -} ObModkeysKey; - -void modkeys_startup(gboolean reconfigure); -void modkeys_shutdown(gboolean reconfigure); - -/*! Get the modifier masks for a keycode. (eg. a keycode bound to Alt_L could - return a mask of (Mod1Mask | Mask3Mask)) */ -guint modkeys_keycode_to_mask(guint keycode); - -/*! Strip off all modifiers except for the modifier keys. This strips stuff - like Button1Mask, and also LockMask, NumLockMask, and ScrollLockMask */ -guint modkeys_only_modifier_masks(guint mask); - -/*! Get the modifier masks for a modifier key. This includes both the left and - right keys when there are both. */ -guint modkeys_key_to_mask(ObModkeysKey key); - -/*! Convert a KeySym to a KeyCode, because the X function is terrible - says - valgrind. */ -KeyCode modkeys_sym_to_code(KeySym sym); - -#endif diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 776f37cd..38963dfc 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -24,7 +24,6 @@ #include "frame.h" #include "openbox.h" #include "resist.h" -#include "modkeys.h" #include "popup.h" #include "moveresize.h" #include "config.h" @@ -34,6 +33,7 @@ #include "render/theme.h" #include "obt/display.h" #include "obt/prop.h" +#include "obt/keyboard.h" #include #include @@ -603,7 +603,7 @@ static void move_with_keys(gint keycode, gint state) gint dist = 0; /* shift means jump to edge */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) { + if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) { gint x, y; ObDirection dir; @@ -621,8 +621,11 @@ static void move_with_keys(gint keycode, gint state) dy = y - moveresize_client->area.y; } else { /* control means fine grained */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) + if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { dist = 1; + } else dist = KEY_DIST; @@ -703,7 +706,7 @@ static void resize_with_keys(gint keycode, gint state) } /* shift means jump to edge */ - if (state & modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT)) { + if (state & obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT)) { gint x, y, w, h; if (keycode == ob_keycode(OB_KEY_RIGHT)) @@ -728,7 +731,9 @@ static void resize_with_keys(gint keycode, gint state) distw = moveresize_client->size_inc.width; resist = 1; } - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) { + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { distw = 1; resist = 1; } @@ -740,7 +745,9 @@ static void resize_with_keys(gint keycode, gint state) disth = moveresize_client->size_inc.height; resist = 1; } - else if (state & modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL)) { + else if (state & + obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL)) + { disth = 1; resist = 1; } diff --git a/openbox/openbox.c b/openbox/openbox.c index fb19cbdf..aefe6851 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -206,12 +206,12 @@ gint main(gint argc, gchar **argv) if (reconfigure) obt_keyboard_reload(); /* get the keycodes for keys we use */ - keys[OB_KEY_RETURN] = modkeys_sym_to_code(XK_Return); - keys[OB_KEY_ESCAPE] = modkeys_sym_to_code(XK_Escape); - keys[OB_KEY_LEFT] = modkeys_sym_to_code(XK_Left); - keys[OB_KEY_RIGHT] = modkeys_sym_to_code(XK_Right); - keys[OB_KEY_UP] = modkeys_sym_to_code(XK_Up); - keys[OB_KEY_DOWN] = modkeys_sym_to_code(XK_Down); + keys[OB_KEY_RETURN] = obt_keyboard_keysym_to_keycode(XK_Return); + keys[OB_KEY_ESCAPE] = obt_keyboard_keysym_to_keycode(XK_Escape); + keys[OB_KEY_LEFT] = obt_keyboard_keysym_to_keycode(XK_Left); + keys[OB_KEY_RIGHT] = obt_keyboard_keysym_to_keycode(XK_Right); + keys[OB_KEY_UP] = obt_keyboard_keysym_to_keycode(XK_Up); + keys[OB_KEY_DOWN] = obt_keyboard_keysym_to_keycode(XK_Down); { ObParseInst *i; diff --git a/openbox/translate.c b/openbox/translate.c index 263bffa4..7e89e32c 100644 --- a/openbox/translate.c +++ b/openbox/translate.c @@ -19,9 +19,9 @@ #include "openbox.h" #include "mouse.h" -#include "modkeys.h" -#include "translate.h" #include "gettext.h" +#include "obt/keyboard.h" + #include #include #include @@ -38,23 +38,23 @@ static guint translate_modifier(gchar *str) else if (!g_ascii_strcasecmp("Control", str) || !g_ascii_strcasecmp("C", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_CONTROL); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_CONTROL); else if (!g_ascii_strcasecmp("Alt", str) || !g_ascii_strcasecmp("A", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_ALT); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_ALT); else if (!g_ascii_strcasecmp("Meta", str) || !g_ascii_strcasecmp("M", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_META); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_META); /* W = windows key, is linked to the Super_L/R buttons */ else if (!g_ascii_strcasecmp("Super", str) || !g_ascii_strcasecmp("W", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_SUPER); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SUPER); else if (!g_ascii_strcasecmp("Shift", str) || !g_ascii_strcasecmp("S", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_SHIFT); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_SHIFT); else if (!g_ascii_strcasecmp("Hyper", str) || !g_ascii_strcasecmp("H", str)) - mask = modkeys_key_to_mask(OB_MODKEY_KEY_HYPER); + mask = obt_keyboard_modkey_to_modmask(OBT_KEYBOARD_MODKEY_HYPER); else g_message(_("Invalid modifier key '%s' in key/mouse binding"), str); @@ -158,30 +158,3 @@ translation_fail: g_strfreev(parsed); return ret; } - -gchar *translate_keycode(guint keycode) -{ - KeySym sym; - const gchar *ret = NULL; - - if ((sym = XKeycodeToKeysym(obt_display, keycode, 0)) != NoSymbol) - ret = XKeysymToString(sym); - return g_locale_to_utf8(ret, -1, NULL, NULL, NULL); -} - -gunichar translate_unichar(guint keycode) -{ - gunichar unikey = 0; - - char *key; - if ((key = translate_keycode(keycode)) != NULL && - /* don't accept keys that aren't a single letter, like "space" */ - key[1] == '\0') - { - unikey = g_utf8_get_char_validated(key, -1); - if (unikey == (gunichar)-1 || unikey == (gunichar)-2 || unikey == 0) - unikey = 0; - } - g_free(key); - return unikey; -} diff --git a/openbox/translate.h b/openbox/translate.h index 6d9e23bc..8249514e 100644 --- a/openbox/translate.h +++ b/openbox/translate.h @@ -24,10 +24,4 @@ gboolean translate_button(const gchar *str, guint *state, guint *keycode); gboolean translate_key(const gchar *str, guint *state, guint *keycode); -/*! Give the string form of a keycode */ -gchar *translate_keycode(guint keycode); - -/*! Translate a keycode to the unicode character it represents */ -gunichar translate_unichar(guint keycode); - #endif