dont use XKeysymToKeycode because valgrind says it is doing bad things, and we have all the data we need anyways
This commit is contained in:
parent
b8309807ab
commit
36ddd0c408
3 changed files with 31 additions and 18 deletions
|
@ -36,14 +36,14 @@
|
||||||
static void set_modkey_mask(guchar mask, KeySym sym);
|
static void set_modkey_mask(guchar mask, KeySym sym);
|
||||||
|
|
||||||
static XModifierKeymap *modmap;
|
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 */
|
/* This is a bitmask of the different masks for each modifier key */
|
||||||
static guchar modkeys_keys[OB_MODKEY_NUM_KEYS];
|
static guchar modkeys_keys[OB_MODKEY_NUM_KEYS];
|
||||||
|
|
||||||
void modkeys_startup(gboolean reconfigure)
|
void modkeys_startup(gboolean reconfigure)
|
||||||
{
|
{
|
||||||
KeySym *keymap;
|
|
||||||
gint i, j, k;
|
gint i, j, k;
|
||||||
gint min_keycode, max_keycode, keysyms_per_keycode;
|
|
||||||
|
|
||||||
/* reset the keys to not be bound to any masks */
|
/* reset the keys to not be bound to any masks */
|
||||||
for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
|
for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i)
|
||||||
|
@ -77,12 +77,12 @@ void modkeys_startup(gboolean reconfigure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree(keymap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void modkeys_shutdown(gboolean reconfigure)
|
void modkeys_shutdown(gboolean reconfigure)
|
||||||
{
|
{
|
||||||
XFreeModifiermap(modmap);
|
XFreeModifiermap(modmap);
|
||||||
|
XFree(keymap);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint modkeys_keycode_to_mask(guint keycode)
|
guint modkeys_keycode_to_mask(guint keycode)
|
||||||
|
@ -142,3 +142,16 @@ static void set_modkey_mask(guchar mask, KeySym sym)
|
||||||
else if (sym == XK_Meta_L || sym == XK_Meta_R)
|
else if (sym == XK_Meta_L || sym == XK_Meta_R)
|
||||||
modkeys_keys[OB_MODKEY_KEY_META] |= mask;
|
modkeys_keys[OB_MODKEY_KEY_META] |= mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define ob__modkeys_h
|
#define ob__modkeys_h
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
/*! These keys are bound to the modifier masks in any fashion */
|
/*! These keys are bound to the modifier masks in any fashion */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -51,4 +52,8 @@ guint modkeys_only_modifier_masks(guint mask);
|
||||||
right keys when there are both. */
|
right keys when there are both. */
|
||||||
guint modkeys_key_to_mask(ObModkeysKey key);
|
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
|
#endif
|
||||||
|
|
|
@ -205,32 +205,27 @@ gint main(gint argc, gchar **argv)
|
||||||
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
|
cursors[OB_CURSOR_NORTHWEST] = load_cursor("top_left_corner",
|
||||||
XC_top_left_corner);
|
XC_top_left_corner);
|
||||||
|
|
||||||
/* create available keycodes */
|
|
||||||
keys[OB_KEY_RETURN] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Return);
|
|
||||||
keys[OB_KEY_ESCAPE] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Escape);
|
|
||||||
keys[OB_KEY_LEFT] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Left);
|
|
||||||
keys[OB_KEY_RIGHT] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Right);
|
|
||||||
keys[OB_KEY_UP] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Up);
|
|
||||||
keys[OB_KEY_DOWN] =
|
|
||||||
XKeysymToKeycode(ob_display, XK_Down);
|
|
||||||
|
|
||||||
prop_startup(); /* get atoms values for the display */
|
prop_startup(); /* get atoms values for the display */
|
||||||
extensions_query_all(); /* find which extensions are present */
|
extensions_query_all(); /* find which extensions are present */
|
||||||
|
|
||||||
if (screen_annex(program_name)) { /* it will be ours! */
|
if (screen_annex(program_name)) { /* it will be ours! */
|
||||||
do {
|
do {
|
||||||
|
modkeys_startup(reconfigure);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
{
|
{
|
||||||
ObParseInst *i;
|
ObParseInst *i;
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
|
|
||||||
modkeys_startup(reconfigure);
|
|
||||||
|
|
||||||
/* startup the parsing so everything can register sections
|
/* startup the parsing so everything can register sections
|
||||||
of the rc */
|
of the rc */
|
||||||
i = parse_startup();
|
i = parse_startup();
|
||||||
|
|
Loading…
Reference in a new issue