Scaling support - scale by screen height (issue #656)
o9000 mrovi9000@gmail.com
6 files changed,
28 insertions(+),
2 deletions(-)
M
src/config.c
→
src/config.c
@@ -246,6 +246,8 @@
/* 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) {
M
src/panel.c
→
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 @@
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 @@ 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; + 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);
M
src/panel.h
→
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;
M
src/tint2conf/properties.c
→
src/tint2conf/properties.c
@@ -22,7 +22,7 @@ #include "background_gui.h"
#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,@@ -612,6 +612,19 @@
scale_relative_to_dpi = gtk_spin_button_new_with_range(0, 9000, 1); gtk_widget_show(scale_relative_to_dpi); 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);
M
src/tint2conf/properties.h
→
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,
M
src/tint2conf/properties_rw.c
→
src/tint2conf/properties_rw.c
@@ -381,6 +381,9 @@
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 @@ /* Gradients */
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;