1 Commits

Author SHA1 Message Date
b04bf6c01e patched hide-behind-monocle 2025-04-25 01:10:53 +02:00
4 changed files with 442 additions and 158 deletions

View File

@@ -6,7 +6,6 @@
/* appearance */ /* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */ static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const int smartborders = 1;
static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff); static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff); static const float bordercolor[] = COLOR(0x444444ff);
@@ -14,53 +13,27 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff); static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
static int enableautoswallow = 0; /* enables autoswallowing newly spawned clients */
static float swallowborder = 1.0f; /* add this multiplied by borderpx to border when a client is swallowed */
/* tagging - TAGCOUNT must be no greater than 31 */ /* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (10) #define TAGCOUNT (9)
/* logging */ /* logging */
static int log_level = WLR_ERROR; static int log_level = WLR_ERROR;
/* 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 isterm noswallow monitor */ /* app_id title tags mask isfloating monitor */
/* examples: */ /* examples: */
{ "firefox", NULL, 1 << 1, 0, 0, 0, -1 }, { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "zen", NULL, 1 << 1, 0, 0, 0, -1 }, { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
{ "Lutris", NULL, 1 << 2, 0, 0, 0, 0 },
{ "zenity", NULL, 0, 1, 0, 0, -1 },
{ "steam", NULL, 1 << 2, 0, 0, 0, 0 },
{ "discord", NULL, 1 << 2, 0, 0, 0, 1 },
{ "TeamSpeak", NULL, 1 << 2, 0, 0, 0, 1 },
{ "Mattermost", NULL, 1 << 2, 0, 0, 0, 1 },
{ "Element", NULL, 1 << 2, 0, 0, 0, 1 },
{ "signal", NULL, 1 << 4, 0, 0, 0, 1 },
{ "telegram", NULL, 1 << 4, 0, 0, 0, 1 },
{ "Threema", NULL, 1 << 4, 0, 0, 0, 1 },
{ "Thunderbird", NULL, 1 << 4, 0, 0, 0, 1 },
{ "Sonixd", NULL, 1 << 8, 0, 0, 0, 1 },
{ "KeePassXC", "Unlock Database - KeePassXC", 1 << 1, 1, 0, 0, 0 },
{ "KeePassXC", NULL, 1 << 9, 0, 0, 0, 0 },
{ "com.obsproject.Studio",NULL, 1 << 7, 0, 0, 0, 1 },
{ "easyeffects", NULL, 1 << 9, 0, 0, 0, 1 },
{ "pavucontrol", NULL, 1 << 9, 0, 0, 0, 1 },
{ "nextcloud", NULL, 0, 1, 0, 0, -1 },
{ "st", NULL, 0, 0, 1, 0, -1 },
{ "vifm", NULL, 0, 0, 1, 0, -1 },
{ "vifmrun", NULL, 0, 0, 1, 0, -1 },
}; };
/* layout(s) */ /* layout(s) */
static const Layout layouts[] = { static const Layout layouts[] = {
/* symbol arrange function */ /* symbol arrange function */
{ "M", monocle }, { "[]=", tile },
{ "T", tile }, { "><>", NULL }, /* no layout function means floating behavior */
{ "D", deck }, { "[M]", monocle },
{ "B", bstack },
{ "B", bstackhoriz },
{ "F", NULL }, /* no layout function means floating behavior */
}; };
/* monitors */ /* monitors */
@@ -79,33 +52,12 @@ static const MonitorRule monrules[] = {
}; };
/* keyboard */ /* keyboard */
static const struct xkb_rule_names xkb_rules[] = { static const struct xkb_rule_names xkb_rules = {
{ /* can specify fields: rules, model, layout, variant, options */
.layout = "de", /* example:
.options = "ctrl:nocaps",
*/
.options = NULL, .options = NULL,
},
{
.layout = "de",
.variant = "nodeadkeys",
.options = NULL,
},
{
.layout = "de",
.variant = "ru",
.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 */
{ "SYNA8020:00 06CB:CE5C Touchpad", createkeyboard, createtogglepointer },
{ NULL, createkeyboard, createpointer },
}; };
static const int repeat_rate = 25; static const int repeat_rate = 25;
@@ -154,10 +106,8 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
*/ */
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM; static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
static const int cursor_timeout = 5;
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */ /* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_LOGO #define MODKEY WLR_MODIFIER_ALT
#define TAGKEYS(KEY,SKEY,TAG) \ #define TAGKEYS(KEY,SKEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
@@ -169,66 +119,45 @@ static const int cursor_timeout = 5;
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */ /* commands */
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "foot", NULL };
static const char *filecmd[] = { "st", "-e", "vifmrun", NULL }; static const char *menucmd[] = { "wmenu-run", NULL };
static const char *menucmd[] = { "dmenu_run", "-F", "-i", "-c", "-l", "20", NULL };
static const Key keys[] = { static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */ /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Escape, quit, {0} }, { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_D, togglefloating, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_F, togglefullscreen, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT|WLR_MODIFIER_CTRL, XKB_KEY_F, togglefakefullscreen, {0} },
{ MODKEY, XKB_KEY_h, focusstack, {.i = -1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, zoom, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, incnmaster, {.i = +1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_l, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_M, setlayout, {.v = &layouts[0]} }, { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_U, setmfact, {.f = -0.05f} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_I, setmfact, {.f = -0.05f} }, { MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, setmfact, {.f = +0.05f} }, { MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_P, setmfact, {.f = +0.05f} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} }, { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_T, setlayout, {.v = &layouts[1]} }, { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, setlayout, {.v = &layouts[2]} }, { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_V, setlayout, {.v = &layouts[3]} }, { MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_S, setlayout, {.v = &layouts[4]} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setmfact, {.f = -0.05f} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, incxkbrules, {.i = +1} }, { 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} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} }, { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_semicolon, tagmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_colon, tagmon, {.i = WLR_DIRECTION_RIGHT} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
{ MODKEY, XKB_KEY_r, spawn, {.v = menucmd} },
{ MODKEY, XKB_KEY_f, spawn, {.v = filecmd} },
{ MODKEY, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_space, togglepointer, {0} },
{ WLR_MODIFIER_ALT, XKB_KEY_Tab, focusstack, {.i = +1} },
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0), TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
TAGKEYS(XKB_KEY_2, XKB_KEY_quotedbl, 1), TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
TAGKEYS(XKB_KEY_3, XKB_KEY_section, 2), TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3), TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3),
TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4), TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
TAGKEYS(XKB_KEY_6, XKB_KEY_ampersand, 5), TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5),
TAGKEYS(XKB_KEY_7, XKB_KEY_slash, 6), TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
TAGKEYS(XKB_KEY_8, XKB_KEY_parenleft, 7), TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
TAGKEYS(XKB_KEY_9, XKB_KEY_parenright, 8), TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
TAGKEYS(XKB_KEY_0, XKB_KEY_equal, 9), { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
// TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
// TAGKEYS( XKB_KEY_2, XKB_KEY_quotedbl, 1),
// TAGKEYS( XKB_KEY_3, XKB_KEY_paragraph, 2),
// TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3),
// TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
// TAGKEYS( XKB_KEY_6, XKB_KEY_ampersand, 5),
// TAGKEYS( XKB_KEY_7, XKB_KEY_asciicircum, 6),
// TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 7),
// TAGKEYS( XKB_KEY_9, XKB_KEY_parenright, 8),
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */ /* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
{ WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} }, { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },

View File

@@ -24,11 +24,11 @@ WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`
# -I$(PWD)/wlroots/0.19/include/wlroots-0.19 # -I$(PWD)/wlroots/0.19/include/wlroots-0.19
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.19/lib64 -L$(PWD)/wlroots/0.19/lib64 -lwlroots-0.19 #WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.19/lib64 -L$(PWD)/wlroots/0.19/lib64 -lwlroots-0.19
# XWAYLAND = XWAYLAND =
# XLIBS = XLIBS =
# Uncomment to build XWayland support # Uncomment to build XWayland support
XWAYLAND = -DXWAYLAND #XWAYLAND = -DXWAYLAND
XLIBS = xcb xcb-icccm #XLIBS = xcb xcb-icccm
# dwl itself only uses C99 features, but wlroots' headers use anonymous unions (C11). # dwl itself only uses C99 features, but wlroots' headers use anonymous unions (C11).
# To avoid warnings about them, we do not use -std=c99 and instead of using the # To avoid warnings about them, we do not use -std=c99 and instead of using the

89
dwl.c
View File

@@ -285,10 +285,11 @@ 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); 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 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);
@@ -518,7 +519,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));
@@ -810,7 +811,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();
} }
@@ -1247,7 +1248,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, 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);
@@ -1286,7 +1287,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, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
destroy: destroy:
@@ -1315,7 +1316,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);
} }
@@ -1426,6 +1427,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);
/* 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 */
@@ -1479,14 +1481,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), 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 && !client_has_children(sel))) if (!sel || (sel->isfullscreen && !client_has_children(sel)))
return; return;
if (arg->i > 0) { if (arg->i > 0) {
@@ -1512,13 +1514,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;
} }
@@ -1563,6 +1568,25 @@ 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)
{ {
@@ -1701,7 +1725,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);
} }
@@ -1829,9 +1853,8 @@ monocle(Monitor *m)
n++; n++;
} }
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
@@ -2098,7 +2121,7 @@ printstatus(void)
if (c->isurgent) if (c->isurgent)
urg |= c->tags; 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 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);
@@ -2412,7 +2435,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
@@ -2686,12 +2709,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();
} }
@@ -2699,7 +2722,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);
} }
@@ -2741,7 +2764,7 @@ tile(Monitor *m)
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);
@@ -2750,7 +2773,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);
} }
@@ -2759,12 +2782,12 @@ void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {
uint32_t newtags; uint32_t newtags;
Client *sel = focustop(selmon); Client *sel = focustop(selmon, 0);
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), 1); focusclient(focustop(selmon, 0), 1);
arrange(selmon); arrange(selmon);
printstatus(); printstatus();
} }
@@ -2777,7 +2800,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();
} }
@@ -2801,7 +2824,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, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
} }
@@ -2818,7 +2841,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), 1); focusclient(focustop(selmon, 0), 1);
} }
} else { } else {
wl_list_remove(&c->link); wl_list_remove(&c->link);
@@ -2899,7 +2922,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); 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,
@@ -2919,7 +2942,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), 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));
@@ -2941,7 +2964,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();
} }
@@ -2951,7 +2974,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;
c->isurgent = 1; c->isurgent = 1;
@@ -2969,7 +2992,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();
} }
@@ -3040,7 +3063,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;
@@ -3151,7 +3174,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) || !c->surface.xwayland->hints) if (c == focustop(selmon, 0) || !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);

332
hide-behind-monocle.patch Normal file
View File

@@ -0,0 +1,332 @@
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