Scale panel window size (issue #656)

This commit is contained in:
o9000 2018-01-17 04:13:01 +00:00
parent 7f62594cf6
commit 12f04e3055
2 changed files with 19 additions and 0 deletions

View file

@ -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)

View file

@ -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;