apply hide behind monocle patch

This commit is contained in:
korei999 2023-11-29 22:30:31 +02:00
parent 0d3a1d0c8a
commit fc14399c31

91
dwl.c
View file

@ -288,9 +288,10 @@ static void dwl_ipc_output_release(struct wl_client *client, struct wl_resource
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); static Client *focustop(Monitor *m, int onlytiled);
static void fullscreennotify(struct wl_listener *listener, void *data); static void fullscreennotify(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 void kblayoutnotify(Keyboard *kb, int update); static void kblayoutnotify(Keyboard *kb, int update);
@ -496,7 +497,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)) && c->isfullscreen); (c = focustop(m, 0)) && c->isfullscreen);
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
@ -776,7 +777,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), 1); focusclient(focustop(selmon, 0), 1);
printstatus(); printstatus();
} }
@ -1141,7 +1142,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), 1); focusclient(focustop(selmon, 0), 1);
motionnotify(0); motionnotify(0);
} }
@ -1177,7 +1178,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); focusclient(focustop(selmon, 0), 0);
motionnotify(0); motionnotify(0);
destroy: destroy:
@ -1206,7 +1207,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), 1); focusclient(focustop(selmon, 0), 1);
} else { } else {
wlr_seat_keyboard_clear_focus(seat); wlr_seat_keyboard_clear_focus(seat);
} }
@ -1335,7 +1336,7 @@ dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output)
Client *c, *focused; Client *c, *focused;
int tagmask, state, numclients, focused_client, tag; int tagmask, state, numclients, focused_client, tag;
const char *title, *appid; const char *title, *appid;
focused = focustop(monitor); focused = focustop(monitor, 0);
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon); zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
for (tag = 0 ; tag < TAGCOUNT; tag++) { for (tag = 0 ; tag < TAGCOUNT; tag++) {
@ -1387,7 +1388,7 @@ dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *res
return; return;
monitor = ipc_output->mon; monitor = ipc_output->mon;
selected_client = focustop(monitor); selected_client = focustop(monitor, 0);
if (!selected_client) if (!selected_client)
return; return;
@ -1396,7 +1397,7 @@ dwl_ipc_output_set_client_tags(struct wl_client *client, struct wl_resource *res
return; return;
selected_client->tags = newtags; selected_client->tags = newtags;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon, 0), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
} }
@ -1440,7 +1441,7 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
monitor->seltags ^= 1; monitor->seltags ^= 1;
monitor->tagset[monitor->seltags] = newtags; monitor->tagset[monitor->seltags] = newtags;
focusclient(focustop(monitor), 1); focusclient(focustop(monitor, 0), 1);
arrange(monitor); arrange(monitor);
printstatus(); printstatus();
} }
@ -1484,6 +1485,7 @@ 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);
client_restack_surface(c); client_restack_surface(c);
/* 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
@ -1548,14 +1550,14 @@ focusmon(const Arg *arg)
do /* don't switch to disabled mons */ do /* don't switch to disabled mons */
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), 1); focusclient(focustop(selmon, 0), 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); Client *c, *sel = focustop(selmon, 0);
if (!sel || sel->isfullscreen) if (!sel || sel->isfullscreen)
return; return;
if (arg->i > 0) { if (arg->i > 0) {
@ -1581,12 +1583,16 @@ 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) focustop(Monitor *m, int onlytiled)
{ {
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;
} }
@ -1631,6 +1637,22 @@ handlesig(int signo)
} }
} }
void
hidebehindmonocle(Monitor *m)
{
Client *c;
if (m && m->lt[m->sellt]->arrange == monocle) {
wl_list_for_each(c, &clients, link)
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)
{ {
@ -1682,7 +1704,7 @@ kblayoutnotify(Keyboard *kb, int update)
XKB_STATE_LAYOUT_EFFECTIVE); XKB_STATE_LAYOUT_EFFECTIVE);
// Update client layout // Update client layout
if (kblayout_perclient && kb->layout_idx != old && (c = focustop(selmon))) if (kblayout_perclient && kb->layout_idx != old && (c = focustop(selmon, 0)))
c->layout_idx = kb->layout_idx; c->layout_idx = kb->layout_idx;
} }
@ -1805,7 +1827,7 @@ keyrepeat(void *data)
void void
killclient(const Arg *arg) killclient(const Arg *arg)
{ {
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
if (sel) if (sel)
client_send_close(sel); client_send_close(sel);
} }
@ -1942,8 +1964,7 @@ monocle(Monitor *m)
} }
if (n) if (n)
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n); snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
if ((c = focustop(m))) hidebehindmonocle(m);
wlr_scene_node_raise_to_top(&c->scene->node);
} }
void void
@ -2491,7 +2512,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), 1); focusclient(focustop(selmon, 0), 1);
} }
void void
@ -2744,12 +2765,12 @@ startdrag(struct wl_listener *listener, void *data)
void void
tag(const Arg *arg) tag(const Arg *arg)
{ {
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
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), 1); focusclient(focustop(selmon, 0), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
} }
@ -2757,7 +2778,7 @@ tag(const Arg *arg)
void void
tagmon(const Arg *arg) tagmon(const Arg *arg)
{ {
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
if (sel) if (sel)
setmon(sel, dirtomon(arg->i), 0); setmon(sel, dirtomon(arg->i), 0);
} }
@ -2844,7 +2865,7 @@ togglebar(const Arg *arg) {
void void
togglefloating(const Arg *arg) togglefloating(const Arg *arg)
{ {
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
/* return if fullscreen */ /* return if fullscreen */
if (sel && !sel->isfullscreen) if (sel && !sel->isfullscreen)
setfloating(sel, !sel->isfloating); setfloating(sel, !sel->isfloating);
@ -2853,7 +2874,7 @@ togglefloating(const Arg *arg)
void void
togglefullscreen(const Arg *arg) togglefullscreen(const Arg *arg)
{ {
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
if (sel) if (sel)
setfullscreen(sel, !sel->isfullscreen); setfullscreen(sel, !sel->isfullscreen);
} }
@ -2867,7 +2888,7 @@ toggleview(const Arg *arg)
return; return;
selmon->tagset[selmon->seltags] = newtagset; selmon->tagset[selmon->seltags] = newtagset;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon, 0), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
} }
@ -2891,7 +2912,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), 1); focusclient(focustop(selmon, 0), 1);
motionnotify(0); motionnotify(0);
} }
@ -2909,7 +2930,7 @@ unmapnotify(struct wl_listener *listener, void *data)
if (c == exclusive_focus) if (c == exclusive_focus)
exclusive_focus = NULL; exclusive_focus = NULL;
if (client_surface(c) == seat->keyboard_state.focused_surface) if (client_surface(c) == seat->keyboard_state.focused_surface)
focusclient(focustop(selmon), 1); focusclient(focustop(selmon, 0), 1);
} else { } else {
wl_list_remove(&c->link); wl_list_remove(&c->link);
setmon(c, NULL, 0); setmon(c, NULL, 0);
@ -2986,7 +3007,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)) && c->isfullscreen) if ((c = focustop(m, 0)) && c->isfullscreen)
resize(c, m->m, 0, 0); resize(c, m->m, 0, 0);
m->gamma_lut_changed = 1; m->gamma_lut_changed = 1;
@ -3000,7 +3021,7 @@ updatemons(struct wl_listener *listener, void *data)
wl_list_for_each(c, &clients, link) wl_list_for_each(c, &clients, link)
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), 1); focusclient(focustop(selmon, 0), 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));
@ -3022,7 +3043,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)) if (c == focustop(c->mon, 0))
printstatus(); printstatus();
} }
@ -3032,7 +3053,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)) if (!c || c == focustop(selmon, 0))
return; return;
if (client_surface(c)->mapped) if (client_surface(c)->mapped)
@ -3049,7 +3070,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), 1); focusclient(focustop(selmon, 0), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
} }
@ -3102,7 +3123,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); Client *c, *sel = focustop(selmon, 0);
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating) if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
return; return;
@ -3242,7 +3263,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)) if (c == focustop(selmon, 0))
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);