Scale panel elements (issue #656)
jump to
@@ -420,6 +420,7 @@
void draw_battery(void *obj, cairo_t *c) { Battery *battery = (Battery *)obj; + Panel *panel = (Panel *)battery->area.panel; draw_text_area(&battery->area, c, buf_bat_line1,@@ -428,7 +429,8 @@ bat1_font_desc,
bat2_font_desc, battery->bat1_posy, battery->bat2_posy, - &battery->font_color); + &battery->font_color, + panel->scale); } void battery_dump_geometry(void *obj, int indent)
@@ -306,6 +306,7 @@
void draw_clock(void *obj, cairo_t *c) { Clock *clock = (Clock *)obj; + Panel *panel = (Panel *)clock->area.panel; draw_text_area(&clock->area, c, buf_time,@@ -314,7 +315,8 @@ time1_font_desc,
time2_font_desc, clock->time1_posy, clock->time2_posy, - &clock->font); + &clock->font, + panel->scale); } void clock_dump_geometry(void *obj, int indent)
@@ -312,9 +312,9 @@ gboolean *resized)
{ Panel *panel = (Panel *)execp->area.panel; Area *area = &execp->area; - *horiz_padding = (panel_horizontal ? area->paddingxlr : area->paddingy); - *vert_padding = (panel_horizontal ? area->paddingy : area->paddingxlr); - *interior_padding = area->paddingx; + *horiz_padding = (panel_horizontal ? area->paddingxlr : area->paddingy) * panel->scale; + *vert_padding = (panel_horizontal ? area->paddingy : area->paddingxlr) * panel->scale; + *interior_padding = area->paddingx * panel->scale; if (reload_icon(execp)) { if (execp->backend->icon) {@@ -333,7 +333,7 @@
int available_w, available_h; if (panel_horizontal) { available_w = panel->area.width; - available_h = area->height - 2 * area->paddingy - left_right_border_width(area); + available_h = area->height - 2 * *horiz_padding - left_right_border_width(area); } else { available_w = !text_next_line ? area->width - *icon_w - (*icon_w ? *interior_padding : 0) - 2 * *horiz_padding -@@ -351,7 +351,8 @@ execp->backend->text,
strlen(execp->backend->text), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, - execp->backend->has_markup); + execp->backend->has_markup, + panel->scale); *resized = FALSE; if (panel_horizontal) {@@ -476,7 +477,11 @@
void draw_execp(void *obj, cairo_t *c) { Execp *execp = (Execp *)obj; - PangoLayout *layout = pango_cairo_create_layout(c); + Panel *panel = (Panel *)execp->area.panel; + + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * panel->scale); + PangoLayout *layout = pango_layout_new(context); if (execp->backend->has_icon && execp->backend->icon) { imlib_context_set_image(execp->backend->icon);@@ -504,6 +509,7 @@ &execp->backend->font_color,
panel_config.font_shadow); g_object_unref(layout); + g_object_unref(context); } void execp_dump_geometry(void *obj, int indent)
@@ -65,14 +65,14 @@ g_list_free_full(panel->freespace_list, free);
panel->freespace_list = NULL; } -int freespace_get_max_size(Panel *p) +int freespace_get_max_size(Panel *panel) { if (panel_shrink) return 0; // Get space used by every element except the freespace int size = 0; int spacers = 0; - for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) { + for (GList *walk = panel->area.children; walk; walk = g_list_next(walk)) { Area *a = (Area *)walk->data; if (!a->on_screen)@@ -83,15 +83,15 @@ continue;
} if (panel_horizontal) - size += a->width + p->area.paddingx; + size += a->width + panel->area.paddingx * panel->scale; else - size += a->height + p->area.paddingy; + size += a->height + panel->area.paddingy * panel->scale; } if (panel_horizontal) - size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr; + size = panel->area.width - size - left_right_border_width(&panel->area) - panel->area.paddingxlr * panel->scale; else - size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr; + size = panel->area.height - size - top_bottom_border_width(&panel->area) - panel->area.paddingxlr * panel->scale; return size / spacers; }
@@ -112,7 +112,7 @@ if (launcher->list_apps == NULL)
return; // This will be recomputed on resize, we just initialize to a non-zero value - launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24; + launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size * panel->scale : 24; launcher->area.on_screen = TRUE; schedule_panel_redraw();@@ -174,11 +174,12 @@ }
int launcher_compute_icon_size(Launcher *launcher) { + Panel *panel = launcher->area.panel; int icon_size = panel_horizontal ? launcher->area.height : launcher->area.width; 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; + (2 * launcher->area.paddingy * panel->scale); + if (launcher_max_icon_size) + icon_size = MIN(icon_size, launcher_max_icon_size * panel->scale); return icon_size; }@@ -189,6 +190,7 @@ int *icons_per_column,
int *icons_per_row, int *margin) { + Panel *panel = (Panel*)launcher->area.panel; int count = 0; for (GSList *l = launcher->list_icons; l; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data;@@ -204,25 +206,25 @@ if (panel_horizontal) {
if (!count) { *size = 0; } else { - int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; + int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy * panel->scale; // 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_column = (height + launcher->area.paddingx * panel->scale) / (*icon_size + launcher->area.paddingx * panel->scale); + *margin = height - (*icons_per_column - 1) * (*icon_size + launcher->area.paddingx * panel->scale) - *icon_size; *icons_per_row = count / *icons_per_column + (count % *icons_per_column != 0); - *size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + - (*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx); + *size = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr * panel->scale + + (*icon_size * *icons_per_row) + ((*icons_per_row - 1) * launcher->area.paddingx * panel->scale); } } else { if (!count) { *size = 0; } else { - int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy; + int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy * panel->scale; // 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_row = (width + launcher->area.paddingx * panel->scale) / (*icon_size + launcher->area.paddingx * panel->scale); + *margin = width - (*icons_per_row - 1) * (*icon_size + launcher->area.paddingx * panel->scale) - *icon_size; *icons_per_column = count / *icons_per_row + (count % *icons_per_row != 0); - *size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr + - (*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx); + *size = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr * panel->scale + + (*icon_size * *icons_per_column) + ((*icons_per_column - 1) * launcher->area.paddingx * panel->scale); } } }@@ -239,6 +241,7 @@
gboolean resize_launcher(void *obj) { Launcher *launcher = (Launcher *)obj; + Panel *panel = (Panel*)launcher->area.panel; int size, icons_per_column, icons_per_row, margin; launcher_compute_geometry(launcher, &size, &launcher->icon_size, &icons_per_column, &icons_per_row, &margin);@@ -281,11 +284,11 @@
int posx, posy; int start; if (panel_horizontal) { - posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; - posx = left_border_width(&launcher->area) + launcher->area.paddingxlr; + posy = start = top_border_width(&launcher->area) + launcher->area.paddingy * panel->scale + margin / 2; + posx = left_border_width(&launcher->area) + launcher->area.paddingxlr * panel->scale; } else { - posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2; - posy = top_border_width(&launcher->area) + launcher->area.paddingxlr; + posx = start = left_border_width(&launcher->area) + launcher->area.paddingy * panel->scale + margin / 2; + posy = top_border_width(&launcher->area) + launcher->area.paddingxlr * panel->scale; } int i = 0;@@ -300,17 +303,17 @@ launcher_icon_on_change_layout(launcherIcon);
// fprintf(stderr, "tint2: launcher %d : %d,%d\n", i, posx, posy); if (panel_horizontal) { if (i % icons_per_column) { - posy += launcher->icon_size + launcher->area.paddingx; + posy += launcher->icon_size + launcher->area.paddingx * panel->scale; } else { posy = start; - posx += (launcher->icon_size + launcher->area.paddingx); + posx += (launcher->icon_size + launcher->area.paddingx * panel->scale); } } else { if (i % icons_per_row) { - posx += launcher->icon_size + launcher->area.paddingx; + posx += launcher->icon_size + launcher->area.paddingx * panel->scale; } else { posx = start; - posy += (launcher->icon_size + launcher->area.paddingx); + posy += (launcher->icon_size + launcher->area.paddingx * panel->scale); } } }
@@ -225,7 +225,7 @@ if (ui_scale_dpi_ref > 0 && server.monitors[p->monitor].dpi > 0)
p->scale = server.monitors[p->monitor].dpi / ui_scale_dpi_ref; else p->scale = 1; - fprintf(stderr, "tint2: panel %d uses scale %f\n", i + 1, p->scale); + fprintf(stderr, BLUE "tint2: panel %d uses scale %g " RESET "\n", i + 1, p->scale); if (!p->area.bg) p->area.bg = &g_array_index(backgrounds, Background, 0); p->area.parent = p;@@ -470,9 +470,9 @@ Taskbar *taskbar = &panel->taskbar[i];
if (!taskbar->area.on_screen) continue; if (panel_horizontal) - taskbar->area.width = 2 * taskbar->area.paddingxlr; + taskbar->area.width = 2 * taskbar->area.paddingxlr * panel->scale; else - taskbar->area.height = 2 * taskbar->area.paddingxlr; + taskbar->area.height = 2 * taskbar->area.paddingxlr * panel->scale; if (taskbarname_enabled && taskbar->area.children) { Area *name = (Area *)taskbar->area.children->data; if (name->on_screen) {@@ -489,9 +489,9 @@ if (!child->on_screen)
continue; if (!first_child) { if (panel_horizontal) - taskbar->area.width += taskbar->area.paddingx; + taskbar->area.width += taskbar->area.paddingx * panel->scale; else - taskbar->area.height += taskbar->area.paddingy; + taskbar->area.height += taskbar->area.paddingy * panel->scale; } first_child = FALSE; }
@@ -115,31 +115,33 @@
int separator_compute_desired_size(void *obj) { Separator *separator = (Separator *)obj; + Panel *panel = (Panel*)separator->area.panel; if (!separator->area.on_screen) return 0; if (panel_horizontal) - return separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); + return separator->thickness + 2 * separator->area.paddingxlr * panel->scale + left_right_border_width(&separator->area); else - return separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); + return separator->thickness + 2 * separator->area.paddingxlr * panel->scale + top_bottom_border_width(&separator->area); } gboolean resize_separator(void *obj) { Separator *separator = (Separator *)obj; + Panel *panel = (Panel*)separator->area.panel; if (!separator->area.on_screen) return FALSE; if (panel_horizontal) { separator->area.width = - separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); + separator->thickness + 2 * separator->area.paddingxlr * panel->scale + left_right_border_width(&separator->area); separator->length = - separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area); + separator->area.height - 2 * separator->area.paddingy * panel->scale - top_bottom_border_width(&separator->area); } else { separator->area.height = - separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); + separator->thickness + 2 * separator->area.paddingxlr * panel->scale + top_bottom_border_width(&separator->area); separator->length = - separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area); + separator->area.width - 2 * separator->area.paddingy * panel->scale - left_right_border_width(&separator->area); } schedule_redraw(&separator->area);
@@ -141,11 +141,12 @@ }
void systray_compute_geometry(int *size) { + Panel *panel = (Panel*)systray.area.panel; systray.icon_size = panel_horizontal ? systray.area.height : systray.area.width; systray.icon_size -= - MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) + 2 * systray.area.paddingy; + MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) + 2 * systray.area.paddingy * panel->scale; if (systray_max_icon_size > 0) - systray.icon_size = MIN(systray.icon_size, systray_max_icon_size); + systray.icon_size = MIN(systray.icon_size, systray_max_icon_size * panel->scale); int count = 0; for (GSList *l = systray.list_icons; l; l = l->next) {@@ -153,24 +154,24 @@ count++;
} if (panel_horizontal) { - int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy; + int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy * panel->scale; // here icons_per_column always higher than 0 - systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); + systray.icons_per_column = (height + systray.area.paddingx * panel->scale) / (systray.icon_size + systray.area.paddingx * panel->scale); systray.margin = - height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; + height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx * panel->scale) - systray.icon_size; systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0); - *size = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr + - (systray.icon_size * systray.icons_per_row) + ((systray.icons_per_row - 1) * systray.area.paddingx); + *size = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr * panel->scale + + (systray.icon_size * systray.icons_per_row) + ((systray.icons_per_row - 1) * systray.area.paddingx * panel->scale); } else { - int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy; + int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy * panel->scale; // here icons_per_row always higher than 0 - systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx); + systray.icons_per_row = (width + systray.area.paddingx * panel->scale) / (systray.icon_size + systray.area.paddingx * panel->scale); systray.margin = - width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size; + width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx * panel->scale) - systray.icon_size; systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0); - *size = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) + + *size = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr * panel->scale) + (systray.icon_size * systray.icons_per_column) + - ((systray.icons_per_column - 1) * systray.area.paddingx); + ((systray.icons_per_column - 1) * systray.area.paddingx * panel->scale); } }@@ -281,13 +282,13 @@ Panel *panel = systray.area.panel;
int posx, posy; int start; if (panel_horizontal) { - posy = start = top_border_width(&panel->area) + panel->area.paddingy + top_border_width(&systray.area) + - systray.area.paddingy + systray.margin / 2; - posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr; + posy = start = top_border_width(&panel->area) + panel->area.paddingy * panel->scale + top_border_width(&systray.area) + + systray.area.paddingy * panel->scale + systray.margin / 2; + posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr * panel->scale; } else { - posx = start = left_border_width(&panel->area) + panel->area.paddingy + left_border_width(&systray.area) + - systray.area.paddingy + systray.margin / 2; - posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr; + posx = start = left_border_width(&panel->area) + panel->area.paddingy * panel->scale + left_border_width(&systray.area) + + systray.area.paddingy * panel->scale + systray.margin / 2; + posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr * panel->scale; } TrayWindow *traywin;@@ -312,17 +313,17 @@ traywin->width = systray.icon_size;
traywin->height = systray.icon_size; if (panel_horizontal) { if (i % systray.icons_per_column) { - posy += systray.icon_size + systray.area.paddingx; + posy += systray.icon_size + systray.area.paddingx * panel->scale; } else { posy = start; - posx += (systray.icon_size + systray.area.paddingx); + posx += (systray.icon_size + systray.area.paddingx * panel->scale); } } else { if (i % systray.icons_per_row) { - posx += systray.icon_size + systray.area.paddingx; + posx += systray.icon_size + systray.area.paddingx * panel->scale; } else { posx = start; - posy += (systray.icon_size + systray.area.paddingx); + posy += (systray.icon_size + systray.area.paddingx * panel->scale); } }
@@ -429,7 +429,7 @@ task->_icon_x = (task->area.width - text_width - panel->g_task.icon_size1) / 2;
else task->_icon_x = (task->area.width - panel->g_task.icon_size1) / 2; } else { - task->_icon_x = left_border_width(&task->area) + task->area.paddingxlr; + task->_icon_x = left_border_width(&task->area) + task->area.paddingxlr * panel->scale; } // Render@@ -459,7 +459,9 @@ Panel *panel = (Panel *)task->area.panel;
task->_text_width = 0; if (panel->g_task.has_text) { - PangoLayout *layout = pango_cairo_create_layout(c); + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * panel->scale); + PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, panel->g_task.font_desc); pango_layout_set_text(layout, task->title, -1);@@ -480,6 +482,7 @@ Color *config_text = &panel->g_task.font[task->current_state];
draw_text(layout, c, panel->g_task.text_posx, task->_text_posy, config_text, panel->font_shadow); g_object_unref(layout); + g_object_unref(context); } if (panel->g_task.has_icon)@@ -532,7 +535,7 @@ int task_compute_desired_size(void *obj)
{ Task *task = (Task *)obj; Panel *panel = (Panel *)task->area.panel; - int size = panel_horizontal ? panel->g_task.maximum_width : panel->g_task.maximum_height; + int size = (panel_horizontal ? panel->g_task.maximum_width : panel->g_task.maximum_height) * panel->scale; return size; }
@@ -238,15 +238,15 @@ 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; if (panel_horizontal) { - panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy; + panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy * panel->scale; panel->g_taskbar.area.height = - panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy; + panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy * panel->scale; 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 = left_border_width(&panel->area) + panel->area.paddingy; + panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy * panel->scale; panel->g_taskbar.area.width = - panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy; + panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy * panel->scale; panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx; panel->g_taskbar.area_name.width = panel->g_taskbar.area.width; }@@ -304,19 +304,19 @@
if (panel_horizontal) { panel->g_task.area.posy = panel->g_taskbar.area.posy + top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + - panel->g_taskbar.area.paddingy; + panel->g_taskbar.area.paddingy * panel->scale; panel->g_task.area.width = panel->g_task.maximum_width; 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; + 2 * panel->g_taskbar.area.paddingy * panel->scale; } else { panel->g_task.area.posx = panel->g_taskbar.area.posx + left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) + - panel->g_taskbar.area.paddingy; + panel->g_taskbar.area.paddingy * panel->scale; 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; + 2 * panel->g_taskbar.area.paddingy * panel->scale; + panel->g_task.area.height = panel->g_task.maximum_height * panel->scale; } for (int j = 0; j < TASK_STATE_COUNT; ++j) {@@ -344,17 +344,18 @@ "TAjpg",
5, PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_END, - FALSE); + FALSE, + panel->scale); - panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr; + panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr * panel->scale; panel->g_task.text_height = - panel->g_task.area.height - (2 * panel->g_task.area.paddingy) - top_bottom_border_width(&panel->g_task.area); + panel->g_task.area.height - (2 * panel->g_task.area.paddingy * panel->scale) - top_bottom_border_width(&panel->g_task.area); if (panel->g_task.has_icon) { - panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height), + panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width * panel->scale, panel->g_task.maximum_height * panel->scale), 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), + 2 * panel->g_task.area.paddingy * panel->scale - 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.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx * panel->scale; panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2; }@@ -573,12 +574,12 @@ break;
} } taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) - - panel->g_task.area.paddingxlr; + panel->g_task.area.paddingxlr * panel->scale; } else { - relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height); + relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height * panel->scale); - taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx - - right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr; + taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy * panel->scale) - panel->g_task.text_posx - + right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr * panel->scale; } return FALSE; }
@@ -145,12 +145,13 @@ taskbar_name->name,
strlen(taskbar_name->name), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, - FALSE); + FALSE, + panel->scale); if (panel_horizontal) { - return name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area); + return name_width + 2 * taskbar_name->area.paddingxlr * panel->scale + left_right_border_width(&taskbar_name->area); } else { - return name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area); + return name_height + 2 * taskbar_name->area.paddingxlr * panel->scale + top_bottom_border_width(&taskbar_name->area); } }@@ -172,7 +173,8 @@ taskbar_name->name,
strlen(taskbar_name->name), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, - FALSE); + FALSE, + panel->scale); gboolean result = FALSE; int new_size = taskbarname_compute_desired_size(obj);@@ -195,11 +197,14 @@
void draw_taskbarname(void *obj, cairo_t *c) { TaskbarName *taskbar_name = obj; + Panel *panel = (Panel *)taskbar_name->area.panel; Taskbar *taskbar = taskbar_name->area.parent; Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font; // draw content - PangoLayout *layout = pango_cairo_create_layout(c); + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * panel->scale); + PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc); pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE); pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);@@ -213,6 +218,7 @@ pango_cairo_update_layout(c, layout);
draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow); g_object_unref(layout); + g_object_unref(context); } void update_desktop_names()
@@ -153,7 +153,9 @@ int screen_width = server.monitors[panel->monitor].width;
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height); cairo_t *c = cairo_create(cs); - PangoLayout *layout = pango_cairo_create_layout(c); + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * panel->scale); + PangoLayout *layout = pango_layout_new(context); pango_layout_set_font_description(layout, g_tooltip.font_desc); PangoRectangle r1, r2;@@ -161,7 +163,7 @@ pango_layout_set_text(layout, "1234567890abcdef", -1);
pango_layout_get_pixel_extents(layout, &r1, &r2); int max_width = MIN(r2.width * 5, screen_width * 2 / 3); if (g_tooltip.image && cairo_image_surface_get_width(g_tooltip.image) > 0) { - max_width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + + max_width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx * panel->scale + cairo_image_surface_get_width(g_tooltip.image); } pango_layout_set_width(layout, max_width * PANGO_SCALE);@@ -169,12 +171,12 @@
pango_layout_set_text(layout, g_tooltip.tooltip_text ? g_tooltip.tooltip_text : "1234567890abcdef", -1); pango_layout_set_wrap(layout, PANGO_WRAP_WORD); pango_layout_get_pixel_extents(layout, &r1, &r2); - 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; + width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx * panel->scale + r2.width; + height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy * panel->scale + r2.height; if (g_tooltip.image && cairo_image_surface_get_width(g_tooltip.image) > 0) { - width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + + width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx * panel->scale + cairo_image_surface_get_width(g_tooltip.image); - height += g_tooltip.paddingy + cairo_image_surface_get_height(g_tooltip.image); + height += g_tooltip.paddingy * panel->scale + cairo_image_surface_get_height(g_tooltip.image); } if (panel_horizontal && panel_position & BOTTOM)@@ -187,6 +189,7 @@ else
x = panel->posx - width; g_object_unref(layout); + g_object_unref(context); cairo_destroy(c); cairo_surface_destroy(cs); }@@ -243,6 +246,7 @@ if (!g_tooltip.tooltip_text) {
tooltip_hide(0); return; } + Panel *panel = g_tooltip.panel; tooltip_update_geometry(); if (just_shown) {@@ -289,15 +293,15 @@ pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
// 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 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx, - -r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy); + -r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx * panel->scale, + -r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy * panel->scale); pango_cairo_show_layout(c, layout); g_object_unref(layout); if (g_tooltip.image) { cairo_translate(c, - left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx, - height - bottom_bg_border_width(g_tooltip.bg) - g_tooltip.paddingy - cairo_image_surface_get_height(g_tooltip.image)); + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx * panel->scale, + height - bottom_bg_border_width(g_tooltip.bg) - g_tooltip.paddingy * panel->scale - cairo_image_surface_get_height(g_tooltip.image)); cairo_set_source_surface(c, g_tooltip.image, 0, 0); cairo_paint(c); }
@@ -950,7 +950,8 @@ line1,
strlen(line1), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, - FALSE); + FALSE, + ((Panel*)area->panel)->scale); else *line1_width = *line1_height_ink = *line1_height = 0;@@ -965,7 +966,8 @@ line2,
strlen(line2), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, - FALSE); + FALSE, + ((Panel*)area->panel)->scale); else *line2_width = *line2_height_ink = *line2_height = 0; }@@ -1067,12 +1069,16 @@ PangoFontDescription *line1_font_desc,
PangoFontDescription *line2_font_desc, int line1_posy, int line2_posy, - Color *color) + Color *color, + double scale) { int inner_w, inner_h; area_compute_inner_size(area, &inner_w, &inner_h); - PangoLayout *layout = pango_cairo_create_layout(c); + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * scale); + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);@@ -1096,6 +1102,7 @@ draw_text(layout, c, (area->width - inner_w) / 2, line2_posy, color, ((Panel *)area->panel)->font_shadow);
} g_object_unref(layout); + g_object_unref(context); } Area *compute_element_area(Area *area, Element element)
@@ -299,7 +299,8 @@ PangoFontDescription *line1_font_desc,
PangoFontDescription *line2_font_desc, int line1_posy, int line2_posy, - Color *color); + Color *color, + double scale); int left_border_width(Area *a); int right_border_width(Area *a);
@@ -934,7 +934,8 @@ const char *text,
int text_len, PangoWrapMode wrap, PangoEllipsizeMode ellipsis, - gboolean markup) + gboolean markup, + double scale) { PangoRectangle rect_ink, rect;@@ -945,7 +946,9 @@ cairo_surface_t *cs =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, available_height, available_width); cairo_t *c = cairo_create(cs); - PangoLayout *layout = pango_cairo_create_layout(c); + PangoContext *context = pango_cairo_create_context(c); + pango_cairo_context_set_resolution(context, 96 * scale); + PangoLayout *layout = pango_layout_new(context); pango_layout_set_width(layout, available_width * PANGO_SCALE); pango_layout_set_height(layout, available_height * PANGO_SCALE); pango_layout_set_wrap(layout, wrap);@@ -964,6 +967,7 @@ *width = rect.width;
// fprintf(stderr, "tint2: dimension : %d - %d\n", rect_ink.height, rect.height); g_object_unref(layout); + g_object_unref(context); cairo_destroy(c); cairo_surface_destroy(cs); }
@@ -122,7 +122,8 @@ const char *text,
int text_len, PangoWrapMode wrap, PangoEllipsizeMode ellipsis, - gboolean markup); + gboolean markup, + double scale); void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);
@@ -313,10 +313,10 @@ }
int compute_dpi(XRRCrtcInfo *crtc, XRROutputInfo *output) { - int width = output->mm_width; - int height = output->mm_height; - int x_res = crtc->width; - int y_res = crtc->height; + double width = output->mm_width; + double height = output->mm_height; + double x_res = crtc->width; + double y_res = crtc->height; if (width > 0 && height > 0) { int dpi_x = x_res / width * 25.4;@@ -364,7 +364,7 @@ int dpi = compute_dpi(crtc_info, output_info);
if (dpi) server.monitors[i_monitor].dpi = dpi; fprintf(stderr, - "tint2: xRandr: Linking output %s with crtc %d, resolution %dx%d, DPI %d\n", + BLUE "tint2: xRandr: Linking output %s with crtc %d, resolution %dx%d, DPI %d" RESET "\n", output_info->name, i, server.monitors[i_monitor].width,