panel: Compute fractional width after reserving the margin, not before (issue #559)
This commit is contained in:
parent
7b6ce97940
commit
9150a180fa
3 changed files with 12 additions and 12 deletions
|
@ -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, '%'))) {
|
||||
|
|
18
src/panel.c
18
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue