From 12f04e3055ba1d8d4a362bdba0ed11fcfa07ff62 Mon Sep 17 00:00:00 2001 From: o9000 Date: Wed, 17 Jan 2018 04:13:01 +0000 Subject: [PATCH] Scale panel window size (issue #656) --- src/panel.c | 18 ++++++++++++++++++ src/panel.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/panel.c b/src/panel.c index 63d6f3c..2881caf 100644 --- a/src/panel.c +++ b/src/panel.c @@ -221,6 +221,11 @@ void init_panel() if (panel_config.monitor < 0) p->monitor = i; + if (ui_scale_dpi_ref > 0 && server.monitors[p->monitor].dpi > 0) + p->scale = server.monitors[p->monitor].dpi / ui_scale_dpi_ref; + else + p->scale = 1; + fprintf(stderr, "tint2: panel %d uses scale %f\n", i + 1, p->scale); if (!p->area.bg) p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p; @@ -358,6 +363,19 @@ void panel_compute_size(Panel *panel) } } + if (!panel->fractional_width) { + if (panel_horizontal) + panel->area.width *= panel->scale; + else + panel->area.height *= panel->scale; + } + if (!panel->fractional_height) { + if (panel_horizontal) + panel->area.height *= panel->scale; + else + panel->area.width *= panel->scale; + } + if (panel->area.width + panel->marginx > server.monitors[panel->monitor].width) panel->area.width = server.monitors[panel->monitor].width - panel->marginx; if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height) diff --git a/src/panel.h b/src/panel.h index 11a468e..009d070 100644 --- a/src/panel.h +++ b/src/panel.h @@ -118,6 +118,7 @@ typedef struct Panel { int mouse_pressed_alpha; int mouse_pressed_saturation; int mouse_pressed_brightness; + double scale; // Per-panel parameters and states for Taskbar and Task GlobalTaskbar g_taskbar;