applied inputdevicerules patch
This commit is contained in:
parent
31a414c2f2
commit
1245fbda0e
4 changed files with 96 additions and 6 deletions
|
@ -22,7 +22,8 @@ philosophy. Like dwm, dwl is:
|
||||||
- [en-keycodes](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/en-keycodes)
|
- [en-keycodes](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/en-keycodes)
|
||||||
- [genericgaps](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/genericgaps/)
|
- [genericgaps](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/genericgaps/)
|
||||||
- [hide_vacant_tags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide_vacant_tags)
|
- [hide_vacant_tags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide_vacant_tags)
|
||||||
- [rotatetags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/rotatetags/rotatetags.patch)
|
- [inputdevicerules](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/inputdevicerules)
|
||||||
|
- [rotatetags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/rotatetags)
|
||||||
- [setupenv](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv)
|
- [setupenv](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv)
|
||||||
- [sticky](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/sticky)
|
- [sticky](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/sticky)
|
||||||
- [xkb-rules-switcher](https://codeberg.org/wochap/dwl/src/branch/v0.6-b/xkb-rules-switcher/xkb-rules-switcher.patch)
|
- [xkb-rules-switcher](https://codeberg.org/wochap/dwl/src/branch/v0.6-b/xkb-rules-switcher/xkb-rules-switcher.patch)
|
||||||
|
|
13
config.def.h
13
config.def.h
|
@ -99,6 +99,18 @@ static const struct xkb_rule_names xkb_rules[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
@ -202,6 +214,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} },
|
||||||
|
|
16
config.h
16
config.h
|
@ -51,7 +51,6 @@ static const char *const autostart[] = {
|
||||||
NULL /* terminate */
|
NULL /* terminate */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
|
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* app_id title tags mask isfloating monitor */
|
/* app_id title tags mask isfloating monitor */
|
||||||
|
@ -96,6 +95,18 @@ static const struct xkb_rule_names xkb_rules[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
@ -228,7 +239,8 @@ 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|WLR_MODIFIER_SHIFT, XKB_KEY_F, togglefullscreen, {0} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, 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} },
|
||||||
|
|
68
dwl.c
68
dwl.c
|
@ -152,6 +152,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;
|
||||||
|
@ -312,6 +318,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);
|
||||||
|
@ -397,6 +405,7 @@ static void togglebar(const Arg *arg);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglesticky(const Arg *arg);
|
static void togglesticky(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
static void togglepointer(const Arg *arg);
|
||||||
static void togglegaps(const Arg *arg);
|
static void togglegaps(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);
|
||||||
|
@ -490,6 +499,8 @@ static struct xkb_keymap *en_keymap;
|
||||||
static struct xkb_state *en_state, *en_state_shift;
|
static struct xkb_state *en_state, *en_state_shift;
|
||||||
static xkb_mod_index_t en_shift;
|
static xkb_mod_index_t en_shift;
|
||||||
|
|
||||||
|
static struct libinput_device *togglepointerdevice = NULL;
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
static void activatex11(struct wl_listener *listener, void *data);
|
static void activatex11(struct wl_listener *listener, void *data);
|
||||||
static void associatex11(struct wl_listener *listener, void *data);
|
static void associatex11(struct wl_listener *listener, void *data);
|
||||||
|
@ -1419,6 +1430,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)
|
||||||
{
|
{
|
||||||
|
@ -1983,13 +2021,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 */
|
||||||
|
@ -3236,6 +3288,18 @@ togglesticky(const Arg *arg)
|
||||||
setsticky(c, !c->issticky);
|
setsticky(c, !c->issticky);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue