Commit 9150a180 authored by o9000's avatar o9000

panel: Compute fractional width after reserving the margin, not before (issue #559)

parent 7b6ce979
......@@ -304,13 +304,13 @@ void add_entry(char *key, char *value)
char *b;
if ((b = strchr(value1, '%'))) {
b[0] = '\0';
panel_config.fractional_width = 1;
panel_config.fractional_width = TRUE;
}
panel_config.area.width = atoi(value1);
if (panel_config.area.width == 0) {
// full width mode
panel_config.area.width = 100;
panel_config.fractional_width = 1;
panel_config.fractional_width = TRUE;
}
if (value2) {
if ((b = strchr(value2, '%'))) {
......
......@@ -287,11 +287,9 @@ void init_panel_size_and_position(Panel *panel)
panel->area.height = 32;
}
if (panel->fractional_width)
panel->area.width = server.monitors[panel->monitor].width * panel->area.width / 100;
panel->area.width = (server.monitors[panel->monitor].width - panel->marginx) * panel->area.width / 100;
if (panel->fractional_height)
panel->area.height = server.monitors[panel->monitor].height * panel->area.height / 100;
if (panel->area.width + panel->marginx > server.monitors[panel->monitor].width)
panel->area.width = server.monitors[panel->monitor].width - panel->marginx;
panel->area.height = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.height / 100;
if (panel->area.bg->border.radius > panel->area.height / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
g_array_append_val(backgrounds, *panel->area.bg);
......@@ -309,18 +307,15 @@ void init_panel_size_and_position(Panel *panel)
}
int old_panel_height = panel->area.height;
if (panel->fractional_width)
panel->area.height = server.monitors[panel->monitor].height * panel->area.width / 100;
panel->area.height = (server.monitors[panel->monitor].height - panel->marginy) * panel->area.width / 100;
else
panel->area.height = panel->area.width;
if (panel->fractional_height)
panel->area.width = server.monitors[panel->monitor].width * old_panel_height / 100;
panel->area.width = (server.monitors[panel->monitor].width - panel->marginx) * old_panel_height / 100;
else
panel->area.width = old_panel_height;
if (panel->area.height + panel->marginy > server.monitors[panel->monitor].height)
panel->area.height = server.monitors[panel->monitor].height - panel->marginy;
if (panel->area.bg->border.radius > panel->area.width / 2) {
printf("panel_background_id rounded is too big... please fix your tint2rc\n");
g_array_append_val(backgrounds, *panel->area.bg);
......@@ -329,6 +324,11 @@ void init_panel_size_and_position(Panel *panel)
}
}
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)
panel->area.height = server.monitors[panel->monitor].height - panel->marginy;
// panel position determined here
if (panel_position & LEFT) {
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
......
......@@ -96,7 +96,7 @@ typedef struct Panel {
// position relative to root window
int posx, posy;
int marginx, marginy;
int fractional_width, fractional_height;
gboolean fractional_width, fractional_height;
int monitor;
int font_shadow;
gboolean mouse_effects;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment