aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnor Nolen <andrey1gorbulin@gmail.com>2023-04-17 19:27:37 +0300
committerArnor Nolen <andrey1gorbulin@gmail.com>2023-04-17 19:27:37 +0300
commit0b23ae5d1e5c38eb8bf3fb1bf4d8e6896f40085f (patch)
treeebfef747d0e2f55fe6d12f10f17275254aec1d2c
parent7e70e4662bfd5add85478956f44aded23b098e50 (diff)
downloaddwlb-0b23ae5d1e5c38eb8bf3fb1bf4d8e6896f40085f.tar.gz
Scaling patch
-rw-r--r--config.def.h2
-rw-r--r--dwlb.c14
2 files changed, 13 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h
index 83d7481..f91787b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -14,6 +14,8 @@ static bool status_commands = true;
static bool center_title = false;
// use title space as status text element
static bool custom_title = false;
+// scale
+static uint32_t buffer_scale = 1;
// font
static char *fontstr = "monospace:size=16";
// tag names if ipc is disabled
diff --git a/dwlb.c b/dwlb.c
index 78acdb9..3785c72 100644
--- a/dwlb.c
+++ b/dwlb.c
@@ -190,7 +190,7 @@ static char **layouts;
static uint32_t layouts_l, layouts_c;
static struct fcft_font *font;
-static uint32_t height, textpadding;
+static uint32_t height, textpadding, buffer_scale;
static bool run_display;
@@ -465,6 +465,7 @@ draw_frame(Bar *bar)
munmap(data, bar->bufsize);
+ wl_surface_set_buffer_scale(bar->wl_surface, buffer_scale);
wl_surface_attach(bar->wl_surface, buffer, 0, 0);
wl_surface_damage_buffer(bar->wl_surface, 0, 0, bar->width, bar->height);
wl_surface_commit(bar->wl_surface);
@@ -477,6 +478,9 @@ static void
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
uint32_t serial, uint32_t w, uint32_t h)
{
+ w = w * buffer_scale;
+ h = h * buffer_scale;
+
zwlr_layer_surface_v1_ack_configure(surface, serial);
Bar *bar = (Bar *)data;
@@ -1719,10 +1723,14 @@ main(int argc, char **argv)
/* Load selected font */
fcft_init(FCFT_LOG_COLORIZE_AUTO, 0, FCFT_LOG_CLASS_ERROR);
fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
- if (!(font = fcft_from_name(1, (const char *[]) {fontstr}, NULL)))
+
+ unsigned int dpi = 96 * buffer_scale;
+ char buf[10];
+ snprintf(buf, sizeof buf, "dpi=%u", dpi);
+ if (!(font = fcft_from_name(1, (const char *[]) {fontstr}, buf)))
DIE("Could not load font");
textpadding = font->height / 2;
- height = font->height + vertical_padding * 2;
+ height = font->height / buffer_scale + vertical_padding * 2;
/* Configure tag names */
if (ipc && tags) {