diff --git a/src/config.c b/src/config.c index 901e8b1..7bff9cb 100644 --- a/src/config.c +++ b/src/config.c @@ -246,6 +246,8 @@ void add_entry(char *key, char *value) /* Background and border */ if (strcmp(key, "scale_relative_to_dpi") == 0) { ui_scale_dpi_ref = atof(value); + } else if (strcmp(key, "scale_relative_to_screen_height") == 0) { + ui_scale_monitor_size_ref = atof(value); } else if (strcmp(key, "rounded") == 0) { // 'rounded' is the first parameter => alloc a new background if (backgrounds->len > 0) { diff --git a/src/panel.c b/src/panel.c index b7aaddb..7db82f5 100644 --- a/src/panel.c +++ b/src/panel.c @@ -80,6 +80,7 @@ GArray *backgrounds; GArray *gradients; double ui_scale_dpi_ref; +double ui_scale_monitor_size_ref; Imlib_Image default_icon; char *default_font = NULL; @@ -87,6 +88,7 @@ char *default_font = NULL; void default_panel() { ui_scale_dpi_ref = 0; + ui_scale_monitor_size_ref = 0; panels = NULL; num_panels = 0; default_icon = NULL; @@ -225,6 +227,8 @@ void init_panel() p->scale = server.monitors[p->monitor].dpi / ui_scale_dpi_ref; else p->scale = 1; + if (ui_scale_monitor_size_ref > 0) + p->scale *= server.monitors[p->monitor].height / ui_scale_monitor_size_ref; 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); diff --git a/src/panel.h b/src/panel.h index 009d070..eabb21b 100644 --- a/src/panel.h +++ b/src/panel.h @@ -96,6 +96,7 @@ extern double tracing_fps_threshold; extern gboolean debug_frames; extern gboolean debug_thumbnails; extern double ui_scale_dpi_ref; +extern double ui_scale_monitor_size_ref; typedef struct Panel { Area area; diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index cf798a8..d618357 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -22,7 +22,7 @@ #include "gradient_gui.h" #include "strlcat.h" -GtkWidget *scale_relative_to_dpi; +GtkWidget *scale_relative_to_dpi, *scale_relative_to_screen_height; GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing; GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, @@ -614,6 +614,19 @@ void create_panel(GtkWidget *parent) gtk_table_attach(GTK_TABLE(table), scale_relative_to_dpi, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); col++; + row++; + col = 2; + label = gtk_label_new(_("Scale relative to screen height")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + + scale_relative_to_screen_height = gtk_spin_button_new_with_range(0, 9000, 1); + gtk_widget_show(scale_relative_to_screen_height); + gtk_table_attach(GTK_TABLE(table), scale_relative_to_screen_height, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + change_paragraph(parent); label = gtk_label_new(_("Appearance")); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 67e6a8e..529ff39 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -9,7 +9,7 @@ #include "../launcher/icon-theme-common.h" // panel -extern GtkWidget *scale_relative_to_dpi; +extern GtkWidget *scale_relative_to_dpi, *scale_relative_to_screen_height; extern GtkWidget *panel_width, *panel_height, *panel_margin_x, *panel_margin_y, *panel_padding_x, *panel_padding_y, *panel_spacing; extern GtkWidget *panel_wm_menu, *panel_dock, *panel_autohide, *panel_autohide_show_time, *panel_autohide_hide_time, diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 9883ab6..8796a46 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -381,6 +381,9 @@ void config_write_panel(FILE *fp) fprintf(fp, "scale_relative_to_dpi = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(scale_relative_to_dpi))); + fprintf(fp, + "scale_relative_to_screen_height = %d\n", + (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(scale_relative_to_screen_height))); fprintf(fp, "\n"); } @@ -1115,6 +1118,9 @@ void add_entry(char *key, char *value) if (strcmp(key, "scale_relative_to_dpi") == 0) { extract_values(value, &value1, &value2, &value3); gtk_spin_button_set_value(GTK_SPIN_BUTTON(scale_relative_to_dpi), atoi(value1)); + } else if (strcmp(key, "scale_relative_to_screen_height") == 0) { + extract_values(value, &value1, &value2, &value3); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(scale_relative_to_screen_height), atoi(value1)); } else if (strcmp(key, "gradient") == 0) { finalize_gradient(); GradientConfigType t;