mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 09:29:47 +01:00
Compare commits
1 Commits
pertag
...
hide-behin
| Author | SHA1 | Date | |
|---|---|---|---|
| b04bf6c01e |
162
dwl.c
162
dwl.c
@@ -100,7 +100,6 @@ typedef struct {
|
||||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
typedef struct Pertag Pertag;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
@@ -198,7 +197,6 @@ struct Monitor {
|
||||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface.link */
|
||||
const Layout *lt[2];
|
||||
Pertag *pertag;
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
uint32_t tagset[2];
|
||||
@@ -287,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);
|
||||
@@ -457,14 +456,6 @@ static struct wlr_xwayland *xwayland;
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
|
||||
struct Pertag {
|
||||
unsigned int curtag, prevtag; /* current and previous tag */
|
||||
int nmasters[TAGCOUNT + 1]; /* number of windows in master area */
|
||||
float mfacts[TAGCOUNT + 1]; /* mfacts per tag */
|
||||
unsigned int sellts[TAGCOUNT + 1]; /* selected layouts */
|
||||
const Layout *ltidxs[TAGCOUNT + 1][2]; /* matrix of tags and layouts indexes */
|
||||
};
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
@@ -528,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));
|
||||
|
||||
@@ -753,7 +744,6 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
free(m->pertag);
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -821,7 +811,7 @@ closemon(Monitor *m)
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
focusclient(focustop(selmon), 1);
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -1099,18 +1089,6 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
|
||||
m->pertag = calloc(1, sizeof(Pertag));
|
||||
m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
|
||||
for (i = 0; i <= TAGCOUNT; i++) {
|
||||
m->pertag->nmasters[i] = m->nmaster;
|
||||
m->pertag->mfacts[i] = m->mfact;
|
||||
|
||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
m->pertag->sellts[i] = m->sellt;
|
||||
}
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
* If the fullscreened surface is not opaque, the compositor must make
|
||||
@@ -1270,7 +1248,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);
|
||||
free(listener);
|
||||
@@ -1309,7 +1287,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:
|
||||
@@ -1338,7 +1316,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);
|
||||
}
|
||||
@@ -1449,6 +1427,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 */
|
||||
@@ -1502,14 +1481,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) {
|
||||
@@ -1535,12 +1514,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;
|
||||
}
|
||||
@@ -1586,12 +1568,31 @@ 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)
|
||||
{
|
||||
if (!arg || !selmon)
|
||||
return;
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -1724,7 +1725,7 @@ keyrepeat(void *data)
|
||||
void
|
||||
killclient(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon);
|
||||
Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
client_send_close(sel);
|
||||
}
|
||||
@@ -1853,8 +1854,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
|
||||
@@ -2121,7 +2121,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);
|
||||
@@ -2392,9 +2392,9 @@ setlayout(const Arg *arg)
|
||||
if (!selmon)
|
||||
return;
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
selmon->sellt ^= 1;
|
||||
if (arg && arg->v)
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2411,7 +2411,7 @@ setmfact(const Arg *arg)
|
||||
f = arg->f < 1.0f ? arg->f + selmon->mfact : arg->f - 1.0f;
|
||||
if (f < 0.1 || f > 0.9)
|
||||
return;
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
selmon->mfact = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -2435,7 +2435,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
|
||||
@@ -2709,12 +2709,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();
|
||||
}
|
||||
@@ -2722,7 +2722,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);
|
||||
}
|
||||
@@ -2764,7 +2764,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);
|
||||
@@ -2773,7 +2773,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);
|
||||
}
|
||||
@@ -2782,12 +2782,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();
|
||||
}
|
||||
@@ -2796,31 +2796,11 @@ void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
uint32_t newtagset;
|
||||
size_t i;
|
||||
if (!(newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0))
|
||||
return;
|
||||
|
||||
if (newtagset == (uint32_t)~0) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
selmon->pertag->curtag = 0;
|
||||
}
|
||||
|
||||
/* test if the user did not select the same tag */
|
||||
if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
selmon->pertag->curtag = i + 1;
|
||||
}
|
||||
|
||||
/* apply settings for this view */
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focusclient(focustop(selmon), 1);
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2844,7 +2824,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);
|
||||
}
|
||||
|
||||
@@ -2861,7 +2841,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);
|
||||
@@ -2942,7 +2922,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,
|
||||
@@ -2962,7 +2942,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));
|
||||
@@ -2984,7 +2964,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();
|
||||
}
|
||||
|
||||
@@ -2994,7 +2974,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;
|
||||
@@ -3007,34 +2987,12 @@ urgent(struct wl_listener *listener, void *data)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
size_t i, tmptag;
|
||||
|
||||
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & ~0) {
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
|
||||
if (arg->ui == TAGMASK)
|
||||
selmon->pertag->curtag = 0;
|
||||
else {
|
||||
for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
selmon->pertag->curtag = i + 1;
|
||||
}
|
||||
} else {
|
||||
tmptag = selmon->pertag->prevtag;
|
||||
selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
selmon->pertag->curtag = tmptag;
|
||||
}
|
||||
|
||||
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
|
||||
focusclient(focustop(selmon), 1);
|
||||
focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -3105,7 +3063,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;
|
||||
@@ -3216,7 +3174,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) || !c->surface.xwayland->hints)
|
||||
if (c == focustop(selmon, 0) || !c->surface.xwayland->hints)
|
||||
return;
|
||||
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
|
||||
3210
dwl.c.orig
3210
dwl.c.orig
File diff suppressed because it is too large
Load Diff
332
hide-behind-monocle.patch
Normal file
332
hide-behind-monocle.patch
Normal 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
|
||||
|
||||
170
pertag.patch
170
pertag.patch
@@ -1,170 +0,0 @@
|
||||
From d3b551ffe3ec85e16341962e322150b81af6722f Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Wed, 31 Jul 2024 08:27:26 -0500
|
||||
Subject: [PATCH] makes layout, mwfact and nmaster individual for every tag
|
||||
|
||||
inspiration: https://github.com/djpohly/dwl/wiki/pertag
|
||||
---
|
||||
dwl.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 70 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 145fd01..2f364bc 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -102,6 +102,7 @@ typedef struct {
|
||||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
+typedef struct Pertag Pertag;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep these three elements in this order */
|
||||
@@ -199,6 +200,7 @@ struct Monitor {
|
||||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface.link */
|
||||
const Layout *lt[2];
|
||||
+ Pertag *pertag;
|
||||
unsigned int seltags;
|
||||
unsigned int sellt;
|
||||
uint32_t tagset[2];
|
||||
@@ -427,6 +429,14 @@ static xcb_atom_t netatom[NetLast];
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
|
||||
+struct Pertag {
|
||||
+ unsigned int curtag, prevtag; /* current and previous tag */
|
||||
+ int nmasters[TAGCOUNT + 1]; /* number of windows in master area */
|
||||
+ float mfacts[TAGCOUNT + 1]; /* mfacts per tag */
|
||||
+ unsigned int sellts[TAGCOUNT + 1]; /* selected layouts */
|
||||
+ const Layout *ltidxs[TAGCOUNT + 1][2]; /* matrix of tags and layouts indexes */
|
||||
+};
|
||||
+
|
||||
/* function implementations */
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
@@ -712,6 +722,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
+ free(m->pertag);
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -983,6 +994,18 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
|
||||
+ m->pertag = calloc(1, sizeof(Pertag));
|
||||
+ m->pertag->curtag = m->pertag->prevtag = 1;
|
||||
+
|
||||
+ for (i = 0; i <= TAGCOUNT; i++) {
|
||||
+ m->pertag->nmasters[i] = m->nmaster;
|
||||
+ m->pertag->mfacts[i] = m->mfact;
|
||||
+
|
||||
+ m->pertag->ltidxs[i][0] = m->lt[0];
|
||||
+ m->pertag->ltidxs[i][1] = m->lt[1];
|
||||
+ m->pertag->sellts[i] = m->sellt;
|
||||
+ }
|
||||
+
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
* If the fullscreened surface is not opaque, the compositor must make
|
||||
@@ -1472,7 +1495,7 @@ incnmaster(const Arg *arg)
|
||||
{
|
||||
if (!arg || !selmon)
|
||||
return;
|
||||
- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -2305,9 +2328,9 @@ setlayout(const Arg *arg)
|
||||
if (!selmon)
|
||||
return;
|
||||
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||
- selmon->sellt ^= 1;
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1;
|
||||
if (arg && arg->v)
|
||||
- selmon->lt[selmon->sellt] = (Layout *)arg->v;
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v;
|
||||
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
@@ -2324,7 +2347,7 @@ setmfact(const Arg *arg)
|
||||
f = arg->f < 1.0f ? arg->f + selmon->mfact : arg->f - 1.0f;
|
||||
if (f < 0.1 || f > 0.9)
|
||||
return;
|
||||
- selmon->mfact = f;
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f;
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -2701,9 +2724,29 @@ void
|
||||
toggleview(const Arg *arg)
|
||||
{
|
||||
uint32_t newtagset;
|
||||
+ size_t i;
|
||||
if (!(newtagset = selmon ? selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK) : 0))
|
||||
return;
|
||||
|
||||
+ if (newtagset == (uint32_t)~0) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ }
|
||||
+
|
||||
+ /* test if the user did not select the same tag */
|
||||
+ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) {
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ for (i = 0; !(newtagset & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+
|
||||
+ /* apply settings for this view */
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
@@ -2892,11 +2935,33 @@ urgent(struct wl_listener *listener, void *data)
|
||||
void
|
||||
view(const Arg *arg)
|
||||
{
|
||||
+ size_t i, tmptag;
|
||||
+
|
||||
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
|
||||
return;
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
- if (arg->ui & TAGMASK)
|
||||
+ if (arg->ui & ~0) {
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+
|
||||
+ if (arg->ui == TAGMASK)
|
||||
+ selmon->pertag->curtag = 0;
|
||||
+ else {
|
||||
+ for (i = 0; !(arg->ui & 1 << i); i++) ;
|
||||
+ selmon->pertag->curtag = i + 1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ tmptag = selmon->pertag->prevtag;
|
||||
+ selmon->pertag->prevtag = selmon->pertag->curtag;
|
||||
+ selmon->pertag->curtag = tmptag;
|
||||
+ }
|
||||
+
|
||||
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag];
|
||||
+ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag];
|
||||
+ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag];
|
||||
+ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt];
|
||||
+ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1];
|
||||
+
|
||||
focusclient(focustop(selmon), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
--
|
||||
2.45.2
|
||||
|
||||
Reference in New Issue
Block a user