aboutsummaryrefslogtreecommitdiff
path: root/terminal.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-15 18:08:14 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-15 18:08:14 +0000
commit4d3ab6176dcf055e0f3b385aec0f4384e8cbba63 (patch)
treec482f0017b3958263a1532f3c481e38ec8bcfdfd /terminal.h
parentwayland: calculate DPI from physical size, not logical size (diff)
term: implement term_font_dpi_changed()
This function reloads the font *if* the DPI has changed. To handle user run-time adjusted font sizes, we record the number of adjustments made. Then, when re-loading the font, we first load the font as specified in the configuration. Then, we re-apply the size adjustment using font_size_adjust(). Note that this means we end up loading the fonts twice; first using the default size (but with adjusted DPI), and then again with the adjusted size. This can probably be improved upon. The existing font code has been refactored to avoid code duplication. For example, term_init() now calls term_font_dpi_changed() to load the initial fonts, instead of directly instantiating them. Finally, the way we calculate the DPI to use has changed: instead of using the highest DPI of all available outputs, we use the highest DPI of the output's we're actually mapped on. If we're not mapped at all, we use the globally highest DPI. Doing it this way means we usually only have to load the fonts once. Otherwise, we'd end up using the default DPI of 96 when the terminal is first instantiated (since it's not mapped at that time). On a single monitor system, we'll use the globally highest DPI at first, before being mapped. Then when we get mapped, we re-load the fonts using the highest mapped DPI. But since they'll be the same, we can skip actually reloading the fonts.
Diffstat (limited to 'terminal.h')
-rw-r--r--terminal.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/terminal.h b/terminal.h
index 1d19c9d7..d400dca5 100644
--- a/terminal.h
+++ b/terminal.h
@@ -187,6 +187,8 @@ struct terminal {
struct grid *grid;
struct font *fonts[4];
+ int font_dpi;
+ int font_adjustments;
tll(struct ptmx_buffer) ptmx_buffer;
@@ -364,9 +366,10 @@ int term_destroy(struct terminal *term);
void term_reset(struct terminal *term, bool hard);
bool term_to_slave(struct terminal *term, const void *data, size_t len);
-void term_font_size_increase(struct terminal *term);
-void term_font_size_decrease(struct terminal *term);
-void term_font_size_reset(struct terminal *term);
+bool term_font_size_increase(struct terminal *term);
+bool term_font_size_decrease(struct terminal *term);
+bool term_font_size_reset(struct terminal *term);
+bool term_font_dpi_changed(struct terminal *term);
void term_damage_rows(struct terminal *term, int start, int end);
void term_damage_rows_in_view(struct terminal *term, int start, int end);