aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--terminal.c51
-rw-r--r--terminal.h2
2 files changed, 14 insertions, 39 deletions
diff --git a/terminal.c b/terminal.c
index b4abbb0f..7fd6f551 100644
--- a/terminal.c
+++ b/terminal.c
@@ -724,31 +724,6 @@ get_font_dpi(const struct terminal *term)
return dpi;
}
-static int
-get_font_scale(const struct terminal *term)
-{
- /* Same as get_font_dpi(), but returns output scale factor instead */
- int scale = 0;
-
- xassert(term->window != NULL);
- tll_foreach(term->window->on_outputs, it) {
- if (it->item->scale > scale)
- scale = it->item->scale;
- }
-
- if (scale == 0) {
- tll_foreach(term->wl->monitors, it) {
- scale = it->item.scale;
- break;
- }
- }
-
- if (scale == 0)
- scale = 1;
-
- return scale;
-}
-
static enum fcft_subpixel
get_font_subpixel(const struct terminal *term)
{
@@ -794,22 +769,22 @@ get_font_subpixel(const struct terminal *term)
}
static bool
-font_should_size_by_dpi(const struct terminal *term, int new_scale)
+font_size_by_dpi_for_scale(const struct terminal *term, int new_scale)
{
return term->conf->dpi_aware == DPI_AWARE_YES ||
(term->conf->dpi_aware == DPI_AWARE_AUTO && new_scale <= 1);
}
static bool
-font_size_by_dpi(const struct terminal *term)
+font_sized_by_dpi(const struct terminal *term)
{
- return font_should_size_by_dpi(term, term->font_scale);
+ return font_size_by_dpi_for_scale(term, term->font_scale);
}
static bool
-font_size_by_scale(const struct terminal *term)
+font_sized_by_scale(const struct terminal *term)
{
- return !font_size_by_dpi(term);
+ return !font_sized_by_dpi(term);
}
@@ -849,7 +824,7 @@ reload_fonts(struct terminal *term)
bool use_px_size = term->font_sizes[i][j].px_size > 0;
char size[64];
- const int scale = font_size_by_scale(term) ? term->scale : 1;
+ const int scale = font_sized_by_scale(term) ? term->scale : 1;
if (use_px_size)
snprintf(size, sizeof(size), ":pixelsize=%d",
@@ -885,7 +860,7 @@ reload_fonts(struct terminal *term)
const size_t count_bold_italic = custom_bold_italic ? counts[3] : counts[0];
const char **names_bold_italic = (const char **)(custom_bold_italic ? names[3] : names[0]);
- const bool use_dpi = font_size_by_dpi(term);
+ const bool use_dpi = font_sized_by_dpi(term);
char *attrs[4] = {NULL};
int attr_len[4] = {-1, -1, -1, -1}; /* -1, so that +1 (below) results in 0 */
@@ -1798,16 +1773,16 @@ bool
term_font_dpi_changed(struct terminal *term)
{
float dpi = get_font_dpi(term);
- int scale = get_font_scale(term);
+ xassert(term->scale > 0);
- bool was_scaled_using_dpi = font_size_by_dpi(term);
- bool will_scale_using_dpi = font_should_size_by_dpi(term, scale);
+ bool was_scaled_using_dpi = font_sized_by_dpi(term);
+ bool will_scale_using_dpi = font_size_by_dpi_for_scale(term, term->scale);
bool need_font_reload =
was_scaled_using_dpi != will_scale_using_dpi ||
(will_scale_using_dpi
? term->font_dpi != dpi
- : term->font_scale != scale);
+ : term->font_scale != term->scale);
if (need_font_reload) {
LOG_DBG("DPI/scale change: DPI-awareness=%s, "
@@ -1815,12 +1790,12 @@ term_font_dpi_changed(struct terminal *term)
"sizing font based on monitor's %s",
term->conf->dpi_aware == DPI_AWARE_AUTO ? "auto" :
term->conf->dpi_aware == DPI_AWARE_YES ? "yes" : "no",
- term->font_dpi, dpi, term->font_scale, scale,
+ term->font_dpi, dpi, term->font_scale, term->scale,
will_scale_using_dpi ? "DPI" : "scaling factor");
}
term->font_dpi = dpi;
- term->font_scale = scale;
+ term->font_scale = term->scale;
if (!need_font_reload)
return true;
diff --git a/terminal.h b/terminal.h
index 85ba90eb..42e2fd2a 100644
--- a/terminal.h
+++ b/terminal.h
@@ -320,7 +320,7 @@ struct terminal {
struct config_font *font_sizes[4];
struct pt_or_px font_line_height;
float font_dpi;
- int font_scale;
+ int font_scale; /* scaling factor last time we loaded fonts */
int16_t font_x_ofs;
int16_t font_y_ofs;
enum fcft_subpixel font_subpixel;