summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortslil clingman <tslil@posteo.de>2023-04-10 21:28:45 +0200
committertslil clingman <tslil@posteo.de>2023-04-10 21:28:45 +0200
commit4e51afbb822c4926151cd80a9e1ef357f05768d6 (patch)
tree920a9760eaabb20db0c43b77bc16ca86a575fc5c
parente7b800d81881cf95fcb822cd46acb03c1dd21856 (diff)
[dwl] upstream changes
-rw-r--r--dwl/config.h2
-rw-r--r--dwl/dwl.c83
2 files changed, 46 insertions, 39 deletions
diff --git a/dwl/config.h b/dwl/config.h
index 6fdee76..e78d5d5 100644
--- a/dwl/config.h
+++ b/dwl/config.h
@@ -10,7 +10,7 @@ static const float focuscolor[] = {1.000, 0.549, 0.000, 1.0}
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
/* tagging */
-static const char *tags[] = { "F", "U", "H", ".", "V", "L", "O", "M" };
+#define tagcount 8
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor keep_focus */
diff --git a/dwl/dwl.c b/dwl/dwl.c
index adba6c5..c7bcf5a 100644
--- a/dwl/dwl.c
+++ b/dwl/dwl.c
@@ -68,7 +68,7 @@
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define END(A) ((A) + LENGTH(A))
-#define TAGMASK ((1 << LENGTH(tags)) - 1)
+#define TAGMASK ((1u << tagcount) - 1)
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define IDLE_NOTIFY_ACTIVITY wlr_idle_notify_activity(idle, seat), wlr_idle_notifier_v1_notify_activity(idle_notifier, seat)
@@ -100,7 +100,7 @@ typedef struct Monitor Monitor;
typedef struct {
/* Must keep these three elements in this order */
unsigned int type; /* XDGShell or X11* */
- struct wlr_box geom; /* layout-relative, includes border */
+ struct wlr_box geom; /* layout-relative, includes border */
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
@@ -118,14 +118,14 @@ typedef struct {
struct wl_listener destroy;
struct wl_listener set_title;
struct wl_listener fullscreen;
- struct wlr_box prev; /* layout-relative, includes border */
+ struct wlr_box prev; /* layout-relative, includes border */
#ifdef XWAYLAND
struct wl_listener activate;
struct wl_listener configure;
struct wl_listener set_hints;
#endif
unsigned int bw;
- unsigned int tags;
+ uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -189,9 +189,10 @@ struct Monitor {
unsigned int curtag, prevtag; /* current and previous tag */
Pertag *pertag;
unsigned int sellt;
- unsigned int tagset;
+ uint32_t tagset;
double mfact;
int nmaster;
+ char ltsymbol[16];
};
typedef struct {
@@ -207,7 +208,7 @@ typedef struct {
typedef struct {
const char *id;
const char *title;
- unsigned int tags;
+ uint32_t tags;
int isfloating;
int monitor;
int focus_client;
@@ -295,7 +296,7 @@ static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
-static void setmon(Client *c, Monitor *m, unsigned int newtags);
+static void setmon(Client *c, Monitor *m, uint32_t newtags);
static void setpsel(struct wl_listener *listener, void *data);
static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
@@ -416,14 +417,16 @@ static Atom netatom[NetLast];
#include "client.h"
struct Pertag {
- int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */
- float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */
- unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */
- const Layout *ltidxs[LENGTH(tags) + 1]; /* matrix of tags and layouts indexes */
+ 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]; /* matrix of tags and layouts indexes */
};
/* compile-time check if all tags fit into an unsigned int bit array. */
-struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+struct NumTags {
+ char limitexceeded[tagcount > 31 ? -1 : 1];
+};
/* function implementations */
void
@@ -435,8 +438,8 @@ applybounds(Client *c, struct wlr_box *bbox)
/* try to set size hints */
c->geom.width = MAX(min.width + (2 * (int)c->bw), c->geom.width);
c->geom.height = MAX(min.height + (2 * (int)c->bw), c->geom.height);
- /* Some clients set them max size to INT_MAX, which does not violates
- * the protocol but its innecesary, they can set them max size to zero. */
+ /* Some clients set their max size to INT_MAX, which does not violate the
+ * protocol but it's unnecesary, as they can set their max size to zero. */
if (max.width > 0 && !(2 * c->bw > INT_MAX - max.width)) /* Checks for overflow */
c->geom.width = MIN(max.width + (2 * c->bw), c->geom.width);
if (max.height > 0 && !(2 * c->bw > INT_MAX - max.height)) /* Checks for overflow */
@@ -458,7 +461,7 @@ applyrules(Client *c)
{
/* rule matching */
const char *appid, *title;
- unsigned int i, newtags = 0;
+ uint32_t i, newtags = 0;
const Rule *r;
Monitor *mon = selmon, *m;
bool fix_focus_at_end = false;
@@ -506,7 +509,8 @@ arrange(Monitor *m)
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
(c = focustop(m)) && c->isfullscreen);
-
+ if (m)
+ strncpy(m->ltsymbol, m->lt->symbol, LENGTH(m->ltsymbol));
if (m && m->lt->arrange)
m->lt->arrange(m);
motionnotify(0);
@@ -987,14 +991,14 @@ createmon(struct wl_listener *listener, void *data)
m->pertag = calloc(1, sizeof(Pertag));
m->curtag = m->prevtag = 1;
- for (i = 0; i <= LENGTH(tags); i++) {
+ for (i = 0; i <= tagcount; i++) {
m->pertag->nmasters[i] = m->nmaster;
m->pertag->mfacts[i] = m->mfact;
m->pertag->ltidxs[i] = m->lt;
- m->pertag->ltidxs[i] = m->lt;
m->pertag->sellts[i] = m->sellt;
}
+
/* Adds this to the output layout in the order it was configured in.
*
* The output layout utility automatically adds a wl_output global to the
@@ -1006,6 +1010,7 @@ createmon(struct wl_listener *listener, void *data)
wlr_output_layout_add_auto(output_layout, wlr_output);
else
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
+ strncpy(m->ltsymbol, m->lt->symbol, LENGTH(m->ltsymbol));
}
void
@@ -1056,7 +1061,7 @@ void
createpointer(struct wlr_pointer *pointer)
{
if (wlr_input_device_is_libinput(&pointer->base)) {
- struct libinput_device *libinput_device = (struct libinput_device*)
+ struct libinput_device *libinput_device = (struct libinput_device*)
wlr_libinput_get_device_handle(&pointer->base);
if (libinput_device_config_tap_get_finger_count(libinput_device)) {
@@ -1324,16 +1329,16 @@ focusstack(const Arg *arg)
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
if (&c->link == &clients)
- continue; /* wrap past the sentinel node */
+ continue; /* wrap past the sentinel node */
if (VISIBLEON(c, selmon))
- break; /* found it */
+ break; /* found it */
}
} else {
wl_list_for_each_reverse(c, &sel->link, link) {
if (&c->link == &clients)
- continue; /* wrap past the sentinel node */
+ continue; /* wrap past the sentinel node */
if (VISIBLEON(c, selmon))
- break; /* found it */
+ break; /* found it */
}
}
/* If only one client is visible on selmon, then c == sel */
@@ -1628,12 +1633,16 @@ void
monocle(Monitor *m)
{
Client *c;
+ int n = 0;
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
resize(c, m->w, 0);
+ n++;
}
+ if (n)
+ snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
if ((c = focustop(m)))
wlr_scene_node_raise_to_top(&c->scene->node);
}
@@ -1765,7 +1774,7 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
{
/*
* Called when a client such as wlr-randr requests a change in output
- * configuration. This is only one way that the layout can be changed,
+ * configuration. This is only one way that the layout can be changed,
* so any Monitor information should be updated by updatemons() after an
* output_layout.change event, not here.
*/
@@ -1856,7 +1865,7 @@ printstatus(void)
{
Monitor *m = NULL;
Client *c;
- unsigned int occ, urg, sel;
+ uint32_t occ, urg, sel;
const char *appid, *title;
wl_list_for_each(m, &mons, link) {
@@ -1887,7 +1896,7 @@ printstatus(void)
printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
printf("%s tags %u %u %u %u\n", m->wlr_output->name, occ, m->tagset,
sel, urg);
- printf("%s layout %s\n", m->wlr_output->name, m->lt->symbol);
+ printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol);
}
fflush(stdout);
}
@@ -2005,7 +2014,7 @@ run(char *startup_cmd)
selmon = xytomon(cursor->x, cursor->y);
/* TODO hack to get cursor to display in its initial location (100, 100)
- * instead of (0, 0) and then jumping. still may not be fully
+ * instead of (0, 0) and then jumping. still may not be fully
* initialized, as the image/coordinates are not transformed for the
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
@@ -2083,7 +2092,7 @@ setlayout(const Arg *arg)
selmon->sellt = selmon->pertag->sellts[selmon->curtag] ^= 1;
if (arg && arg->v)
selmon->lt = selmon->pertag->ltidxs[selmon->curtag] = (Layout *)arg->v;
- /* TODO change layout symbol? */
+ strncpy(selmon->ltsymbol, selmon->lt->symbol, LENGTH(selmon->ltsymbol));
arrange(selmon);
printstatus();
}
@@ -2104,7 +2113,7 @@ setmfact(const Arg *arg)
}
void
-setmon(Client *c, Monitor *m, unsigned int newtags)
+setmon(Client *c, Monitor *m, uint32_t newtags)
{
Monitor *oldmon = c->mon;
@@ -2455,7 +2464,7 @@ togglefullscreen(const Arg *arg)
void
toggletag(const Arg *arg)
{
- unsigned int newtags;
+ uint32_t newtags;
Client *sel = focustop(selmon);
if (!sel)
return;
@@ -2471,8 +2480,8 @@ toggletag(const Arg *arg)
void
toggleview(const Arg *arg)
{
- unsigned int newtagset = selmon ? selmon->tagset ^ (arg->ui & TAGMASK) : 0;
- size_t i;
+ uint32_t newtagset = selmon ? selmon->tagset ^ (arg->ui & TAGMASK) : 0;
+ uint32_t i;
if (newtagset) {
selmon->tagset = newtagset;
@@ -2494,7 +2503,6 @@ toggleview(const Arg *arg)
selmon->mfact = selmon->pertag->mfacts[selmon->curtag];
selmon->sellt = selmon->pertag->sellts[selmon->curtag];
selmon->lt = selmon->pertag->ltidxs[selmon->curtag];
- selmon->lt = selmon->pertag->ltidxs[selmon->curtag];
focusclient(focustop(selmon), 1);
arrange(selmon);
@@ -2559,7 +2567,7 @@ updatemons(struct wl_listener *listener, void *data)
{
/*
* Called whenever the output layout changes: adding or removing a
- * monitor, changing an output's mode or position, etc. This is where
+ * monitor, changing an output's mode or position, etc. This is where
* the change officially happens and we update geometry, window
* positions, focus, and the stored configuration in wlroots'
* output-manager implementation.
@@ -2849,8 +2857,8 @@ sigchld(int unused)
{
siginfo_t in;
/* We should be able to remove this function in favor of a simple
- * struct sigaction sa = {.sa_handler = SIG_IGN};
- * sigaction(SIGCHLD, &sa, NULL);
+ * struct sigaction sa = {.sa_handler = SIG_IGN};
+ * sigaction(SIGCHLD, &sa, NULL);
* but the Xwayland implementation in wlroots currently prevents us from
* setting our own disposition for SIGCHLD.
*/
@@ -2872,8 +2880,7 @@ xwaylandready(struct wl_listener *listener, void *data)
fprintf(stderr, "xcb_connect to X server failed with code %d\n. Continuing with degraded functionality.\n", err);
return;
}
-
- /* Collect atoms we are interested in. If getatom returns 0, we will
+ /* Collect atoms we are interested in. If getatom returns 0, we will
* not detect that window type. */
netatom[NetWMWindowTypeDialog] = getatom(xc, "_NET_WM_WINDOW_TYPE_DIALOG");
netatom[NetWMWindowTypeSplash] = getatom(xc, "_NET_WM_WINDOW_TYPE_SPLASH");