Option to shrink panel: fix taskbar sizing

This commit is contained in:
o9000 2016-10-09 15:21:56 +02:00
parent 7c54f2acf7
commit 0d861ebd97
3 changed files with 26 additions and 0 deletions

View file

@ -47,6 +47,7 @@ TaskbarSortMethod taskbar_sort_method;
Alignment taskbar_alignment;
void taskbar_init_fonts();
int taskbar_compute_desired_size(void *obj);
// Removes the task with &win = key. The other args are ignored.
void taskbar_remove_task(Window *win);
@ -174,6 +175,7 @@ void init_taskbar_panel(void *p)
panel->g_taskbar.area.size_mode = LAYOUT_DYNAMIC;
panel->g_taskbar.area.alignment = taskbar_alignment;
panel->g_taskbar.area._resize = resize_taskbar;
panel->g_taskbar.area._compute_desired_size = taskbar_compute_desired_size;
panel->g_taskbar.area._is_under_mouse = full_width_area_is_under_mouse;
panel->g_taskbar.area.resize_needed = 1;
panel->g_taskbar.area.on_screen = TRUE;
@ -419,6 +421,22 @@ void taskbar_refresh_tasklist()
XFree(win);
}
int taskbar_compute_desired_size(void *obj)
{
Taskbar *taskbar = (Taskbar *)obj;
Panel *panel = (Panel *)taskbar->area.panel;
if (taskbar_mode == MULTI_DESKTOP && !taskbar_distribute_size && !hide_taskbar_if_empty) {
int result = 0;
for (int i = 0; i < panel->num_desktops; i++) {
Taskbar *t = &panel->taskbar[i];
result = MAX(result, container_compute_desired_size(&t->area));
}
return result;
}
return container_compute_desired_size(&taskbar->area);
}
gboolean resize_taskbar(void *obj)
{
Taskbar *taskbar = (Taskbar *)obj;

View file

@ -224,6 +224,13 @@ int compute_desired_size(Area *a)
return a->_compute_desired_size(a);
if (a->size_mode == LAYOUT_FIXED)
fprintf(stderr, YELLOW "Area %s does not set desired size!" RESET "\n", a->name);
return container_compute_desired_size(a);
}
int container_compute_desired_size(Area *a)
{
if (!a->on_screen)
return 0;
int result = 2 * a->paddingxlr + (panel_horizontal ? left_right_border_width(a) : top_bottom_border_width(a));
int children_count = 0;
for (GList *l = a->children; l != NULL; l = l->next) {

View file

@ -260,6 +260,7 @@ void relayout(Area *a);
int relayout_with_constraint(Area *a, int maximum_size);
int compute_desired_size(Area *a);
int container_compute_desired_size(Area *a);
int left_border_width(Area *a);
int right_border_width(Area *a);