Hide keybindings away 1/2
Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
6c877c5905
commit
3a7dd8c715
2
event.c
2
event.c
|
@ -412,7 +412,7 @@ event_handle_keypress(void *data __attribute__ ((unused)),
|
|||
}
|
||||
else
|
||||
{
|
||||
keybinding_t *k = keybinding_find(&globalconf.keys, ev);
|
||||
keybinding_t *k = keybinding_find(ev);
|
||||
if (k && k->fct != LUA_REFNIL)
|
||||
luaA_dofunction(globalconf.L, k->fct, 0);
|
||||
}
|
||||
|
|
81
keybinding.c
81
keybinding.c
|
@ -27,16 +27,14 @@
|
|||
#include "window.h"
|
||||
|
||||
extern awesome_t globalconf;
|
||||
static struct {
|
||||
keybinding_array_t by_code;
|
||||
keybinding_array_t by_sym;
|
||||
} keys;
|
||||
|
||||
DO_LUA_NEW(static, keybinding_t, keybinding, "keybinding", keybinding_ref)
|
||||
DO_LUA_GC(keybinding_t, keybinding, "keybinding", keybinding_unref)
|
||||
|
||||
void keybinding_idx_wipe(keybinding_idx_t *idx)
|
||||
{
|
||||
keybinding_array_wipe(&idx->by_code);
|
||||
keybinding_array_wipe(&idx->by_sym);
|
||||
}
|
||||
|
||||
void keybinding_delete(keybinding_t **kbp)
|
||||
{
|
||||
luaL_unref(globalconf.L, LUA_REGISTRYINDEX, (*kbp)->fct);
|
||||
|
@ -71,11 +69,67 @@ keybinding_cmp(const keybinding_t *k1, const keybinding_t *k2)
|
|||
return k1->mod == k2->mod ? 0 : (k2->mod > k1->mod ? 1 : -1);
|
||||
}
|
||||
|
||||
/** Grab key on the root windows.
|
||||
* \param k The keybinding.
|
||||
*/
|
||||
static void
|
||||
window_root_grabkey(keybinding_t *k)
|
||||
{
|
||||
int phys_screen = globalconf.default_screen;
|
||||
xcb_screen_t *s;
|
||||
xcb_keycode_t kc;
|
||||
|
||||
if((kc = k->keycode)
|
||||
|| (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym))))
|
||||
do
|
||||
{
|
||||
s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | globalconf.numlockmask, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC);
|
||||
phys_screen++;
|
||||
} while(!globalconf.screens_info->xinerama_is_active
|
||||
&& phys_screen < globalconf.screens_info->nscreen);
|
||||
}
|
||||
|
||||
/** Ungrab key on the root windows.
|
||||
* \param k The keybinding.
|
||||
*/
|
||||
static void
|
||||
window_root_ungrabkey(keybinding_t *k)
|
||||
{
|
||||
int phys_screen = globalconf.default_screen;
|
||||
xcb_screen_t *s;
|
||||
xcb_keycode_t kc;
|
||||
|
||||
if((kc = k->keycode)
|
||||
|| (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym))))
|
||||
do
|
||||
{
|
||||
s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | XCB_MOD_MASK_LOCK);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | globalconf.numlockmask);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||
phys_screen++;
|
||||
} while(!globalconf.screens_info->xinerama_is_active
|
||||
&& phys_screen < globalconf.screens_info->nscreen);
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_register_root(keybinding_t *k)
|
||||
{
|
||||
keybinding_idx_t *idx = &globalconf.keys;
|
||||
keybinding_array_t *arr = k->keysym ? &idx->by_sym : &idx->by_code;
|
||||
keybinding_array_t *arr = k->keysym ? &keys.by_sym : &keys.by_code;
|
||||
int l = 0, r = arr->len;
|
||||
|
||||
keybinding_ref(&k);
|
||||
|
@ -103,8 +157,7 @@ keybinding_register_root(keybinding_t *k)
|
|||
void
|
||||
keybinding_unregister_root(keybinding_t **k)
|
||||
{
|
||||
keybinding_idx_t *idx = &globalconf.keys;
|
||||
keybinding_array_t *arr = (*k)->keysym ? &idx->by_sym : &idx->by_code;
|
||||
keybinding_array_t *arr = (*k)->keysym ? &keys.by_sym : &keys.by_code;
|
||||
int l = 0, r = arr->len;
|
||||
|
||||
while (l < r) {
|
||||
|
@ -126,9 +179,9 @@ keybinding_unregister_root(keybinding_t **k)
|
|||
}
|
||||
|
||||
keybinding_t *
|
||||
keybinding_find(const keybinding_idx_t *idx, const xcb_key_press_event_t *ev)
|
||||
keybinding_find(const xcb_key_press_event_t *ev)
|
||||
{
|
||||
const keybinding_array_t *arr = &idx->by_sym;
|
||||
const keybinding_array_t *arr = &keys.by_sym;
|
||||
int l, r, mod = CLEANMASK(ev->state);
|
||||
xcb_keysym_t keysym;
|
||||
|
||||
|
@ -150,8 +203,8 @@ keybinding_find(const keybinding_idx_t *idx, const xcb_key_press_event_t *ev)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (arr != &idx->by_code) {
|
||||
arr = &idx->by_code;
|
||||
if (arr != &keys.by_code) {
|
||||
arr = &keys.by_code;
|
||||
goto again;
|
||||
}
|
||||
return NULL;
|
||||
|
|
31
keybinding.h
31
keybinding.h
|
@ -22,17 +22,32 @@
|
|||
#ifndef AWESOME_KEYBINDING_H
|
||||
#define AWESOME_KEYBINDING_H
|
||||
|
||||
#include "structs.h"
|
||||
#include <xcb/xcb.h>
|
||||
#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
|
||||
{
|
||||
/** Ref count */
|
||||
int refcount;
|
||||
/** Key modifier */
|
||||
unsigned long mod;
|
||||
/** Keysym */
|
||||
xcb_keysym_t keysym;
|
||||
/** Keycode */
|
||||
xcb_keycode_t keycode;
|
||||
/** Lua function to execute. */
|
||||
luaA_function fct;
|
||||
};
|
||||
|
||||
void keybinding_delete(keybinding_t **);
|
||||
DO_RCNT(keybinding_t, keybinding, keybinding_delete)
|
||||
ARRAY_FUNCS(keybinding_t *, keybinding, keybinding_unref)
|
||||
|
||||
void keybinding_idx_wipe(keybinding_idx_t *);
|
||||
|
||||
void keybinding_register_root(keybinding_t *);
|
||||
void keybinding_unregiste_rootr(keybinding_t **);
|
||||
keybinding_t *keybinding_find(const keybinding_idx_t *,
|
||||
const xcb_key_press_event_t *);
|
||||
keybinding_t *keybinding_find(const xcb_key_press_event_t *);
|
||||
|
||||
#endif
|
||||
|
|
25
structs.h
25
structs.h
|
@ -60,7 +60,6 @@ typedef struct widget_node_t widget_node_t;
|
|||
typedef struct statusbar_t statusbar_t;
|
||||
typedef struct client_t client_t;
|
||||
typedef struct titlebar_t titlebar_t;
|
||||
typedef struct keybinding_t keybinding_t;
|
||||
typedef struct client_node_t client_node_t;
|
||||
typedef struct _tag_t tag_t;
|
||||
typedef struct tag_client_node_t tag_client_node_t;
|
||||
|
@ -195,28 +194,6 @@ titlebar_delete(titlebar_t **t)
|
|||
|
||||
DO_RCNT(titlebar_t, titlebar, titlebar_delete)
|
||||
|
||||
/** Keys bindings */
|
||||
ARRAY_TYPE(struct keybinding_t *, keybinding);
|
||||
|
||||
typedef struct keybinding_idx_t {
|
||||
keybinding_array_t by_code;
|
||||
keybinding_array_t by_sym;
|
||||
} keybinding_idx_t;
|
||||
|
||||
struct keybinding_t
|
||||
{
|
||||
/** Ref count */
|
||||
int refcount;
|
||||
/** Key modifier */
|
||||
unsigned long mod;
|
||||
/** Keysym */
|
||||
xcb_keysym_t keysym;
|
||||
/** Keycode */
|
||||
xcb_keycode_t keycode;
|
||||
/** Lua function to execute. */
|
||||
luaA_function fct;
|
||||
};
|
||||
|
||||
/** Status bar */
|
||||
struct statusbar_t
|
||||
{
|
||||
|
@ -392,8 +369,6 @@ struct awesome_t
|
|||
screen_t *screens;
|
||||
/** Screens info */
|
||||
screens_info_t *screens_info;
|
||||
/** Keys bindings list */
|
||||
keybinding_idx_t keys;
|
||||
/** Mouse bindings list */
|
||||
struct
|
||||
{
|
||||
|
|
57
window.c
57
window.c
|
@ -147,63 +147,6 @@ window_root_grabbuttons(xcb_window_t root)
|
|||
}
|
||||
}
|
||||
|
||||
/** Grab key on the root windows.
|
||||
* \param k The keybinding.
|
||||
*/
|
||||
void
|
||||
window_root_grabkey(keybinding_t *k)
|
||||
{
|
||||
int phys_screen = globalconf.default_screen;
|
||||
xcb_screen_t *s;
|
||||
xcb_keycode_t kc;
|
||||
|
||||
if((kc = k->keycode)
|
||||
|| (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym))))
|
||||
do
|
||||
{
|
||||
s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | globalconf.numlockmask, kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
xcb_grab_key(globalconf.connection, true, s->root,
|
||||
k->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK, kc, XCB_GRAB_MODE_ASYNC,
|
||||
XCB_GRAB_MODE_ASYNC);
|
||||
phys_screen++;
|
||||
} while(!globalconf.screens_info->xinerama_is_active
|
||||
&& phys_screen < globalconf.screens_info->nscreen);
|
||||
}
|
||||
|
||||
/** Ungrab key on the root windows.
|
||||
* \param k The keybinding.
|
||||
*/
|
||||
void
|
||||
window_root_ungrabkey(keybinding_t *k)
|
||||
{
|
||||
int phys_screen = globalconf.default_screen;
|
||||
xcb_screen_t *s;
|
||||
xcb_keycode_t kc;
|
||||
|
||||
if((kc = k->keycode)
|
||||
|| (k->keysym && (kc = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym))))
|
||||
do
|
||||
{
|
||||
s = xutil_screen_get(globalconf.connection, phys_screen);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | XCB_MOD_MASK_LOCK);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | globalconf.numlockmask);
|
||||
xcb_ungrab_key(globalconf.connection, kc, s->root,
|
||||
k->mod | globalconf.numlockmask | XCB_MOD_MASK_LOCK);
|
||||
phys_screen++;
|
||||
} while(!globalconf.screens_info->xinerama_is_active
|
||||
&& phys_screen < globalconf.screens_info->nscreen);
|
||||
}
|
||||
|
||||
/** Set transparency of a window.
|
||||
* \param win The window.
|
||||
* \param opacity Opacity of the window, between 0 and 1.
|
||||
|
|
2
window.h
2
window.h
|
@ -29,8 +29,6 @@ long window_getstate(xcb_window_t);
|
|||
void window_configure(xcb_window_t, area_t, int);
|
||||
void window_grabbuttons(xcb_window_t, xcb_window_t, button_t *);
|
||||
void window_root_grabbuttons(xcb_window_t);
|
||||
void window_root_grabkey(keybinding_t *);
|
||||
void window_root_ungrabkey(keybinding_t *);
|
||||
void window_settrans(xcb_window_t, double);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue