diff --git a/src/config.c b/src/config.c index 15ab9e1..99eadb6 100644 --- a/src/config.c +++ b/src/config.c @@ -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, '%'))) { diff --git a/src/panel.c b/src/panel.c index 0c627d4..6489656 100644 --- a/src/panel.c +++ b/src/panel.c @@ -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; diff --git a/src/panel.h b/src/panel.h index 0b17985..1806940 100644 --- a/src/panel.h +++ b/src/panel.h @@ -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;