mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 01:20:23 -07:00
Refresh keyboard mapping uppon MappingNotify event
When dynamically switching between layout the keys that are grabbed need to also be refreshed. This is a fix similar to venam/2bwm@148d832 fixes dylanaraps#100
This commit is contained in:
parent
95596f43aa
commit
5663175d57
12
sowm.c
12
sowm.c
@ -24,6 +24,7 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
[ConfigureRequest] = configure_request,
|
[ConfigureRequest] = configure_request,
|
||||||
[KeyPress] = key_press,
|
[KeyPress] = key_press,
|
||||||
[MapRequest] = map_request,
|
[MapRequest] = map_request,
|
||||||
|
[MappingNotify] = mapping_notify,
|
||||||
[DestroyNotify] = notify_destroy,
|
[DestroyNotify] = notify_destroy,
|
||||||
[EnterNotify] = notify_enter,
|
[EnterNotify] = notify_enter,
|
||||||
[MotionNotify] = notify_motion
|
[MotionNotify] = notify_motion
|
||||||
@ -221,6 +222,15 @@ void map_request(XEvent *e) {
|
|||||||
win_focus(list->prev);
|
win_focus(list->prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mapping_notify(XEvent *e) {
|
||||||
|
XMappingEvent *ev = &e->xmapping;
|
||||||
|
|
||||||
|
if (ev->request == MappingKeyboard || ev->request == MappingModifier) {
|
||||||
|
XRefreshKeyboardMapping(ev);
|
||||||
|
input_grab(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void run(const Arg arg) {
|
void run(const Arg arg) {
|
||||||
if (fork()) return;
|
if (fork()) return;
|
||||||
if (d) close(ConnectionNumber(d));
|
if (d) close(ConnectionNumber(d));
|
||||||
@ -240,6 +250,8 @@ void input_grab(Window root) {
|
|||||||
== XKeysymToKeycode(d, 0xff7f))
|
== XKeysymToKeycode(d, 0xff7f))
|
||||||
numlock = (1 << i);
|
numlock = (1 << i);
|
||||||
|
|
||||||
|
XUngrabKey(d, AnyKey, AnyModifier, root);
|
||||||
|
|
||||||
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
|
for (i = 0; i < sizeof(keys)/sizeof(*keys); i++)
|
||||||
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
||||||
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
|
for (j = 0; j < sizeof(modifiers)/sizeof(*modifiers); j++)
|
||||||
|
1
sowm.h
1
sowm.h
@ -39,6 +39,7 @@ void configure_request(XEvent *e);
|
|||||||
void input_grab(Window root);
|
void input_grab(Window root);
|
||||||
void key_press(XEvent *e);
|
void key_press(XEvent *e);
|
||||||
void map_request(XEvent *e);
|
void map_request(XEvent *e);
|
||||||
|
void mapping_notify(XEvent *e);
|
||||||
void notify_destroy(XEvent *e);
|
void notify_destroy(XEvent *e);
|
||||||
void notify_enter(XEvent *e);
|
void notify_enter(XEvent *e);
|
||||||
void notify_motion(XEvent *e);
|
void notify_motion(XEvent *e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user