mirror of
https://github.com/tiyn/dwl.git
synced 2025-11-13 05:49:45 +01:00
added inputdevicerules patch and branch
This commit is contained in:
68
dwl.c
68
dwl.c
@@ -141,6 +141,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;
|
||||
@@ -268,6 +274,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);
|
||||
@@ -336,6 +344,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);
|
||||
@@ -436,6 +445,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
|
||||
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);
|
||||
@@ -1196,6 +1207,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)
|
||||
{
|
||||
@@ -1579,13 +1617,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 */
|
||||
@@ -2755,6 +2807,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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user