From 5798ef0594e5a8408b89cac6d0f8e6b03c467e17 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Mon, 30 Jun 2008 22:49:11 +0200 Subject: [PATCH] Hide keybidings_t away, subsequent simplifications 2/2 Signed-off-by: Pierre Habouzit Signed-off-by: Julien Danjou --- keybinding.c | 33 ++++++++++++++++++++------------- keybinding.h | 13 ++----------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/keybinding.c b/keybinding.c index c7aefcd9..11aa66d2 100644 --- a/keybinding.c +++ b/keybinding.c @@ -23,24 +23,31 @@ /* XStringToKeysym() */ #include +#include "structs.h" +#include "common/refcount.h" +#include "common/array.h" #include "keybinding.h" -#include "window.h" + +ARRAY_TYPE(keybinding_t *, keybinding); extern awesome_t globalconf; + static struct { keybinding_array_t by_code; keybinding_array_t by_sym; -} keys; +} keys_g; -DO_LUA_NEW(static, keybinding_t, keybinding, "keybinding", keybinding_ref) -DO_LUA_GC(keybinding_t, keybinding, "keybinding", keybinding_unref) - -void keybinding_delete(keybinding_t **kbp) +static void keybinding_delete(keybinding_t **kbp) { luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*kbp)->fct); p_delete(kbp); } +DO_RCNT(keybinding_t, keybinding, keybinding_delete) +ARRAY_FUNCS(keybinding_t *, keybinding, keybinding_unref) +DO_LUA_NEW(static, keybinding_t, keybinding, "keybinding", keybinding_ref) +DO_LUA_GC(keybinding_t, keybinding, "keybinding", keybinding_unref) + static int keybinding_ev_cmp(xcb_keysym_t keysym, xcb_keycode_t keycode, unsigned long mod, const keybinding_t *k) @@ -126,10 +133,10 @@ window_root_ungrabkey(keybinding_t *k) && phys_screen < globalconf.screens_info->nscreen); } -void +static void keybinding_register_root(keybinding_t *k) { - keybinding_array_t *arr = k->keysym ? &keys.by_sym : &keys.by_code; + keybinding_array_t *arr = k->keysym ? &keys_g.by_sym : &keys_g.by_code; int l = 0, r = arr->len; keybinding_ref(&k); @@ -154,10 +161,10 @@ keybinding_register_root(keybinding_t *k) window_root_grabkey(k); } -void +static void keybinding_unregister_root(keybinding_t **k) { - keybinding_array_t *arr = (*k)->keysym ? &keys.by_sym : &keys.by_code; + keybinding_array_t *arr = (*k)->keysym ? &keys_g.by_sym : &keys_g.by_code; int l = 0, r = arr->len; while (l < r) { @@ -181,7 +188,7 @@ keybinding_unregister_root(keybinding_t **k) keybinding_t * keybinding_find(const xcb_key_press_event_t *ev) { - const keybinding_array_t *arr = &keys.by_sym; + const keybinding_array_t *arr = &keys_g.by_sym; int l, r, mod = CLEANMASK(ev->state); xcb_keysym_t keysym; @@ -203,8 +210,8 @@ keybinding_find(const xcb_key_press_event_t *ev) break; } } - if (arr != &keys.by_code) { - arr = &keys.by_code; + if (arr != &keys_g.by_code) { + arr = &keys_g.by_code; goto again; } return NULL; diff --git a/keybinding.h b/keybinding.h index 7ca30ee7..cf4f2726 100644 --- a/keybinding.h +++ b/keybinding.h @@ -24,14 +24,8 @@ #include #include "lua.h" -#include "common/refcount.h" -#include "common/array.h" -/** Keys bindings */ -typedef struct keybinding_t keybinding_t; -ARRAY_TYPE(struct keybinding_t *, keybinding); - -struct keybinding_t +typedef struct keybinding_t { /** Ref count */ int refcount; @@ -43,11 +37,8 @@ struct keybinding_t xcb_keycode_t keycode; /** Lua function to execute. */ luaA_function fct; -}; +} keybinding_t; -void keybinding_delete(keybinding_t **); -DO_RCNT(keybinding_t, keybinding, keybinding_delete) -ARRAY_FUNCS(keybinding_t *, keybinding, keybinding_unref) keybinding_t *keybinding_find(const xcb_key_press_event_t *); #endif