dwmstatus: make use of IgnoreLockMods
This commit is contained in:
parent
ccf7c7f7e1
commit
694f9f29a6
17
dwmstatus.c
17
dwmstatus.c
|
@ -2724,19 +2724,15 @@ get_numlock_mask (struct app_context *ctx)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CLEANMASK(mask) (mask & ~(numlock_mask | LockMask))
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_x_keypress (struct app_context *ctx, XEvent *e)
|
on_x_keypress (struct app_context *ctx, XEvent *e)
|
||||||
{
|
{
|
||||||
unsigned numlock_mask = get_numlock_mask (ctx);
|
|
||||||
|
|
||||||
XKeyEvent *ev = &e->xkey;
|
XKeyEvent *ev = &e->xkey;
|
||||||
KeySym keysym = XkbKeycodeToKeysym (ctx->dpy, (KeyCode) ev->keycode,
|
KeySym keysym = XkbKeycodeToKeysym (ctx->dpy, (KeyCode) ev->keycode,
|
||||||
0, !!(ev->state & ShiftMask));
|
0, !!(ev->state & ShiftMask));
|
||||||
for (size_t i = 0; i < N_ELEMENTS (g_keys); i++)
|
for (size_t i = 0; i < N_ELEMENTS (g_keys); i++)
|
||||||
if (keysym == g_keys[i].keysym
|
if (keysym == g_keys[i].keysym
|
||||||
&& CLEANMASK (g_keys[i].mod) == CLEANMASK (ev->state)
|
&& g_keys[i].mod == ev->state
|
||||||
&& g_keys[i].handler)
|
&& g_keys[i].handler)
|
||||||
g_keys[i].handler (ctx, g_keys[i].arg);
|
g_keys[i].handler (ctx, g_keys[i].arg);
|
||||||
}
|
}
|
||||||
|
@ -2760,17 +2756,16 @@ on_x_ready (const struct pollfd *pfd, void *user_data)
|
||||||
static void
|
static void
|
||||||
grab_keys (struct app_context *ctx)
|
grab_keys (struct app_context *ctx)
|
||||||
{
|
{
|
||||||
unsigned numlock_mask = get_numlock_mask (ctx);
|
unsigned ignored_locks = LockMask | get_numlock_mask (ctx);
|
||||||
unsigned modifiers[] =
|
hard_assert (XkbSetIgnoreLockMods
|
||||||
{ 0, LockMask, numlock_mask, numlock_mask | LockMask };
|
(ctx->dpy, XkbUseCoreKbd, ignored_locks, ignored_locks, 0, 0));
|
||||||
|
|
||||||
KeyCode code;
|
KeyCode code;
|
||||||
Window root = DefaultRootWindow (ctx->dpy);
|
Window root = DefaultRootWindow (ctx->dpy);
|
||||||
for (size_t i = 0; i < N_ELEMENTS (g_keys); i++)
|
for (size_t i = 0; i < N_ELEMENTS (g_keys); i++)
|
||||||
if ((code = XKeysymToKeycode (ctx->dpy, g_keys[i].keysym)))
|
if ((code = XKeysymToKeycode (ctx->dpy, g_keys[i].keysym)))
|
||||||
for (size_t j = 0; j < N_ELEMENTS (modifiers); j++)
|
XGrabKey (ctx->dpy, code, g_keys[i].mod, root,
|
||||||
XGrabKey (ctx->dpy, code, g_keys[i].mod | modifiers[j], root,
|
False /* ? */, GrabModeAsync, GrabModeAsync);
|
||||||
False /* ? */, GrabModeAsync, GrabModeAsync);
|
|
||||||
|
|
||||||
XSelectInput (ctx->dpy, root, KeyPressMask);
|
XSelectInput (ctx->dpy, root, KeyPressMask);
|
||||||
XSync (ctx->dpy, False);
|
XSync (ctx->dpy, False);
|
||||||
|
|
Loading…
Reference in New Issue