mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-16 07:47:22 +01:00
key: move grabbing code to window
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
8969bb181a
commit
5daab0fb47
5 changed files with 32 additions and 31 deletions
30
key.c
30
key.c
|
@ -32,36 +32,6 @@
|
|||
#include "common/xutil.h"
|
||||
#include "common/luaobject.h"
|
||||
|
||||
/** Grab key on a window.
|
||||
* \param win The window.
|
||||
* \param k The key.
|
||||
*/
|
||||
static void
|
||||
window_grabkey(xcb_window_t win, keyb_t *k)
|
||||
{
|
||||
if(k->keycode)
|
||||
xcb_grab_key(globalconf.connection, true, win,
|
||||
k->modifiers, k->keycode, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
else if(k->keysym)
|
||||
{
|
||||
xcb_keycode_t *keycodes = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym);
|
||||
if(keycodes)
|
||||
{
|
||||
for(xcb_keycode_t *kc = keycodes; *kc; kc++)
|
||||
xcb_grab_key(globalconf.connection, true, win,
|
||||
k->modifiers, *kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
p_delete(&keycodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
window_grabkeys(xcb_window_t win, key_array_t *keys)
|
||||
{
|
||||
foreach(k, *keys)
|
||||
window_grabkey(win, *k);
|
||||
}
|
||||
|
||||
/** XCB equivalent of XLookupString which translate the keycode given
|
||||
* by PressEvent to a KeySym and a string
|
||||
* \todo use XKB!
|
||||
|
|
1
key.h
1
key.h
|
@ -47,7 +47,6 @@ xcb_keysym_t key_getkeysym(xcb_keycode_t, uint16_t);
|
|||
void luaA_key_array_set(lua_State *, int, int, key_array_t *);
|
||||
int luaA_key_array_get(lua_State *, int, key_array_t *);
|
||||
|
||||
void window_grabkeys(xcb_window_t, key_array_t *);
|
||||
int luaA_pushmodifiers(lua_State *, uint16_t);
|
||||
uint16_t luaA_tomodifiers(lua_State *L, int ud);
|
||||
|
||||
|
|
1
root.c
1
root.c
|
@ -25,6 +25,7 @@
|
|||
#include "button.h"
|
||||
#include "wibox.h"
|
||||
#include "luaa.h"
|
||||
#include "window.h"
|
||||
#include "common/xcursor.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/xutil.h"
|
||||
|
|
30
window.c
30
window.c
|
@ -109,6 +109,36 @@ window_buttons_grab(xcb_window_t win, button_array_t *buttons)
|
|||
(*b)->button, (*b)->modifiers);
|
||||
}
|
||||
|
||||
/** Grab key on a window.
|
||||
* \param win The window.
|
||||
* \param k The key.
|
||||
*/
|
||||
static void
|
||||
window_grabkey(xcb_window_t win, keyb_t *k)
|
||||
{
|
||||
if(k->keycode)
|
||||
xcb_grab_key(globalconf.connection, true, win,
|
||||
k->modifiers, k->keycode, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
else if(k->keysym)
|
||||
{
|
||||
xcb_keycode_t *keycodes = xcb_key_symbols_get_keycode(globalconf.keysyms, k->keysym);
|
||||
if(keycodes)
|
||||
{
|
||||
for(xcb_keycode_t *kc = keycodes; *kc; kc++)
|
||||
xcb_grab_key(globalconf.connection, true, win,
|
||||
k->modifiers, *kc, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||
p_delete(&keycodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
window_grabkeys(xcb_window_t win, key_array_t *keys)
|
||||
{
|
||||
foreach(k, *keys)
|
||||
window_grabkey(win, *k);
|
||||
}
|
||||
|
||||
/** Get the opacity of a window.
|
||||
* \param win The window.
|
||||
* \return The opacity, between 0 and 1 or -1 or no opacity set.
|
||||
|
|
1
window.h
1
window.h
|
@ -33,6 +33,7 @@ double window_opacity_get(xcb_window_t);
|
|||
double window_opacity_get_from_reply(xcb_get_property_reply_t *);
|
||||
void window_opacity_set(xcb_window_t, double);
|
||||
void window_grabbuttons(xcb_window_t, xcb_window_t, button_array_t *);
|
||||
void window_grabkeys(xcb_window_t, key_array_t *);
|
||||
void window_takefocus(xcb_window_t);
|
||||
void window_set_cursor(xcb_window_t, xcb_cursor_t);
|
||||
|
||||
|
|
Loading…
Reference in a new issue