Add numlock capslock patch
This commit is contained in:
27
dwl.c
27
dwl.c
@@ -15,6 +15,9 @@
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/libinput.h>
|
||||
#if NUMLOCK_CAPSLOCK_PATCH
|
||||
#include <wlr/interfaces/wlr_keyboard.h>
|
||||
#endif // NUMLOCK_CAPSLOCK_PATCH
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_alpha_modifier_v1.h>
|
||||
@@ -417,6 +420,9 @@ static void ffullscreennotify(struct wl_listener *listener, void *data);
|
||||
static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
#if NUMLOCK_CAPSLOCK_PATCH
|
||||
static uint32_t locked_mods = 0;
|
||||
#endif // NUMLOCK_CAPSLOCK_PATCH
|
||||
static void *exclusive_focus;
|
||||
static struct wl_display *dpy;
|
||||
static struct wl_event_loop *event_loop;
|
||||
@@ -1009,6 +1015,10 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
||||
/* Set the keymap to match the group keymap */
|
||||
wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap);
|
||||
|
||||
#if NUMLOCK_CAPSLOCK_PATCH
|
||||
wlr_keyboard_notify_modifiers(keyboard, 0, 0, locked_mods, 0);
|
||||
#endif // NUMLOCK_CAPSLOCK_PATCH
|
||||
|
||||
/* Add the new keyboard to the group */
|
||||
wlr_keyboard_group_add_keyboard(kb_group->wlr_group, keyboard);
|
||||
}
|
||||
@@ -1030,6 +1040,23 @@ createkeyboardgroup(void)
|
||||
die("failed to compile keymap");
|
||||
|
||||
wlr_keyboard_set_keymap(&group->wlr_group->keyboard, keymap);
|
||||
#if NUMLOCK_CAPSLOCK_PATCH
|
||||
if (numlock) {
|
||||
xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
|
||||
if (mod_index != XKB_MOD_INVALID)
|
||||
locked_mods |= (uint32_t)1 << mod_index;
|
||||
}
|
||||
|
||||
if (capslock) {
|
||||
xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
|
||||
if (mod_index != XKB_MOD_INVALID)
|
||||
locked_mods |= (uint32_t)1 << mod_index;
|
||||
}
|
||||
|
||||
if (locked_mods)
|
||||
wlr_keyboard_notify_modifiers(&group->wlr_group->keyboard, 0, 0, locked_mods, 0);
|
||||
#endif // NUMLOCK_CAPSLOCK_PATCH
|
||||
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
|
||||
|
Reference in New Issue
Block a user