bar: 2024-06-10; solves #53

This commit is contained in:
sewn 2024-06-10 16:35:41 +03:00
parent 5bf8944850
commit c70d13bb18
No known key found for this signature in database
2 changed files with 123 additions and 101 deletions

View File

@ -14,7 +14,7 @@ slstatus -s | dwl
### Download ### Download
- [git branch](https://codeberg.org/sewn/dwl/src/branch/bar) - [git branch](https://codeberg.org/sewn/dwl/src/branch/bar)
- [2024-05-28](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch) - [2024-06-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
Below is a preview of the patch. Below is a preview of the patch.

View File

@ -1,16 +1,16 @@
From a53e23e1fe72e46eac00c428360b7ce679eadb4b Mon Sep 17 00:00:00 2001 From ebe8a7aca8684c66da54abb50c630f4ad9cb233e Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org> From: sewn <sewn@disroot.org>
Date: Tue, 28 May 2024 13:25:00 +0300 Date: Mon, 10 Jun 2024 14:41:35 +0300
Subject: [PATCH] Implement dwm bar clone Subject: [PATCH] Implement dwm bar clone
--- ---
LICENSE.drwl | 22 +++ LICENSE.drwl | 22 +++
LICENSE.utf8dec | 25 ++++ LICENSE.utf8dec | 25 ++++
Makefile | 2 +- Makefile | 2 +-
config.def.h | 29 +++- config.def.h | 28 +++-
drwl.h | 142 +++++++++++++++++++ drwl.h | 142 ++++++++++++++++++
dwl.c | 364 ++++++++++++++++++++++++++++++++++++++---------- dwl.c | 380 ++++++++++++++++++++++++++++++++++++++----------
6 files changed, 503 insertions(+), 81 deletions(-) 6 files changed, 518 insertions(+), 81 deletions(-)
create mode 100644 LICENSE.drwl create mode 100644 LICENSE.drwl
create mode 100644 LICENSE.utf8dec create mode 100644 LICENSE.utf8dec
create mode 100644 drwl.h create mode 100644 drwl.h
@ -88,10 +88,10 @@ index a67fdd3..5578ae2 100644
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS) LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index 8847e58..0be3ad0 100644 index 8847e58..d0bb5bc 100644
--- a/config.def.h --- a/config.def.h
+++ b/config.def.h +++ b/config.def.h
@@ -7,15 +7,25 @@ @@ -7,15 +7,24 @@
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 unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
@ -107,7 +107,6 @@ index 8847e58..0be3ad0 100644
+static const int showbar = 1; /* 0 means no bar */ +static const int showbar = 1; /* 0 means no bar */
+static const int topbar = 1; /* 0 means bottom bar */ +static const int topbar = 1; /* 0 means bottom bar */
+static const char *fonts[] = {"monospace:size=10"}; +static const char *fonts[] = {"monospace:size=10"};
+static const char *fontattrs = "dpi=96";
+static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff }; +static pixman_color_t normbarfg = { 0xbbbb, 0xbbbb, 0xbbbb, 0xffff };
+static pixman_color_t normbarbg = { 0x2222, 0x2222, 0x2222, 0xffff }; +static pixman_color_t normbarbg = { 0x2222, 0x2222, 0x2222, 0xffff };
+static pixman_color_t selbarfg = { 0xeeee, 0xeeee, 0xeeee, 0xffff }; +static pixman_color_t selbarfg = { 0xeeee, 0xeeee, 0xeeee, 0xffff };
@ -119,7 +118,7 @@ index 8847e58..0be3ad0 100644
/* logging */ /* logging */
static int log_level = WLR_ERROR; static int log_level = WLR_ERROR;
@@ -122,6 +132,7 @@ static const Key keys[] = { @@ -122,6 +131,7 @@ static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
@ -127,7 +126,7 @@ index 8847e58..0be3ad0 100644
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
@@ -165,7 +176,15 @@ static const Key keys[] = { @@ -165,7 +175,15 @@ static const Key keys[] = {
}; };
static const Button buttons[] = { static const Button buttons[] = {
@ -295,7 +294,7 @@ index 0000000..613551e
+ return x + (render ? w : 0); + return x + (render ? w : 0);
+} +}
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index bf763df..0268772 100644 index bf763df..cd484bd 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
@ -334,7 +333,7 @@ index bf763df..0268772 100644
+#define TAGMASK ((1u << LENGTH(tags)) - 1) +#define TAGMASK ((1u << LENGTH(tags)) - 1)
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L))) #define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0) #define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
+#define TEXTW(text) (drwl_text(NULL, font, 0, 0, 0, 0, 0, text, NULL, NULL) + lrpad) +#define TEXTW(mon, text) (drwl_text(NULL, mon->font, 0, 0, 0, 0, 0, text, NULL, NULL) + mon->lrpad)
/* enums */ /* enums */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
@ -360,20 +359,26 @@ index bf763df..0268772 100644
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */ struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
struct wl_listener frame; struct wl_listener frame;
struct wl_listener destroy; struct wl_listener destroy;
@@ -195,6 +204,7 @@ struct Monitor { @@ -195,6 +204,11 @@ struct Monitor {
struct wl_listener destroy_lock_surface; struct wl_listener destroy_lock_surface;
struct wlr_session_lock_surface_v1 *lock_surface; struct wlr_session_lock_surface_v1 *lock_surface;
struct wlr_box m; /* monitor area, layout-relative */ struct wlr_box m; /* monitor area, layout-relative */
+ struct wlr_box b; /* bar area */ + struct {
+ int width, height;
+ int real_width, real_height; /* non-scaled */
+ float scale;
+ } b; /* bar area */
struct wlr_box w; /* window area, layout-relative */ struct wlr_box w; /* window area, layout-relative */
struct wl_list layers[4]; /* LayerSurface.link */ struct wl_list layers[4]; /* LayerSurface.link */
const Layout *lt[2]; const Layout *lt[2];
@@ -204,9 +214,16 @@ struct Monitor { @@ -204,9 +218,18 @@ struct Monitor {
float mfact; float mfact;
int gamma_lut_changed; int gamma_lut_changed;
int nmaster; int nmaster;
+ int showbar; + int showbar;
char ltsymbol[16]; char ltsymbol[16];
+ struct fcft_font *font;
+ int lrpad;
}; };
+typedef struct { +typedef struct {
@ -385,7 +390,7 @@ index bf763df..0268772 100644
typedef struct { typedef struct {
const char *name; const char *name;
float mfact; float mfact;
@@ -247,6 +264,10 @@ static void arrangelayer(Monitor *m, struct wl_list *list, @@ -247,6 +270,10 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive); struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m); static void arrangelayers(Monitor *m);
static void axisnotify(struct wl_listener *listener, void *data); static void axisnotify(struct wl_listener *listener, void *data);
@ -396,7 +401,7 @@ index bf763df..0268772 100644
static void buttonpress(struct wl_listener *listener, void *data); static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg); static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude); static void checkidleinhibitor(struct wlr_surface *exclude);
@@ -278,6 +299,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data); @@ -278,6 +305,8 @@ static void destroypointerconstraint(struct wl_listener *listener, void *data);
static void destroysessionlock(struct wl_listener *listener, void *data); static void destroysessionlock(struct wl_listener *listener, void *data);
static void destroysessionmgr(struct wl_listener *listener, void *data); static void destroysessionmgr(struct wl_listener *listener, void *data);
static Monitor *dirtomon(enum wlr_direction dir); static Monitor *dirtomon(enum wlr_direction dir);
@ -405,7 +410,7 @@ index bf763df..0268772 100644
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);
@@ -306,7 +329,6 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int @@ -306,7 +335,6 @@ static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int
static void outputmgrtest(struct wl_listener *listener, void *data); static void outputmgrtest(struct wl_listener *listener, void *data);
static void pointerfocus(Client *c, struct wlr_surface *surface, static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time); double sx, double sy, uint32_t time);
@ -413,7 +418,7 @@ index bf763df..0268772 100644
static void quit(const Arg *arg); static void quit(const Arg *arg);
static void rendermon(struct wl_listener *listener, void *data); static void rendermon(struct wl_listener *listener, void *data);
static void requestdecorationmode(struct wl_listener *listener, void *data); static void requestdecorationmode(struct wl_listener *listener, void *data);
@@ -327,9 +349,11 @@ static void setsel(struct wl_listener *listener, void *data); @@ -327,9 +355,11 @@ static void setsel(struct wl_listener *listener, void *data);
static void setup(void); static void setup(void);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void startdrag(struct wl_listener *listener, void *data); static void startdrag(struct wl_listener *listener, void *data);
@ -425,21 +430,18 @@ index bf763df..0268772 100644
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
@@ -338,6 +362,7 @@ static void unlocksession(struct wl_listener *listener, void *data); @@ -338,6 +368,7 @@ static void unlocksession(struct wl_listener *listener, void *data);
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data); static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
static void unmapnotify(struct wl_listener *listener, void *data); static void unmapnotify(struct wl_listener *listener, void *data);
static void updatemons(struct wl_listener *listener, void *data); static void updatemons(struct wl_listener *listener, void *data);
+static void updatebardims(Monitor *m); +static void updatebar(Monitor *m);
static void updatetitle(struct wl_listener *listener, void *data); static void updatetitle(struct wl_listener *listener, void *data);
static void urgent(struct wl_listener *listener, void *data); static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg); static void view(const Arg *arg);
@@ -405,6 +430,18 @@ static struct wlr_box sgeom; @@ -405,6 +436,15 @@ static struct wlr_box sgeom;
static struct wl_list mons; static struct wl_list mons;
static Monitor *selmon; static Monitor *selmon;
+static struct fcft_font *font;
+static int bh;
+static int lrpad;
+static char stext[256]; +static char stext[256];
+static struct wl_event_source *status_event_source; +static struct wl_event_source *status_event_source;
+ +
@ -452,19 +454,19 @@ index bf763df..0268772 100644
#ifdef XWAYLAND #ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data); static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data); static void associatex11(struct wl_listener *listener, void *data);
@@ -531,6 +568,11 @@ arrangelayers(Monitor *m) @@ -531,6 +571,11 @@ arrangelayers(Monitor *m)
if (!m->wlr_output->enabled) if (!m->wlr_output->enabled)
return; return;
+ if (m->showbar) { + if (m->showbar) {
+ usable_area.height -= m->b.height; + usable_area.height -= m->b.real_height;
+ usable_area.y += topbar ? m->b.height : 0; + usable_area.y += topbar ? m->b.real_height : 0;
+ } + }
+ +
/* Arrange exclusive surfaces from top->bottom */ /* Arrange exclusive surfaces from top->bottom */
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--)
arrangelayer(m, &m->layers[i], &usable_area, 1); arrangelayer(m, &m->layers[i], &usable_area, 1);
@@ -573,17 +615,77 @@ axisnotify(struct wl_listener *listener, void *data) @@ -573,17 +618,77 @@ axisnotify(struct wl_listener *listener, void *data)
event->delta_discrete, event->source); event->delta_discrete, event->source);
} }
@ -526,14 +528,14 @@ index bf763df..0268772 100644
+ (buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) { + (buffer = wlr_scene_buffer_from_node(node)) && buffer == selmon->scene_buffer) {
+ x = selmon->m.x; + x = selmon->m.x;
+ do + do
+ x += TEXTW(tags[i]); + x += TEXTW(selmon, tags[i]);
+ while (cursor->x >= x && ++i < LENGTH(tags)); + while (cursor->x >= x && ++i < LENGTH(tags));
+ if (i < LENGTH(tags)) { + if (i < LENGTH(tags)) {
+ click = ClkTagBar; + click = ClkTagBar;
+ arg.ui = 1 << i; + arg.ui = 1 << i;
+ } else if (cursor->x < x + TEXTW(selmon->ltsymbol)) + } else if (cursor->x < x + TEXTW(selmon, selmon->ltsymbol))
+ click = ClkLtSymbol; + click = ClkLtSymbol;
+ else if (cursor->x > selmon->w.width - (int)TEXTW(stext)) + else if (cursor->x > selmon->w.width - (int)TEXTW(selmon, stext))
+ click = ClkStatus; + click = ClkStatus;
+ else + else
+ click = ClkTitle; + click = ClkTitle;
@ -542,7 +544,7 @@ index bf763df..0268772 100644
switch (event->state) { switch (event->state) {
case WLR_BUTTON_PRESSED: case WLR_BUTTON_PRESSED:
cursor_mode = CurPressed; cursor_mode = CurPressed;
@@ -592,16 +694,14 @@ buttonpress(struct wl_listener *listener, void *data) @@ -592,16 +697,14 @@ buttonpress(struct wl_listener *listener, void *data)
break; break;
/* Change focus if the button was _pressed_ over a client */ /* Change focus if the button was _pressed_ over a client */
@ -562,17 +564,26 @@ index bf763df..0268772 100644
return; return;
} }
} }
@@ -675,6 +775,9 @@ cleanup(void) @@ -675,6 +778,9 @@ cleanup(void)
/* Destroy after the wayland display (when the monitors are already destroyed) /* Destroy after the wayland display (when the monitors are already destroyed)
to avoid destroying them with an invalid scene output. */ to avoid destroying them with an invalid scene output. */
wlr_scene_node_destroy(&scene->tree.node); wlr_scene_node_destroy(&scene->tree.node);
+ +
+ fcft_destroy(font); +
+ fcft_fini(); + fcft_fini();
} }
void void
@@ -726,7 +829,7 @@ closemon(Monitor *m) @@ -690,6 +796,8 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_layer_surface_v1_destroy(l->layer_surface);
}
+ fcft_destroy(m->font);
+
wl_list_remove(&m->destroy.link);
wl_list_remove(&m->frame.link);
wl_list_remove(&m->link);
@@ -726,7 +834,7 @@ closemon(Monitor *m)
setmon(c, selmon, c->tags); setmon(c, selmon, c->tags);
} }
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
@ -581,14 +592,14 @@ index bf763df..0268772 100644
} }
void void
@@ -912,8 +1015,13 @@ createmon(struct wl_listener *listener, void *data) @@ -912,8 +1020,13 @@ createmon(struct wl_listener *listener, void *data)
wlr_output_commit_state(wlr_output, &state); wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state); wlr_output_state_finish(&state);
+ m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL); + m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
+ m->scene_buffer->point_accepts_input = bar_accepts_input; + m->scene_buffer->point_accepts_input = bar_accepts_input;
+ m->showbar = showbar; + m->showbar = showbar;
+ updatebardims(m); + updatebar(m);
+ +
wl_list_insert(&mons, &m->link); wl_list_insert(&mons, &m->link);
- printstatus(); - printstatus();
@ -596,59 +607,58 @@ index bf763df..0268772 100644
/* The xdg-protocol specifies: /* The xdg-protocol specifies:
* *
@@ -1233,6 +1341,98 @@ dirtomon(enum wlr_direction dir) @@ -1233,6 +1346,99 @@ dirtomon(enum wlr_direction dir)
return selmon; return selmon;
} }
+void +void
+drawbar(Monitor *mon) +drawbar(Monitor *m)
+{ +{
+ int x, w, tw = 0; + int x, w, tw = 0;
+ int sel; + int sel;
+ int boxs = font->height / 9; + int boxs = m->font->height / 9;
+ int boxw = font->height / 6 + 2; + int boxw = m->font->height / 6 + 2;
+ uint32_t i, occ = 0, urg = 0; + uint32_t i, occ = 0, urg = 0;
+ uint32_t stride, size; + uint32_t stride, size;
+ pixman_image_t *pix; + pixman_image_t *pix;
+ Client *c; + Client *c;
+ Buffer *buf; + Buffer *buf;
+ +
+ if (!mon || !mon->showbar) + if (!m->showbar)
+ return; + return;
+ +
+ stride = mon->b.width * 4; + stride = m->b.width * 4;
+ size = stride * mon->b.height; + size = stride * m->b.height;
+ +
+ buf = ecalloc(1, sizeof(Buffer) + size); + buf = ecalloc(1, sizeof(Buffer) + size);
+ buf->stride = stride; + buf->stride = stride;
+ wlr_buffer_init(&buf->base, &buffer_impl, mon->b.width, mon->b.height); + wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height);
+ +
+ pix = pixman_image_create_bits( + pix = pixman_image_create_bits(
+ PIXMAN_a8r8g8b8, mon->b.width, mon->b.height, buf->data, stride); + PIXMAN_a8r8g8b8, m->b.width, m->b.height, buf->data, stride);
+ +
+ /* draw status first so it can be overdrawn by tags later */ + /* draw status first so it can be overdrawn by tags later */
+ if (mon == selmon) { + if (m == selmon) {
+ if (stext[0] == '\0') + if (stext[0] == '\0')
+ strncpy(stext, "dwl-"VERSION, sizeof(stext)); + strncpy(stext, "dwl-"VERSION, sizeof(stext));
+ tw = TEXTW(stext) - lrpad; + tw = TEXTW(m, stext) - m->lrpad;
+ drwl_text(pix, font, mon->b.width - tw, 0, tw, mon->b.height, 0, + drwl_text(pix, m->font, m->b.width - tw, 0, tw, m->b.height, 0,
+ stext, &normbarfg, &normbarbg); + stext, &normbarfg, &normbarbg);
+ } + }
+ +
+ wl_list_for_each(c, &clients, link) { + wl_list_for_each(c, &clients, link) {
+ if (c->mon != mon) + if (c->mon != m)
+ continue; + continue;
+ occ |= c->tags; + occ |= c->tags;
+ if (c->isurgent) + if (c->isurgent)
+ urg |= c->tags; + urg |= c->tags;
+ } + }
+ c = focustop(mon);
+ x = 0; + x = 0;
+ for (i = 0; i < LENGTH(tags); i++) { + for (i = 0; i < LENGTH(tags); i++) {
+ w = TEXTW(tags[i]); + w = TEXTW(m, tags[i]);
+ sel = mon->tagset[mon->seltags] & 1 << i; + sel = m->tagset[m->seltags] & 1 << i;
+ +
+ drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2, tags[i], + drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2, tags[i],
+ urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg), + urg & 1 << i ? &selbarbg : (sel ? &selbarfg : &normbarfg),
+ urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg)); + urg & 1 << i ? &selbarfg : (sel ? &selbarbg : &normbarbg));
+ +
@ -659,27 +669,29 @@ index bf763df..0268772 100644
+ x += w; + x += w;
+ } + }
+ +
+ w = TEXTW(mon->ltsymbol); + w = TEXTW(m, m->ltsymbol);
+ x = drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2, + x = drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2,
+ mon->ltsymbol, &normbarfg, &normbarbg); + m->ltsymbol, &normbarfg, &normbarbg);
+ +
+ if ((w = mon->b.width - tw - x) > mon->b.height) { + if ((w = m->b.width - tw - x) > m->b.height) {
+ if (c != NULL) { + if ((c = focustop(m)) != NULL) {
+ drwl_text(pix, font, x, 0, w, mon->b.height, lrpad / 2, + drwl_text(pix, m->font, x, 0, w, m->b.height, m->lrpad / 2,
+ client_get_title(c), + client_get_title(c),
+ mon == selmon ? &selbarfg : &normbarfg, + m == selmon ? &selbarfg : &normbarfg,
+ (mon == selmon && c) ? &selbarbg : &normbarbg); + (m == selmon && c) ? &selbarbg : &normbarbg);
+ if (c && c->isfloating) + if (c && c->isfloating)
+ drwl_rect(pix, x + boxs, boxs, boxw, boxw, 0, + drwl_rect(pix, x + boxs, boxs, boxw, boxw, 0,
+ mon == selmon ? &selbarfg : &normbarfg); + m == selmon ? &selbarfg : &normbarfg);
+ } else + } else
+ drwl_rect(pix, x, 0, w, mon->b.height, 1, &normbarbg); + drwl_rect(pix, x, 0, w, m->b.height, 1, &normbarbg);
+ } + }
+ +
+ pixman_image_unref(pix); + pixman_image_unref(pix);
+ wlr_scene_node_set_position(&mon->scene_buffer->node, mon->m.x, + wlr_scene_buffer_set_dest_size(m->scene_buffer,
+ mon->m.y + (topbar ? 0 : mon->m.height - mon->b.height)); + m->b.real_width, m->b.real_height);
+ wlr_scene_buffer_set_buffer(mon->scene_buffer, &buf->base); + wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
+ m->m.y + (topbar ? 0 : m->m.height - m->b.real_height));
+ wlr_scene_buffer_set_buffer(m->scene_buffer, &buf->base);
+ wlr_buffer_drop(&buf->base); + wlr_buffer_drop(&buf->base);
+} +}
+ +
@ -695,7 +707,7 @@ index bf763df..0268772 100644
void void
focusclient(Client *c, int lift) focusclient(Client *c, int lift)
{ {
@@ -1290,7 +1490,7 @@ focusclient(Client *c, int lift) @@ -1290,7 +1496,7 @@ focusclient(Client *c, int lift)
client_activate_surface(old, 0); client_activate_surface(old, 0);
} }
} }
@ -704,7 +716,7 @@ index bf763df..0268772 100644
if (!c) { if (!c) {
/* With no client, all we have left is to clear focus */ /* With no client, all we have left is to clear focus */
@@ -1618,7 +1818,7 @@ mapnotify(struct wl_listener *listener, void *data) @@ -1618,7 +1824,7 @@ mapnotify(struct wl_listener *listener, void *data)
} else { } else {
applyrules(c); applyrules(c);
} }
@ -713,7 +725,7 @@ index bf763df..0268772 100644
unset_fullscreen: unset_fullscreen:
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y); m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
@@ -1904,46 +2104,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, @@ -1904,46 +2110,6 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
wlr_seat_pointer_notify_motion(seat, time, sx, sy); wlr_seat_pointer_notify_motion(seat, time, sx, sy);
} }
@ -760,7 +772,7 @@ index bf763df..0268772 100644
void void
quit(const Arg *arg) quit(const Arg *arg)
@@ -2074,23 +2234,14 @@ run(char *startup_cmd) @@ -2074,23 +2240,14 @@ run(char *startup_cmd)
/* Now that the socket exists and the backend is started, run the startup command */ /* Now that the socket exists and the backend is started, run the startup command */
if (startup_cmd) { if (startup_cmd) {
@ -785,7 +797,7 @@ index bf763df..0268772 100644
/* At this point the outputs are initialized, choose initial selmon based on /* At this point the outputs are initialized, choose initial selmon based on
* cursor position, and set default cursor image */ * cursor position, and set default cursor image */
@@ -2155,7 +2306,7 @@ setfloating(Client *c, int floating) @@ -2155,7 +2312,7 @@ setfloating(Client *c, int floating)
(p && p->isfullscreen) ? LyrFS (p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]); : c->isfloating ? LyrFloat : LyrTile]);
arrange(c->mon); arrange(c->mon);
@ -794,7 +806,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2178,7 +2329,7 @@ setfullscreen(Client *c, int fullscreen) @@ -2178,7 +2335,7 @@ setfullscreen(Client *c, int fullscreen)
resize(c, c->prev, 0); resize(c, c->prev, 0);
} }
arrange(c->mon); arrange(c->mon);
@ -803,7 +815,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2203,7 +2354,7 @@ setlayout(const Arg *arg) @@ -2203,7 +2360,7 @@ setlayout(const Arg *arg)
selmon->lt[selmon->sellt] = (Layout *)arg->v; selmon->lt[selmon->sellt] = (Layout *)arg->v;
strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol)); strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, LENGTH(selmon->ltsymbol));
arrange(selmon); arrange(selmon);
@ -812,17 +824,12 @@ index bf763df..0268772 100644
} }
/* arg > 1.0 will set mfact absolutely */ /* arg > 1.0 will set mfact absolutely */
@@ -2506,6 +2657,17 @@ setup(void) @@ -2506,6 +2663,12 @@ setup(void)
wlr_scene_set_presentation(scene, wlr_presentation_create(dpy, backend)); wlr_scene_set_presentation(scene, wlr_presentation_create(dpy, backend));
+ fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR); + fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR);
+ fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3); + fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
+ if (!(font = fcft_from_name(LENGTH(fonts), fonts, fontattrs)))
+ die("Could not load font");
+
+ lrpad = font->height;
+ bh = font->height + 2;
+ +
+ status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy), + status_event_source = wl_event_loop_add_fd(wl_display_get_event_loop(dpy),
+ STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL); + STDIN_FILENO, WL_EVENT_READABLE, status_in, NULL);
@ -830,7 +837,7 @@ index bf763df..0268772 100644
/* Make sure XWayland clients don't connect to the parent X server, /* Make sure XWayland clients don't connect to the parent X server,
* e.g when running in the x11 backend or the wayland backend and the * e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */ * compositor has Xwayland support */
@@ -2530,6 +2692,7 @@ void @@ -2530,6 +2693,7 @@ void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
if (fork() == 0) { if (fork() == 0) {
@ -838,7 +845,7 @@ index bf763df..0268772 100644
dup2(STDERR_FILENO, STDOUT_FILENO); dup2(STDERR_FILENO, STDOUT_FILENO);
setsid(); setsid();
execvp(((char **)arg->v)[0], (char **)arg->v); execvp(((char **)arg->v)[0], (char **)arg->v);
@@ -2548,6 +2711,30 @@ startdrag(struct wl_listener *listener, void *data) @@ -2548,6 +2712,30 @@ startdrag(struct wl_listener *listener, void *data)
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon); LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
} }
@ -869,7 +876,7 @@ index bf763df..0268772 100644
void void
tag(const Arg *arg) tag(const Arg *arg)
{ {
@@ -2558,7 +2745,7 @@ tag(const Arg *arg) @@ -2558,7 +2746,7 @@ tag(const Arg *arg)
sel->tags = arg->ui & TAGMASK; sel->tags = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
@ -878,7 +885,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2603,6 +2790,14 @@ tile(Monitor *m) @@ -2603,6 +2791,14 @@ tile(Monitor *m)
} }
} }
@ -893,7 +900,7 @@ index bf763df..0268772 100644
void void
togglefloating(const Arg *arg) togglefloating(const Arg *arg)
{ {
@@ -2631,7 +2826,7 @@ toggletag(const Arg *arg) @@ -2631,7 +2827,7 @@ toggletag(const Arg *arg)
sel->tags = newtags; sel->tags = newtags;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
@ -902,7 +909,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2644,7 +2839,7 @@ toggleview(const Arg *arg) @@ -2644,7 +2840,7 @@ toggleview(const Arg *arg)
selmon->tagset[selmon->seltags] = newtagset; selmon->tagset[selmon->seltags] = newtagset;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
@ -911,7 +918,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2692,7 +2887,7 @@ unmapnotify(struct wl_listener *listener, void *data) @@ -2692,7 +2888,7 @@ unmapnotify(struct wl_listener *listener, void *data)
} }
wlr_scene_node_destroy(&c->scene->node); wlr_scene_node_destroy(&c->scene->node);
@ -920,30 +927,45 @@ index bf763df..0268772 100644
motionnotify(0, NULL, 0, 0, 0, 0); motionnotify(0, NULL, 0, 0, 0, 0);
} }
@@ -2788,6 +2983,12 @@ updatemons(struct wl_listener *listener, void *data) @@ -2788,6 +2984,12 @@ updatemons(struct wl_listener *listener, void *data)
} }
} }
+ /* Update bar */ + /* Update bar */
+ wl_list_for_each(m, &mons, link) { + wl_list_for_each(m, &mons, link) {
+ updatebardims(m); + updatebar(m);
+ drawbar(m); + drawbar(m);
+ } + }
+ +
/* FIXME: figure out why the cursor image is at 0,0 after turning all /* FIXME: figure out why the cursor image is at 0,0 after turning all
* the monitors on. * the monitors on.
* Move the cursor image where it used to be. It does not generate a * Move the cursor image where it used to be. It does not generate a
@@ -2798,12 +2999,21 @@ updatemons(struct wl_listener *listener, void *data) @@ -2798,12 +3000,36 @@ updatemons(struct wl_listener *listener, void *data)
wlr_output_manager_v1_set_configuration(output_mgr, config); wlr_output_manager_v1_set_configuration(output_mgr, config);
} }
+void +void
+updatebardims(Monitor *m) +updatebar(Monitor *m)
+{ +{
+ int rw, rh; + int rw, rh;
+ wlr_output_effective_resolution(m->wlr_output, &rw, &rh); + char fontattrs[12];
+
+ wlr_output_transformed_resolution(m->wlr_output, &rw, &rh);
+ m->b.width = rw; + m->b.width = rw;
+ m->b.height = bh; + m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
+
+ if (m->b.scale == m->wlr_output->scale && m->font)
+ return;
+
+ fcft_destroy(m->font);
+ snprintf(fontattrs, sizeof(fontattrs), "dpi=%.2f", 96. * m->wlr_output->scale);
+ if (!(m->font = fcft_from_name(LENGTH(fonts), fonts, fontattrs)))
+ die("Could not load font");
+
+ m->b.scale = m->wlr_output->scale;
+ m->lrpad = m->font->height;
+ m->b.height = m->font->height + 2;
+ m->b.real_height = (int)((float)m->b.height / m->wlr_output->scale);
+} +}
+ +
void void
@ -956,7 +978,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2816,7 +3026,7 @@ urgent(struct wl_listener *listener, void *data) @@ -2816,7 +3042,7 @@ urgent(struct wl_listener *listener, void *data)
return; return;
c->isurgent = 1; c->isurgent = 1;
@ -965,7 +987,7 @@ index bf763df..0268772 100644
if (client_surface(c)->mapped) if (client_surface(c)->mapped)
client_set_border_color(c, urgentcolor); client_set_border_color(c, urgentcolor);
@@ -2832,7 +3042,7 @@ view(const Arg *arg) @@ -2832,7 +3058,7 @@ view(const Arg *arg)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
focusclient(focustop(selmon), 1); focusclient(focustop(selmon), 1);
arrange(selmon); arrange(selmon);
@ -974,7 +996,7 @@ index bf763df..0268772 100644
} }
void void
@@ -2871,6 +3081,7 @@ xytonode(double x, double y, struct wlr_surface **psurface, @@ -2871,6 +3097,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
{ {
struct wlr_scene_node *node, *pnode; struct wlr_scene_node *node, *pnode;
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
@ -982,7 +1004,7 @@ index bf763df..0268772 100644
Client *c = NULL; Client *c = NULL;
LayerSurface *l = NULL; LayerSurface *l = NULL;
int layer; int layer;
@@ -2879,9 +3090,12 @@ xytonode(double x, double y, struct wlr_surface **psurface, @@ -2879,9 +3106,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny))) if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
continue; continue;
@ -998,7 +1020,7 @@ index bf763df..0268772 100644
/* Walk the tree to find a node that knows the client */ /* Walk the tree to find a node that knows the client */
for (pnode = node; pnode && !c; pnode = &pnode->parent->node) for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
c = pnode->data; c = pnode->data;
@@ -3020,7 +3234,7 @@ sethints(struct wl_listener *listener, void *data) @@ -3020,7 +3250,7 @@ sethints(struct wl_listener *listener, void *data)
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);