mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
2 Commits
en-keycode
...
inputdevic
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f6f4b65f8 | |||
| 96b753c3e5 |
13
config.def.h
13
config.def.h
@@ -60,6 +60,18 @@ static const struct xkb_rule_names xkb_rules = {
|
|||||||
.options = NULL,
|
.options = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* input devices */
|
||||||
|
static const InputRule inputrules[] = {
|
||||||
|
/* name kbcreate ptrcreate */
|
||||||
|
/* ignore bad device - like a touchpad ;) */
|
||||||
|
{ "BAD DEVICE", NULL, NULL },
|
||||||
|
/* ungroup ydotool device - fixes a bug */
|
||||||
|
{ "ydotoold virtual device", createungroupedkeyboard, createpointer },
|
||||||
|
/* put your touchpad name here to enable toggle touchpad */
|
||||||
|
{ "Elan Touchpad", createkeyboard, createtogglepointer },
|
||||||
|
{ NULL, createkeyboard, createpointer },
|
||||||
|
};
|
||||||
|
|
||||||
static const int repeat_rate = 25;
|
static const int repeat_rate = 25;
|
||||||
static const int repeat_delay = 600;
|
static const int repeat_delay = 600;
|
||||||
|
|
||||||
@@ -142,6 +154,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_u, togglepointer, {0} },
|
||||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
|||||||
89
dwl.c
89
dwl.c
@@ -141,6 +141,12 @@ typedef struct {
|
|||||||
uint32_t resize; /* configure serial of a pending resize */
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
} Client;
|
} Client;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name;
|
||||||
|
void (*kbcreate)(struct wlr_keyboard *);
|
||||||
|
void (*ptrcreate)(struct wlr_pointer *);
|
||||||
|
} InputRule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t mod;
|
uint32_t mod;
|
||||||
xkb_keysym_t keysym;
|
xkb_keysym_t keysym;
|
||||||
@@ -268,6 +274,8 @@ static void createnotify(struct wl_listener *listener, void *data);
|
|||||||
static void createpointer(struct wlr_pointer *pointer);
|
static void createpointer(struct wlr_pointer *pointer);
|
||||||
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
||||||
static void createpopup(struct wl_listener *listener, void *data);
|
static void createpopup(struct wl_listener *listener, void *data);
|
||||||
|
static void createtogglepointer(struct wlr_pointer *pointer);
|
||||||
|
static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
|
||||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||||
static void cursorframe(struct wl_listener *listener, void *data);
|
static void cursorframe(struct wl_listener *listener, void *data);
|
||||||
static void cursorwarptohint(void);
|
static void cursorwarptohint(void);
|
||||||
@@ -336,6 +344,7 @@ static void tagmon(const Arg *arg);
|
|||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
static void togglepointer(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
@@ -436,10 +445,7 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
|||||||
static struct wl_listener start_drag = {.notify = startdrag};
|
static struct wl_listener start_drag = {.notify = startdrag};
|
||||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||||
|
|
||||||
static const struct xkb_rule_names en_rules = {.layout = "de"};
|
static struct libinput_device *togglepointerdevice = NULL;
|
||||||
static struct xkb_context *en_context;
|
|
||||||
static struct xkb_keymap *en_keymap;
|
|
||||||
static struct xkb_state *en_state;
|
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
static void activatex11(struct wl_listener *listener, void *data);
|
static void activatex11(struct wl_listener *listener, void *data);
|
||||||
@@ -722,9 +728,6 @@ cleanup(void)
|
|||||||
wlr_backend_destroy(backend);
|
wlr_backend_destroy(backend);
|
||||||
|
|
||||||
wl_display_destroy(dpy);
|
wl_display_destroy(dpy);
|
||||||
xkb_state_unref(en_state);
|
|
||||||
xkb_keymap_unref(en_keymap);
|
|
||||||
xkb_context_unref(en_context);
|
|
||||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||||
to avoid destroying them with an invalid scene output. */
|
to avoid destroying them with an invalid scene output. */
|
||||||
wlr_scene_node_destroy(&scene->tree.node);
|
wlr_scene_node_destroy(&scene->tree.node);
|
||||||
@@ -1204,6 +1207,33 @@ createpopup(struct wl_listener *listener, void *data)
|
|||||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
createtogglepointer(struct wlr_pointer *pointer)
|
||||||
|
{
|
||||||
|
struct libinput_device *device;
|
||||||
|
|
||||||
|
createpointer(pointer);
|
||||||
|
|
||||||
|
if (wlr_input_device_is_libinput(&pointer->base)
|
||||||
|
&& (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||||
|
togglepointerdevice = device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
createungroupedkeyboard(struct wlr_keyboard *keyboard)
|
||||||
|
{
|
||||||
|
/* for keyboards that need their own keyboard group */
|
||||||
|
KeyboardGroup *group = createkeyboardgroup();
|
||||||
|
|
||||||
|
/* Set the keymap to match the group keymap */
|
||||||
|
wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
|
||||||
|
LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
|
||||||
|
|
||||||
|
/* Add the new keyboard to the group */
|
||||||
|
wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
||||||
{
|
{
|
||||||
@@ -1587,13 +1617,27 @@ inputdevice(struct wl_listener *listener, void *data)
|
|||||||
* available. */
|
* available. */
|
||||||
struct wlr_input_device *device = data;
|
struct wlr_input_device *device = data;
|
||||||
uint32_t caps;
|
uint32_t caps;
|
||||||
|
const InputRule *r;
|
||||||
|
|
||||||
switch (device->type) {
|
switch (device->type) {
|
||||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||||
createkeyboard(wlr_keyboard_from_input_device(device));
|
for (r = inputrules; r < END(inputrules); r++) {
|
||||||
|
if (!r->name || strstr(device->name, r->name)) {
|
||||||
|
if (r->kbcreate)
|
||||||
|
r->kbcreate(wlr_keyboard_from_input_device(device));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WLR_INPUT_DEVICE_POINTER:
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
createpointer(wlr_pointer_from_input_device(device));
|
for (r = inputrules; r < END(inputrules); r++) {
|
||||||
|
if (!r->name || strstr(device->name, r->name)) {
|
||||||
|
if (r->ptrcreate)
|
||||||
|
r->ptrcreate(wlr_pointer_from_input_device(device));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* TODO handle other input device types */
|
/* TODO handle other input device types */
|
||||||
@@ -1636,19 +1680,16 @@ keypress(struct wl_listener *listener, void *data)
|
|||||||
/* This event is raised when a key is pressed or released. */
|
/* This event is raised when a key is pressed or released. */
|
||||||
KeyboardGroup *group = wl_container_of(listener, group, key);
|
KeyboardGroup *group = wl_container_of(listener, group, key);
|
||||||
struct wlr_keyboard_key_event *event = data;
|
struct wlr_keyboard_key_event *event = data;
|
||||||
int nsyms, handled;
|
|
||||||
|
|
||||||
/* Translate libinput keycode -> xkbcommon */
|
/* Translate libinput keycode -> xkbcommon */
|
||||||
uint32_t keycode = event->keycode + 8;
|
uint32_t keycode = event->keycode + 8;
|
||||||
/* Get a list of keysyms based on the keymap for this keyboard */
|
/* Get a list of keysyms based on the keymap for this keyboard */
|
||||||
const xkb_keysym_t *syms;
|
const xkb_keysym_t *syms;
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
int nsyms = xkb_state_key_get_syms(
|
||||||
xkb_state_update_key(en_state, keycode,
|
group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
||||||
(event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
|
||||||
? XKB_KEY_DOWN : XKB_KEY_UP);
|
|
||||||
nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
|
|
||||||
|
|
||||||
handled = 0;
|
int handled = 0;
|
||||||
|
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
@@ -2630,10 +2671,6 @@ setup(void)
|
|||||||
* pointer, touch, and drawing tablet device. We also rig up a listener to
|
* pointer, touch, and drawing tablet device. We also rig up a listener to
|
||||||
* let us know when new input devices are available on the backend.
|
* let us know when new input devices are available on the backend.
|
||||||
*/
|
*/
|
||||||
en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
||||||
en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
|
|
||||||
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
||||||
en_state = xkb_state_new(en_keymap);
|
|
||||||
wl_signal_add(&backend->events.new_input, &new_input_device);
|
wl_signal_add(&backend->events.new_input, &new_input_device);
|
||||||
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
||||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
||||||
@@ -2770,6 +2807,18 @@ togglefullscreen(const Arg *arg)
|
|||||||
setfullscreen(sel, !sel->isfullscreen);
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
togglepointer(const Arg *arg)
|
||||||
|
{
|
||||||
|
if (!togglepointerdevice)
|
||||||
|
return;
|
||||||
|
|
||||||
|
libinput_device_config_send_events_set_mode(
|
||||||
|
togglepointerdevice,
|
||||||
|
libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
From cd61fac9cb6e9d0172e2f7a01e6a514d676ba5f0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
|
||||||
Date: Tue, 4 Feb 2025 23:53:11 +0100
|
|
||||||
Subject: [PATCH] Always use the English keymap to get keycodes
|
|
||||||
|
|
||||||
---
|
|
||||||
dwl.c | 23 +++++++++++++++++++----
|
|
||||||
1 file changed, 19 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index def2562..c299365 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -413,6 +413,11 @@ static struct wlr_box sgeom;
|
|
||||||
static struct wl_list mons;
|
|
||||||
static Monitor *selmon;
|
|
||||||
|
|
||||||
+static const struct xkb_rule_names en_rules = {.layout = "us"};
|
|
||||||
+static struct xkb_context *en_context;
|
|
||||||
+static struct xkb_keymap *en_keymap;
|
|
||||||
+static struct xkb_state *en_state;
|
|
||||||
+
|
|
||||||
#ifdef XWAYLAND
|
|
||||||
static void activatex11(struct wl_listener *listener, void *data);
|
|
||||||
static void associatex11(struct wl_listener *listener, void *data);
|
|
||||||
@@ -694,6 +699,9 @@ cleanup(void)
|
|
||||||
wlr_backend_destroy(backend);
|
|
||||||
|
|
||||||
wl_display_destroy(dpy);
|
|
||||||
+ xkb_state_unref(en_state);
|
|
||||||
+ xkb_keymap_unref(en_keymap);
|
|
||||||
+ xkb_context_unref(en_context);
|
|
||||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
|
||||||
to avoid destroying them with an invalid scene output. */
|
|
||||||
wlr_scene_node_destroy(&scene->tree.node);
|
|
||||||
@@ -1582,16 +1590,19 @@ keypress(struct wl_listener *listener, void *data)
|
|
||||||
/* This event is raised when a key is pressed or released. */
|
|
||||||
KeyboardGroup *group = wl_container_of(listener, group, key);
|
|
||||||
struct wlr_keyboard_key_event *event = data;
|
|
||||||
+ int nsyms, handled;
|
|
||||||
|
|
||||||
/* Translate libinput keycode -> xkbcommon */
|
|
||||||
uint32_t keycode = event->keycode + 8;
|
|
||||||
/* Get a list of keysyms based on the keymap for this keyboard */
|
|
||||||
const xkb_keysym_t *syms;
|
|
||||||
- int nsyms = xkb_state_key_get_syms(
|
|
||||||
- group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
|
||||||
-
|
|
||||||
- int handled = 0;
|
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
|
||||||
+ xkb_state_update_key(en_state, keycode,
|
|
||||||
+ (event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
|
||||||
+ ? XKB_KEY_DOWN : XKB_KEY_UP);
|
|
||||||
+ nsyms = xkb_state_key_get_syms(en_state, keycode, &syms);
|
|
||||||
+
|
|
||||||
+ handled = 0;
|
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
|
||||||
|
|
||||||
@@ -2607,6 +2618,10 @@ setup(void)
|
|
||||||
* pointer, touch, and drawing tablet device. We also rig up a listener to
|
|
||||||
* let us know when new input devices are available on the backend.
|
|
||||||
*/
|
|
||||||
+ en_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
||||||
+ en_keymap = xkb_keymap_new_from_names(en_context, &en_rules,
|
|
||||||
+ XKB_KEYMAP_COMPILE_NO_FLAGS);
|
|
||||||
+ en_state = xkb_state_new(en_keymap);
|
|
||||||
LISTEN_STATIC(&backend->events.new_input, inputdevice);
|
|
||||||
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
|
||||||
LISTEN_STATIC(&virtual_keyboard_mgr->events.new_virtual_keyboard, virtualkeyboard);
|
|
||||||
--
|
|
||||||
2.48.1
|
|
||||||
|
|
||||||
173
inputdevicerules-v0.7.patch
Normal file
173
inputdevicerules-v0.7.patch
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
From 89f870a04f903681b0a7a0ac4eb1ae70c4984b46 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ben Collerson <benc@benc.cc>
|
||||||
|
Date: Sat, 15 Jun 2024 12:34:01 +1000
|
||||||
|
Subject: [PATCH] input device rules
|
||||||
|
|
||||||
|
* customise input device handling
|
||||||
|
* ignore unwanted input devices
|
||||||
|
* configure a toggle for an input device
|
||||||
|
---
|
||||||
|
config.def.h | 13 ++++++++++
|
||||||
|
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
2 files changed, 79 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 22d2171d..0b287ab5 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -60,6 +60,18 @@ static const struct xkb_rule_names xkb_rules = {
|
||||||
|
.options = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* input devices */
|
||||||
|
+static const InputRule inputrules[] = {
|
||||||
|
+ /* name kbcreate ptrcreate */
|
||||||
|
+ /* ignore bad device - like a touchpad ;) */
|
||||||
|
+ { "BAD DEVICE", NULL, NULL },
|
||||||
|
+ /* ungroup ydotool device - fixes a bug */
|
||||||
|
+ { "ydotoold virtual device", createungroupedkeyboard, createpointer },
|
||||||
|
+ /* put your touchpad name here to enable toggle touchpad */
|
||||||
|
+ { "Elan Touchpad", createkeyboard, createtogglepointer },
|
||||||
|
+ { NULL, createkeyboard, createpointer },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const int repeat_rate = 25;
|
||||||
|
static const int repeat_delay = 600;
|
||||||
|
|
||||||
|
@@ -142,6 +154,7 @@ static const Key keys[] = {
|
||||||
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
|
+ { MODKEY, XKB_KEY_u, togglepointer, {0} },
|
||||||
|
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index a2711f67..f6f91938 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -143,6 +143,12 @@ typedef struct {
|
||||||
|
uint32_t resize; /* configure serial of a pending resize */
|
||||||
|
} Client;
|
||||||
|
|
||||||
|
+typedef struct {
|
||||||
|
+ const char *name;
|
||||||
|
+ void (*kbcreate)(struct wlr_keyboard *);
|
||||||
|
+ void (*ptrcreate)(struct wlr_pointer *);
|
||||||
|
+} InputRule;
|
||||||
|
+
|
||||||
|
typedef struct {
|
||||||
|
uint32_t mod;
|
||||||
|
xkb_keysym_t keysym;
|
||||||
|
@@ -270,6 +276,8 @@ static void createnotify(struct wl_listener *listener, void *data);
|
||||||
|
static void createpointer(struct wlr_pointer *pointer);
|
||||||
|
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
||||||
|
static void createpopup(struct wl_listener *listener, void *data);
|
||||||
|
+static void createtogglepointer(struct wlr_pointer *pointer);
|
||||||
|
+static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
|
||||||
|
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||||
|
static void cursorframe(struct wl_listener *listener, void *data);
|
||||||
|
static void cursorwarptohint(void);
|
||||||
|
@@ -340,6 +348,7 @@ static void tagmon(const Arg *arg);
|
||||||
|
static void tile(Monitor *m);
|
||||||
|
static void togglefloating(const Arg *arg);
|
||||||
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
+static void togglepointer(const Arg *arg);
|
||||||
|
static void toggletag(const Arg *arg);
|
||||||
|
static void toggleview(const Arg *arg);
|
||||||
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
|
@@ -413,6 +422,8 @@ static struct wlr_box sgeom;
|
||||||
|
static struct wl_list mons;
|
||||||
|
static Monitor *selmon;
|
||||||
|
|
||||||
|
+static struct libinput_device *togglepointerdevice = NULL;
|
||||||
|
+
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
static void activatex11(struct wl_listener *listener, void *data);
|
||||||
|
static void associatex11(struct wl_listener *listener, void *data);
|
||||||
|
@@ -1133,6 +1144,33 @@ createpopup(struct wl_listener *listener, void *data)
|
||||||
|
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+createtogglepointer(struct wlr_pointer *pointer)
|
||||||
|
+{
|
||||||
|
+ struct libinput_device *device;
|
||||||
|
+
|
||||||
|
+ createpointer(pointer);
|
||||||
|
+
|
||||||
|
+ if (wlr_input_device_is_libinput(&pointer->base)
|
||||||
|
+ && (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||||
|
+ togglepointerdevice = device;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+createungroupedkeyboard(struct wlr_keyboard *keyboard)
|
||||||
|
+{
|
||||||
|
+ /* for keyboards that need their own keyboard group */
|
||||||
|
+ KeyboardGroup *group = createkeyboardgroup();
|
||||||
|
+
|
||||||
|
+ /* Set the keymap to match the group keymap */
|
||||||
|
+ wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
|
||||||
|
+ LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
|
||||||
|
+
|
||||||
|
+ /* Add the new keyboard to the group */
|
||||||
|
+ wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
||||||
|
{
|
||||||
|
@@ -1531,13 +1569,27 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||||
|
* available. */
|
||||||
|
struct wlr_input_device *device = data;
|
||||||
|
uint32_t caps;
|
||||||
|
+ const InputRule *r;
|
||||||
|
|
||||||
|
switch (device->type) {
|
||||||
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||||
|
- createkeyboard(wlr_keyboard_from_input_device(device));
|
||||||
|
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||||
|
+ if (!r->name || strstr(device->name, r->name)) {
|
||||||
|
+ if (r->kbcreate)
|
||||||
|
+ r->kbcreate(wlr_keyboard_from_input_device(device));
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
break;
|
||||||
|
case WLR_INPUT_DEVICE_POINTER:
|
||||||
|
- createpointer(wlr_pointer_from_input_device(device));
|
||||||
|
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||||
|
+ if (!r->name || strstr(device->name, r->name)) {
|
||||||
|
+ if (r->ptrcreate)
|
||||||
|
+ r->ptrcreate(wlr_pointer_from_input_device(device));
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* TODO handle other input device types */
|
||||||
|
@@ -2739,6 +2791,18 @@ togglefullscreen(const Arg *arg)
|
||||||
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+togglepointer(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ if (!togglepointerdevice)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ libinput_device_config_send_events_set_mode(
|
||||||
|
+ togglepointerdevice,
|
||||||
|
+ libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
||||||
|
+ );
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
toggletag(const Arg *arg)
|
||||||
|
{
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
||||||
Reference in New Issue
Block a user