mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
2 Commits
hide-behin
...
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} },
|
||||||
|
|||||||
155
dwl.c
155
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);
|
||||||
@@ -285,11 +293,10 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
|||||||
static void focusclient(Client *c, int lift);
|
static void focusclient(Client *c, int lift);
|
||||||
static void focusmon(const Arg *arg);
|
static void focusmon(const Arg *arg);
|
||||||
static void focusstack(const Arg *arg);
|
static void focusstack(const Arg *arg);
|
||||||
static Client *focustop(Monitor *m, int onlytiled);
|
static Client *focustop(Monitor *m);
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||||
static void gpureset(struct wl_listener *listener, void *data);
|
static void gpureset(struct wl_listener *listener, void *data);
|
||||||
static void handlesig(int signo);
|
static void handlesig(int signo);
|
||||||
static void hidebehindmonocle(Monitor *m);
|
|
||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
static void inputdevice(struct wl_listener *listener, void *data);
|
||||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||||
@@ -337,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);
|
||||||
@@ -437,6 +445,8 @@ 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 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);
|
||||||
@@ -519,7 +529,7 @@ arrange(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
||||||
(c = focustop(m, 0)) && c->isfullscreen);
|
(c = focustop(m)) && c->isfullscreen);
|
||||||
|
|
||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||||
|
|
||||||
@@ -811,7 +821,7 @@ closemon(Monitor *m)
|
|||||||
if (c->mon == m)
|
if (c->mon == m)
|
||||||
setmon(c, selmon, c->tags);
|
setmon(c, selmon, c->tags);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1197,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)
|
||||||
{
|
{
|
||||||
@@ -1248,7 +1285,7 @@ void
|
|||||||
destroydragicon(struct wl_listener *listener, void *data)
|
destroydragicon(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
wl_list_remove(&listener->link);
|
wl_list_remove(&listener->link);
|
||||||
free(listener);
|
free(listener);
|
||||||
@@ -1287,7 +1324,7 @@ destroylock(SessionLock *lock, int unlock)
|
|||||||
|
|
||||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||||
|
|
||||||
focusclient(focustop(selmon, 0), 0);
|
focusclient(focustop(selmon), 0);
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
|
|
||||||
destroy:
|
destroy:
|
||||||
@@ -1316,7 +1353,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
|
|||||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
||||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
||||||
} else if (!locked) {
|
} else if (!locked) {
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
} else {
|
} else {
|
||||||
wlr_seat_keyboard_clear_focus(seat);
|
wlr_seat_keyboard_clear_focus(seat);
|
||||||
}
|
}
|
||||||
@@ -1427,7 +1464,6 @@ focusclient(Client *c, int lift)
|
|||||||
wl_list_insert(&fstack, &c->flink);
|
wl_list_insert(&fstack, &c->flink);
|
||||||
selmon = c->mon;
|
selmon = c->mon;
|
||||||
c->isurgent = 0;
|
c->isurgent = 0;
|
||||||
hidebehindmonocle(c->mon);
|
|
||||||
|
|
||||||
/* Don't change border color if there is an exclusive focus or we are
|
/* Don't change border color if there is an exclusive focus or we are
|
||||||
* handling a drag operation */
|
* handling a drag operation */
|
||||||
@@ -1481,14 +1517,14 @@ focusmon(const Arg *arg)
|
|||||||
selmon = dirtomon(arg->i);
|
selmon = dirtomon(arg->i);
|
||||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focusstack(const Arg *arg)
|
focusstack(const Arg *arg)
|
||||||
{
|
{
|
||||||
/* Focus the next or previous client (in tiling order) on selmon */
|
/* Focus the next or previous client (in tiling order) on selmon */
|
||||||
Client *c, *sel = focustop(selmon, 0);
|
Client *c, *sel = focustop(selmon);
|
||||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||||
return;
|
return;
|
||||||
if (arg->i > 0) {
|
if (arg->i > 0) {
|
||||||
@@ -1514,15 +1550,12 @@ focusstack(const Arg *arg)
|
|||||||
* will focus the topmost client of this mon, when actually will
|
* will focus the topmost client of this mon, when actually will
|
||||||
* only return that client */
|
* only return that client */
|
||||||
Client *
|
Client *
|
||||||
focustop(Monitor *m, int onlytiled)
|
focustop(Monitor *m)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
wl_list_for_each(c, &fstack, flink) {
|
wl_list_for_each(c, &fstack, flink) {
|
||||||
if (VISIBLEON(c, m)) {
|
if (VISIBLEON(c, m))
|
||||||
if (onlytiled && c->isfloating)
|
|
||||||
continue;
|
|
||||||
return c;
|
return c;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1568,25 +1601,6 @@ handlesig(int signo)
|
|||||||
quit(NULL);
|
quit(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
hidebehindmonocle(Monitor *m)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
if (m && m->lt[m->sellt]->arrange == monocle) {
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
|
||||||
if (c->mon != m)
|
|
||||||
continue;
|
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
|
||||||
}
|
|
||||||
|
|
||||||
c = NULL;
|
|
||||||
|
|
||||||
/* Enable top tiled client, fullscreen is considered tiled */
|
|
||||||
if ((c = focustop(m, 1)))
|
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
incnmaster(const Arg *arg)
|
incnmaster(const Arg *arg)
|
||||||
{
|
{
|
||||||
@@ -1603,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 */
|
||||||
@@ -1725,7 +1753,7 @@ keyrepeat(void *data)
|
|||||||
void
|
void
|
||||||
killclient(const Arg *arg)
|
killclient(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
if (sel)
|
if (sel)
|
||||||
client_send_close(sel);
|
client_send_close(sel);
|
||||||
}
|
}
|
||||||
@@ -1854,7 +1882,8 @@ monocle(Monitor *m)
|
|||||||
}
|
}
|
||||||
if (n)
|
if (n)
|
||||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
||||||
hidebehindmonocle(m);
|
if ((c = focustop(m)))
|
||||||
|
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2121,7 +2150,7 @@ printstatus(void)
|
|||||||
if (c->isurgent)
|
if (c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
}
|
}
|
||||||
if ((c = focustop(m, 0))) {
|
if ((c = focustop(m))) {
|
||||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
||||||
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
||||||
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
||||||
@@ -2435,7 +2464,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
|||||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||||
setfloating(c, c->isfloating);
|
setfloating(c, c->isfloating);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2709,12 +2738,12 @@ startdrag(struct wl_listener *listener, void *data)
|
|||||||
void
|
void
|
||||||
tag(const Arg *arg)
|
tag(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sel->tags = arg->ui & TAGMASK;
|
sel->tags = arg->ui & TAGMASK;
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
@@ -2722,7 +2751,7 @@ tag(const Arg *arg)
|
|||||||
void
|
void
|
||||||
tagmon(const Arg *arg)
|
tagmon(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
if (sel)
|
if (sel)
|
||||||
setmon(sel, dirtomon(arg->i), 0);
|
setmon(sel, dirtomon(arg->i), 0);
|
||||||
}
|
}
|
||||||
@@ -2764,7 +2793,7 @@ tile(Monitor *m)
|
|||||||
void
|
void
|
||||||
togglefloating(const Arg *arg)
|
togglefloating(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
/* return if fullscreen */
|
/* return if fullscreen */
|
||||||
if (sel && !sel->isfullscreen)
|
if (sel && !sel->isfullscreen)
|
||||||
setfloating(sel, !sel->isfloating);
|
setfloating(sel, !sel->isfloating);
|
||||||
@@ -2773,21 +2802,33 @@ togglefloating(const Arg *arg)
|
|||||||
void
|
void
|
||||||
togglefullscreen(const Arg *arg)
|
togglefullscreen(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
if (sel)
|
if (sel)
|
||||||
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)
|
||||||
{
|
{
|
||||||
uint32_t newtags;
|
uint32_t newtags;
|
||||||
Client *sel = focustop(selmon, 0);
|
Client *sel = focustop(selmon);
|
||||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sel->tags = newtags;
|
sel->tags = newtags;
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
@@ -2800,7 +2841,7 @@ toggleview(const Arg *arg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
selmon->tagset[selmon->seltags] = newtagset;
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
@@ -2824,7 +2865,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
|||||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||||
arrangelayers(l->mon);
|
arrangelayers(l->mon);
|
||||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2841,7 +2882,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|||||||
if (client_is_unmanaged(c)) {
|
if (client_is_unmanaged(c)) {
|
||||||
if (c == exclusive_focus) {
|
if (c == exclusive_focus) {
|
||||||
exclusive_focus = NULL;
|
exclusive_focus = NULL;
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_remove(&c->link);
|
wl_list_remove(&c->link);
|
||||||
@@ -2922,7 +2963,7 @@ updatemons(struct wl_listener *listener, void *data)
|
|||||||
/* Don't move clients to the left output when plugging monitors */
|
/* Don't move clients to the left output when plugging monitors */
|
||||||
arrange(m);
|
arrange(m);
|
||||||
/* make sure fullscreen clients have the right size */
|
/* make sure fullscreen clients have the right size */
|
||||||
if ((c = focustop(m, 0)) && c->isfullscreen)
|
if ((c = focustop(m)) && c->isfullscreen)
|
||||||
resize(c, m->m, 0);
|
resize(c, m->m, 0);
|
||||||
|
|
||||||
/* Try to re-set the gamma LUT when updating monitors,
|
/* Try to re-set the gamma LUT when updating monitors,
|
||||||
@@ -2942,7 +2983,7 @@ updatemons(struct wl_listener *listener, void *data)
|
|||||||
if (!c->mon && client_surface(c)->mapped)
|
if (!c->mon && client_surface(c)->mapped)
|
||||||
setmon(c, selmon, c->tags);
|
setmon(c, selmon, c->tags);
|
||||||
}
|
}
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
if (selmon->lock_surface) {
|
if (selmon->lock_surface) {
|
||||||
client_notify_enter(selmon->lock_surface->surface,
|
client_notify_enter(selmon->lock_surface->surface,
|
||||||
wlr_seat_get_keyboard(seat));
|
wlr_seat_get_keyboard(seat));
|
||||||
@@ -2964,7 +3005,7 @@ void
|
|||||||
updatetitle(struct wl_listener *listener, void *data)
|
updatetitle(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
Client *c = wl_container_of(listener, c, set_title);
|
Client *c = wl_container_of(listener, c, set_title);
|
||||||
if (c == focustop(c->mon, 0))
|
if (c == focustop(c->mon))
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2974,7 +3015,7 @@ urgent(struct wl_listener *listener, void *data)
|
|||||||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
||||||
Client *c = NULL;
|
Client *c = NULL;
|
||||||
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
||||||
if (!c || c == focustop(selmon, 0))
|
if (!c || c == focustop(selmon))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
c->isurgent = 1;
|
c->isurgent = 1;
|
||||||
@@ -2992,7 +3033,7 @@ view(const Arg *arg)
|
|||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||||
if (arg->ui & TAGMASK)
|
if (arg->ui & TAGMASK)
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||||
focusclient(focustop(selmon, 0), 1);
|
focusclient(focustop(selmon), 1);
|
||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
printstatus();
|
printstatus();
|
||||||
}
|
}
|
||||||
@@ -3063,7 +3104,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
|||||||
void
|
void
|
||||||
zoom(const Arg *arg)
|
zoom(const Arg *arg)
|
||||||
{
|
{
|
||||||
Client *c, *sel = focustop(selmon, 0);
|
Client *c, *sel = focustop(selmon);
|
||||||
|
|
||||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||||
return;
|
return;
|
||||||
@@ -3174,7 +3215,7 @@ sethints(struct wl_listener *listener, void *data)
|
|||||||
{
|
{
|
||||||
Client *c = wl_container_of(listener, c, set_hints);
|
Client *c = wl_container_of(listener, c, set_hints);
|
||||||
struct wlr_surface *surface = client_surface(c);
|
struct wlr_surface *surface = client_surface(c);
|
||||||
if (c == focustop(selmon, 0) || !c->surface.xwayland->hints)
|
if (c == focustop(selmon) || !c->surface.xwayland->hints)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||||
|
|||||||
@@ -1,332 +0,0 @@
|
|||||||
From 8022376ee59d616831271dbc9f289a8bfd4fedda Mon Sep 17 00:00:00 2001
|
|
||||||
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
|
|
||||||
<leohdz172@proton.me>
|
|
||||||
Date: Sat, 8 Jul 2023 17:25:16 -0600
|
|
||||||
Subject: [PATCH] hide behind monocle
|
|
||||||
MIME-Version: 1.0
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
|
||||||
Content-Transfer-Encoding: 8bit
|
|
||||||
|
|
||||||
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
|
|
||||||
---
|
|
||||||
dwl.c | 87 +++++++++++++++++++++++++++++++++++++----------------------
|
|
||||||
1 file changed, 55 insertions(+), 32 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/dwl.c b/dwl.c
|
|
||||||
index ad21e1ba..cad3b0b2 100644
|
|
||||||
--- a/dwl.c
|
|
||||||
+++ b/dwl.c
|
|
||||||
@@ -285,10 +285,11 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
|
||||||
static void focusclient(Client *c, int lift);
|
|
||||||
static void focusmon(const Arg *arg);
|
|
||||||
static void focusstack(const Arg *arg);
|
|
||||||
-static Client *focustop(Monitor *m);
|
|
||||||
+static Client *focustop(Monitor *m, int onlytiled);
|
|
||||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
|
||||||
static void gpureset(struct wl_listener *listener, void *data);
|
|
||||||
static void handlesig(int signo);
|
|
||||||
+static void hidebehindmonocle(Monitor *m);
|
|
||||||
static void incnmaster(const Arg *arg);
|
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
|
||||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
|
||||||
@@ -518,7 +519,7 @@ arrange(Monitor *m)
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
|
||||||
- (c = focustop(m)) && c->isfullscreen);
|
|
||||||
+ (c = focustop(m, 0)) && c->isfullscreen);
|
|
||||||
|
|
||||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
|
||||||
|
|
||||||
@@ -807,7 +808,7 @@ closemon(Monitor *m)
|
|
||||||
if (c->mon == m)
|
|
||||||
setmon(c, selmon, c->tags);
|
|
||||||
}
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1243,7 +1244,7 @@ void
|
|
||||||
destroydragicon(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
||||||
wl_list_remove(&listener->link);
|
|
||||||
}
|
|
||||||
@@ -1280,7 +1281,7 @@ destroylock(SessionLock *lock, int unlock)
|
|
||||||
|
|
||||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
|
||||||
|
|
||||||
- focusclient(focustop(selmon), 0);
|
|
||||||
+ focusclient(focustop(selmon, 0), 0);
|
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
destroy:
|
|
||||||
@@ -1309,7 +1310,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
|
|
||||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
|
||||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
|
||||||
} else if (!locked) {
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
} else {
|
|
||||||
wlr_seat_keyboard_clear_focus(seat);
|
|
||||||
}
|
|
||||||
@@ -1420,6 +1421,7 @@ focusclient(Client *c, int lift)
|
|
||||||
wl_list_insert(&fstack, &c->flink);
|
|
||||||
selmon = c->mon;
|
|
||||||
c->isurgent = 0;
|
|
||||||
+ hidebehindmonocle(c->mon);
|
|
||||||
|
|
||||||
/* Don't change border color if there is an exclusive focus or we are
|
|
||||||
* handling a drag operation */
|
|
||||||
@@ -1473,14 +1475,14 @@ focusmon(const Arg *arg)
|
|
||||||
selmon = dirtomon(arg->i);
|
|
||||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
|
||||||
}
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
focusstack(const Arg *arg)
|
|
||||||
{
|
|
||||||
/* Focus the next or previous client (in tiling order) on selmon */
|
|
||||||
- Client *c, *sel = focustop(selmon);
|
|
||||||
+ Client *c, *sel = focustop(selmon, 0);
|
|
||||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
|
||||||
return;
|
|
||||||
if (arg->i > 0) {
|
|
||||||
@@ -1506,12 +1508,15 @@ focusstack(const Arg *arg)
|
|
||||||
* will focus the topmost client of this mon, when actually will
|
|
||||||
* only return that client */
|
|
||||||
Client *
|
|
||||||
-focustop(Monitor *m)
|
|
||||||
+focustop(Monitor *m, int onlytiled)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
wl_list_for_each(c, &fstack, flink) {
|
|
||||||
- if (VISIBLEON(c, m))
|
|
||||||
+ if (VISIBLEON(c, m)) {
|
|
||||||
+ if (onlytiled && c->isfloating)
|
|
||||||
+ continue;
|
|
||||||
return c;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
@@ -1557,6 +1562,25 @@ handlesig(int signo)
|
|
||||||
quit(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+hidebehindmonocle(Monitor *m)
|
|
||||||
+{
|
|
||||||
+ Client *c;
|
|
||||||
+ if (m && m->lt[m->sellt]->arrange == monocle) {
|
|
||||||
+ wl_list_for_each(c, &clients, link) {
|
|
||||||
+ if (c->mon != m)
|
|
||||||
+ continue;
|
|
||||||
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ c = NULL;
|
|
||||||
+
|
|
||||||
+ /* Enable top tiled client, fullscreen is considered tiled */
|
|
||||||
+ if ((c = focustop(m, 1)))
|
|
||||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
incnmaster(const Arg *arg)
|
|
||||||
{
|
|
||||||
@@ -1695,7 +1719,7 @@ keyrepeat(void *data)
|
|
||||||
void
|
|
||||||
killclient(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
if (sel)
|
|
||||||
client_send_close(sel);
|
|
||||||
}
|
|
||||||
@@ -1824,8 +1848,7 @@ monocle(Monitor *m)
|
|
||||||
}
|
|
||||||
if (n)
|
|
||||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
|
||||||
- if ((c = focustop(m)))
|
|
||||||
- wlr_scene_node_raise_to_top(&c->scene->node);
|
|
||||||
+ hidebehindmonocle(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -2092,7 +2115,7 @@ printstatus(void)
|
|
||||||
if (c->isurgent)
|
|
||||||
urg |= c->tags;
|
|
||||||
}
|
|
||||||
- if ((c = focustop(m))) {
|
|
||||||
+ if ((c = focustop(m, 0))) {
|
|
||||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
|
||||||
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
|
||||||
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
|
||||||
@@ -2406,7 +2429,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
|
||||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
|
||||||
setfloating(c, c->isfloating);
|
|
||||||
}
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
@@ -2680,12 +2703,12 @@ startdrag(struct wl_listener *listener, void *data)
|
|
||||||
void
|
|
||||||
tag(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sel->tags = arg->ui & TAGMASK;
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
arrange(selmon);
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
@@ -2693,7 +2716,7 @@ tag(const Arg *arg)
|
|
||||||
void
|
|
||||||
tagmon(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
if (sel)
|
|
||||||
setmon(sel, dirtomon(arg->i), 0);
|
|
||||||
}
|
|
||||||
@@ -2735,7 +2758,7 @@ tile(Monitor *m)
|
|
||||||
void
|
|
||||||
togglefloating(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
/* return if fullscreen */
|
|
||||||
if (sel && !sel->isfullscreen)
|
|
||||||
setfloating(sel, !sel->isfloating);
|
|
||||||
@@ -2744,7 +2767,7 @@ togglefloating(const Arg *arg)
|
|
||||||
void
|
|
||||||
togglefullscreen(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
if (sel)
|
|
||||||
setfullscreen(sel, !sel->isfullscreen);
|
|
||||||
}
|
|
||||||
@@ -2753,12 +2776,12 @@ void
|
|
||||||
toggletag(const Arg *arg)
|
|
||||||
{
|
|
||||||
uint32_t newtags;
|
|
||||||
- Client *sel = focustop(selmon);
|
|
||||||
+ Client *sel = focustop(selmon, 0);
|
|
||||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
sel->tags = newtags;
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
arrange(selmon);
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
@@ -2771,7 +2794,7 @@ toggleview(const Arg *arg)
|
|
||||||
return;
|
|
||||||
|
|
||||||
selmon->tagset[selmon->seltags] = newtagset;
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
arrange(selmon);
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
@@ -2795,7 +2818,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
|
||||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
|
||||||
arrangelayers(l->mon);
|
|
||||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2812,7 +2835,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
|
||||||
if (client_is_unmanaged(c)) {
|
|
||||||
if (c == exclusive_focus) {
|
|
||||||
exclusive_focus = NULL;
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
wl_list_remove(&c->link);
|
|
||||||
@@ -2893,7 +2916,7 @@ updatemons(struct wl_listener *listener, void *data)
|
|
||||||
/* Don't move clients to the left output when plugging monitors */
|
|
||||||
arrange(m);
|
|
||||||
/* make sure fullscreen clients have the right size */
|
|
||||||
- if ((c = focustop(m)) && c->isfullscreen)
|
|
||||||
+ if ((c = focustop(m, 0)) && c->isfullscreen)
|
|
||||||
resize(c, m->m, 0);
|
|
||||||
|
|
||||||
/* Try to re-set the gamma LUT when updating monitors,
|
|
||||||
@@ -2913,7 +2936,7 @@ updatemons(struct wl_listener *listener, void *data)
|
|
||||||
if (!c->mon && client_surface(c)->mapped)
|
|
||||||
setmon(c, selmon, c->tags);
|
|
||||||
}
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
if (selmon->lock_surface) {
|
|
||||||
client_notify_enter(selmon->lock_surface->surface,
|
|
||||||
wlr_seat_get_keyboard(seat));
|
|
||||||
@@ -2935,7 +2958,7 @@ void
|
|
||||||
updatetitle(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
Client *c = wl_container_of(listener, c, set_title);
|
|
||||||
- if (c == focustop(c->mon))
|
|
||||||
+ if (c == focustop(c->mon, 0))
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2945,7 +2968,7 @@ urgent(struct wl_listener *listener, void *data)
|
|
||||||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
|
||||||
Client *c = NULL;
|
|
||||||
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
|
||||||
- if (!c || c == focustop(selmon))
|
|
||||||
+ if (!c || c == focustop(selmon, 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
c->isurgent = 1;
|
|
||||||
@@ -2963,7 +2986,7 @@ view(const Arg *arg)
|
|
||||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
|
||||||
if (arg->ui & TAGMASK)
|
|
||||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
|
||||||
- focusclient(focustop(selmon), 1);
|
|
||||||
+ focusclient(focustop(selmon, 0), 1);
|
|
||||||
arrange(selmon);
|
|
||||||
printstatus();
|
|
||||||
}
|
|
||||||
@@ -3034,7 +3057,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
|
||||||
void
|
|
||||||
zoom(const Arg *arg)
|
|
||||||
{
|
|
||||||
- Client *c, *sel = focustop(selmon);
|
|
||||||
+ Client *c, *sel = focustop(selmon, 0);
|
|
||||||
|
|
||||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
|
||||||
return;
|
|
||||||
@@ -3145,7 +3168,7 @@ sethints(struct wl_listener *listener, void *data)
|
|
||||||
{
|
|
||||||
Client *c = wl_container_of(listener, c, set_hints);
|
|
||||||
struct wlr_surface *surface = client_surface(c);
|
|
||||||
- if (c == focustop(selmon))
|
|
||||||
+ if (c == focustop(selmon, 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
|
||||||
--
|
|
||||||
2.48.0
|
|
||||||
|
|
||||||
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