Commit ed802d76 authored by o9000's avatar o9000

Compute layouts correctly with partial borders (issue #580)

parent 77d2a748
......@@ -158,8 +158,8 @@ void init_battery_panel(void *p)
battery->area.on_screen = TRUE;
battery->area.resize_needed = 1;
battery->area.has_mouse_over_effect =
panel_config.mouse_effects && (battery_lclick_command || battery_mclick_command || battery_rclick_command ||
battery_uwheel_command || battery_dwheel_command);
panel_config.mouse_effects && (battery_lclick_command || battery_mclick_command || battery_rclick_command ||
battery_uwheel_command || battery_dwheel_command);
battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect;
if (battery_tooltip_enabled)
battery->area._get_tooltip_text = battery_get_tooltip;
......@@ -227,12 +227,12 @@ void update_battery_tick(void *arg)
}
if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING &&
!battery_low_cmd_sent) {
!battery_low_cmd_sent) {
tint_exec(battery_low_cmd);
battery_low_cmd_sent = TRUE;
}
if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING &&
battery_low_cmd_sent) {
battery_low_cmd_sent) {
battery_low_cmd_sent = FALSE;
}
......@@ -259,7 +259,7 @@ void update_battery_tick(void *arg)
// Redraw if needed
if (panels[i].battery.area.on_screen) {
if (old_found != battery_found || old_percentage != battery_state.percentage ||
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
panels[i].battery.area.resize_needed = TRUE;
panel_refresh = TRUE;
}
......@@ -302,31 +302,31 @@ gboolean resize_battery(void *obj)
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
}
get_text_size2(bat1_font_desc,
&bat_percentage_height_ink,
&bat_percentage_height,
&bat_percentage_width,
panel->area.height,
panel->area.width,
buf_bat_percentage,
strlen(buf_bat_percentage),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
&bat_percentage_height_ink,
&bat_percentage_height,
&bat_percentage_width,
panel->area.height,
panel->area.width,
buf_bat_percentage,
strlen(buf_bat_percentage),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
get_text_size2(bat2_font_desc,
&bat_time_height_ink,
&bat_time_height,
&bat_time_width,
panel->area.height,
panel->area.width,
buf_bat_time,
strlen(buf_bat_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
&bat_time_height_ink,
&bat_time_height,
&bat_time_width,
panel->area.height,
panel->area.width,
buf_bat_time,
strlen(buf_bat_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
if (panel_horizontal) {
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
new_size += 2 * battery->area.paddingxlr + 2 * battery->area.bg->border.width;
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
if (new_size > battery->area.width || new_size < battery->area.width - 2) {
// we try to limit the number of resize
battery->area.width = new_size;
......@@ -335,8 +335,8 @@ gboolean resize_battery(void *obj)
ret = 1;
}
} else {
int new_size =
bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
top_bottom_border_width(&battery->area);
if (new_size > battery->area.height || new_size < battery->area.height - 2) {
battery->area.height = new_size;
battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2;
......
......@@ -276,7 +276,7 @@ gboolean resize_clock(void *obj)
if (panel_horizontal) {
int new_size = (time_width > date_width) ? time_width : date_width;
new_size += (2 * clock->area.paddingxlr) + (2 * clock->area.bg->border.width);
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
// we try to limit the number of resizes
clock->area.width = new_size + 1;
......@@ -288,7 +288,7 @@ gboolean resize_clock(void *obj)
result = TRUE;
}
} else {
int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width));
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
if (new_size != clock->area.height) {
// we try to limit the number of resizes
clock->area.height = new_size;
......
......@@ -322,8 +322,8 @@ gboolean resize_execp(void *obj)
panel->area.height,
!text_next_line
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) -
2 * (horiz_padding + execp->area.bg->border.width)
: execp->area.width - 2 * (horiz_padding + execp->area.bg->border.width),
2 * horiz_padding - left_right_border_width(&execp->area)
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
execp->backend->text,
strlen(execp->backend->text),
PANGO_WRAP_WORD_CHAR,
......@@ -336,7 +336,7 @@ gboolean resize_execp(void *obj)
int new_size = txt_width;
if (icon_w)
new_size += interior_padding + icon_w;
new_size += 2 * (horiz_padding + execp->area.bg->border.width);
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
if (new_size > execp->area.width || new_size < (execp->area.width - 6)) {
// we try to limit the number of resize
execp->area.width = new_size + 1;
......@@ -345,12 +345,10 @@ gboolean resize_execp(void *obj)
} else {
int new_size;
if (!text_next_line) {
new_size = txt_height + (2 * (vert_padding + execp->area.bg->border.width));
if (new_size < icon_h + (2 * (vert_padding + execp->area.bg->border.width))) {
new_size = icon_h + (2 * (vert_padding + execp->area.bg->border.width));
}
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
} else {
new_size = icon_h + interior_padding + txt_height + (2 * (vert_padding + execp->area.bg->border.width));
new_size = icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
}
if (new_size != execp->area.height) {
execp->area.height = new_size;
......@@ -380,18 +378,18 @@ gboolean resize_execp(void *obj)
if (icon_w) {
if (!text_next_line) {
execp->frontend->icony = (execp->area.height - icon_h) / 2;
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
execp->frontend->texty = (execp->area.height - txt_height) / 2;
execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding;
} else {
execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2;
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding;
execp->frontend->textx = execp->frontend->iconx;
}
} else {
execp->frontend->texty = (execp->area.height - txt_height) / 2;
execp->frontend->textx = execp->area.bg->border.width + horiz_padding;
execp->frontend->textx = left_border_width(&execp->area) + horiz_padding;
}
}
......
......@@ -57,15 +57,15 @@ int freespace_get_max_size(Panel *p)
continue;
if (panel_horizontal)
size += a->width + (a->bg->border.width * 2) + p->area.paddingx;
size += a->width + p->area.paddingx;
else
size += a->height + (a->bg->border.width * 2) + p->area.paddingy;
size += a->height + p->area.paddingy;
}
if (panel_horizontal)
size = p->area.width - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr;
else
size = p->area.height - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr;
return size;
}
......
......@@ -163,7 +163,8 @@ gboolean resize_launcher(void *obj)
} else {
icon_size = launcher->area.width;
}
icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy);
icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) -
(2 * launcher->area.paddingy);
if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
icon_size = launcher_max_icon_size;
......@@ -177,7 +178,7 @@ gboolean resize_launcher(void *obj)
// Get the path for an icon file with the new size
char *new_icon_path =
get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size);
get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size);
if (!new_icon_path) {
// Draw a blank icon
free_icon(launcherIcon->image);
......@@ -217,13 +218,13 @@ gboolean resize_launcher(void *obj)
if (panel_config.mouse_effects) {
launcherIcon->image_hover = adjust_icon(launcherIcon->image,
panel_config.mouse_over_alpha,
panel_config.mouse_over_saturation,
panel_config.mouse_over_brightness);
panel_config.mouse_over_alpha,
panel_config.mouse_over_saturation,
panel_config.mouse_over_brightness);
launcherIcon->image_pressed = adjust_icon(launcherIcon->image,
panel_config.mouse_pressed_alpha,
panel_config.mouse_pressed_saturation,
panel_config.mouse_pressed_brightness);
panel_config.mouse_pressed_alpha,
panel_config.mouse_pressed_saturation,
panel_config.mouse_pressed_brightness);
}
}
save_icon_cache(launcher->icon_theme_wrapper);
......@@ -234,36 +235,36 @@ gboolean resize_launcher(void *obj)
if (!count) {
launcher->area.width = 0;
} else {
int height = launcher->area.height - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_column always higher than 0
icons_per_column = (height + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = height - (icons_per_column - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_row = count / icons_per_column + (count % icons_per_column != 0);
launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
launcher->area.width = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
}
} else {
if (!count) {
launcher->area.height = 0;
} else {
int width = launcher->area.width - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_row always higher than 0
icons_per_row = (width + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = width - (icons_per_row - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_column = count / icons_per_row + (count % icons_per_row != 0);
launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
launcher->area.height = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
}
}
int posx, posy;
int start = launcher->area.bg->border.width + launcher->area.paddingy + margin / 2;
int start;
if (panel_horizontal) {
posy = start;
posx = launcher->area.bg->border.width + launcher->area.paddingxlr;
posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
posx = left_border_width(&launcher->area) + launcher->area.paddingxlr;
} else {
posx = start;
posy = launcher->area.bg->border.width + launcher->area.paddingxlr;
posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
posy = top_border_width(&launcher->area) + launcher->area.paddingxlr;
}
int i;
......@@ -351,21 +352,21 @@ Imlib_Image scale_icon(Imlib_Image original, int icon_size)
if (original) {
imlib_context_set_image(original);
icon_scaled = imlib_create_cropped_scaled_image(0,
0,
imlib_image_get_width(),
imlib_image_get_height(),
icon_size,
icon_size);
0,
imlib_image_get_width(),
imlib_image_get_height(),
icon_size,
icon_size);
imlib_context_set_image(icon_scaled);
imlib_image_set_has_alpha(1);
DATA32 *data = imlib_image_get_data();
adjust_asb(data,
icon_size,
icon_size,
launcher_alpha / 100.0,
launcher_saturation / 100.0,
launcher_brightness / 100.0);
icon_size,
icon_size,
launcher_alpha / 100.0,
launcher_saturation / 100.0,
launcher_brightness / 100.0);
imlib_image_put_back_data(data);
imlib_context_set_image(icon_scaled);
......@@ -453,7 +454,10 @@ void launcher_load_icons(Launcher *launcher)
if (entry.exec) {
LauncherIcon *launcherIcon = calloc(1, sizeof(LauncherIcon));
launcherIcon->area.panel = launcher->area.panel;
snprintf(launcherIcon->area.name, sizeof(launcherIcon->area.name), "LauncherIcon %s", entry.name ? entry.name : "null");
snprintf(launcherIcon->area.name,
sizeof(launcherIcon->area.name),
"LauncherIcon %s",
entry.name ? entry.name : "null");
launcherIcon->area._draw_foreground = draw_launcher_icon;
launcherIcon->area.size_mode = LAYOUT_FIXED;
launcherIcon->area._resize = NULL;
......
This diff is collapsed.
This diff is collapsed.
......@@ -369,7 +369,7 @@ void draw_task_icon(Task *task, int text_width)
else
pos_x = (task->area.width - panel->g_task.icon_size1) / 2;
} else {
pos_x = task->area.bg->border.width + task->area.paddingxlr;
pos_x = left_border_width(&task->area) + task->area.paddingxlr;
}
// Render
......@@ -393,7 +393,7 @@ void draw_task_icon(Task *task, int text_width)
fprintf(stderr, "Task icon size: %d %d pos %d %d\n", imlib_image_get_width(), imlib_image_get_height(), pos_x, panel->g_task.icon_posy);
fprintf(stderr, "Task max size : %d %d\n", panel->g_task.maximum_width, panel->g_task.maximum_height);
fprintf(stderr, "Task area size: %d %d\n", task->area.width, task->area.height);
fprintf(stderr, "Task border : %d\n", task->area.bg->border.width);
fprintf(stderr, "Task border : %d\n", left_border_width(&task->area));
fprintf(stderr, "\n");
}
}
......
......@@ -167,13 +167,15 @@ void init_taskbar_panel(void *p)
panel->g_taskbar.area.resize_needed = 1;
panel->g_taskbar.area.on_screen = TRUE;
if (panel_horizontal) {
panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy;
panel->g_taskbar.area.height =
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy;
panel->g_taskbar.area_name.height = panel->g_taskbar.area.height;
} else {
panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy;
panel->g_taskbar.area.width =
panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx;
panel->g_taskbar.area_name.width = panel->g_taskbar.area.width;
}
......@@ -230,15 +232,19 @@ void init_taskbar_panel(void *p)
if (panel_horizontal) {
panel->g_task.area.posy = panel->g_taskbar.area.posy +
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
panel->g_taskbar.area.paddingy;
top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->g_task.maximum_width;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
panel->g_task.area.height = panel->g_taskbar.area.height -
top_bottom_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
2 * panel->g_taskbar.area.paddingy;
} else {
panel->g_task.area.posx = panel->g_taskbar.area.posx +
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->g_taskbar.area.width -
left_right_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
2 * panel->g_taskbar.area.paddingy;
panel->g_task.area.height = panel->g_task.maximum_height;
}
......@@ -247,7 +253,7 @@ void init_taskbar_panel(void *p)
panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0);
if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) {
printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
g_array_append_val(backgrounds, *panel->g_task.background[j]);
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1);
panel->g_task.background[j]->border.radius = panel->g_task.area.height / 2;
......@@ -257,36 +263,36 @@ void init_taskbar_panel(void *p)
// compute vertical position : text and icon
int height_ink, height, width;
get_text_size2(panel->g_task.font_desc,
&height_ink,
&height,
&width,
panel->area.height,
panel->area.width,
"TAjpg",
5,
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_END,
FALSE);
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
&height_ink,
&height,
&width,
panel->area.height,
panel->area.width,
"TAjpg",
5,
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_END,
FALSE);
panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
if (panel->g_task.has_icon) {
panel->g_task.icon_size1 =
MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
(2 * panel->g_task.area.paddingy) - 2 * panel->g_task.area.bg->border.width;
panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
2 * panel->g_task.area.paddingy - MAX(left_right_border_width(&panel->g_task.area),
top_bottom_border_width(&panel->g_task.area));
panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx;
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
if (0)
printf("task: icon_size = %d, textx = %f, texth = %f, icony = %d, w = %d, h = %d, maxw = %d, maxh = %d\n",
panel->g_task.icon_size1,
panel->g_task.text_posx,
panel->g_task.text_height,
panel->g_task.icon_posy,
panel->g_task.area.width,
panel->g_task.area.height,
panel->g_task.maximum_width,
panel->g_task.maximum_height);
panel->g_task.icon_size1,
panel->g_task.text_posx,
panel->g_task.text_height,
panel->g_task.icon_posy,
panel->g_task.area.width,
panel->g_task.area.height,
panel->g_task.maximum_width,
panel->g_task.maximum_height);
}
Taskbar *taskbar;
......@@ -413,13 +419,13 @@ gboolean resize_taskbar(void *obj)
break;
}
}
taskbar->text_width =
text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) -
panel->g_task.area.paddingxlr;
} else {
relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height);
taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx -
panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr;
}
return FALSE;
}
......@@ -442,7 +448,7 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
schedule_redraw(&taskbar->bar_name.area);
}
if (taskbar_mode == MULTI_DESKTOP &&
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
GList *l = taskbar->area.children;
if (taskbarname_enabled)
l = l->next;
......@@ -486,7 +492,7 @@ gint compare_tasks_trivial(Task *a, Task *b, Taskbar *taskbar)
gboolean contained_within(Task *a, Task *b)
{
if ((a->win_x <= b->win_x) && (a->win_y <= b->win_y) && (a->win_x + a->win_w >= b->win_x + b->win_w) &&
(a->win_y + a->win_h >= b->win_y + b->win_h)) {
(a->win_y + a->win_h >= b->win_y + b->win_h)) {
return TRUE;
}
return FALSE;
......
......@@ -147,14 +147,14 @@ gboolean resize_taskbarname(void *obj)
FALSE);
if (panel_horizontal) {
int new_size = name_width + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
int new_size = name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area);
if (new_size != taskbar_name->area.width) {
taskbar_name->area.width = new_size;
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
result = TRUE;
}
} else {
int new_size = name_height + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
int new_size = name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area);
if (new_size != taskbar_name->area.height) {
taskbar_name->area.height = new_size;
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
......
......@@ -160,8 +160,8 @@ void tooltip_update_geometry()
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_get_pixel_extents(layout, &r1, &r2);
width = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingx + r2.width;
height = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingy + r2.height;
width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + r2.width;
height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy + r2.height;
if (panel_horizontal && panel_position & BOTTOM)
y = panel->posy - height;
......@@ -275,8 +275,8 @@ void tooltip_update()
// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
// vert.)
cairo_move_to(c,
-r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
-r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
-r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx,
-r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy);
pango_cairo_show_layout(c, layout);
g_object_unref(layout);
......
This diff is collapsed.
......@@ -250,6 +250,20 @@ void relayout(Area *a);
// If maximum_size > 0, it is an upper limit for the child size.
int relayout_with_constraint(Area *a, int maximum_size);
int left_border_width(Area *a);
int right_border_width(Area *a);
int left_right_border_width(Area *a);
int top_border_width(Area *a);
int bottom_border_width(Area *a);
int top_bottom_border_width(Area *a);
int left_bg_border_width(Background *bg);
int right_bg_border_width(Background *bg);
int top_bg_border_width(Background *bg);
int bottom_bg_border_width(Background *bg);
int left_right_bg_border_width(Background *bg);
int top_bottom_bg_border_width(Background *bg);
// Rendering
// Sets the redraw_needed flag on the area and its descendants
......
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