From 7526e7e18d8f5b08f5c8325abd6cf00cf9a46c59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Wed, 22 May 2024 14:52:49 +0200 Subject: [PATCH] Cleanup remaining dpi scaling of min & max width (#1926) This was left over from #1877. --- src/conky.cc | 4 ++-- src/display-wayland.cc | 4 ++-- src/display-x11.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 2a60adf27..6de676c35 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -858,7 +858,7 @@ void update_text_area() { if (fixed_size == 0) #endif { - text_size = conky::vec2i(dpi_scale(minimum_width.get(*state)), 0); + text_size = conky::vec2i(minimum_width.get(*state), 0); last_font_height = font_height(); for_each_line(text_buffer, text_size_updater); text_size += conky::vec2i::UnitX(); @@ -984,7 +984,7 @@ static int text_size_updater(char *s, int special_index) { if (w > text_size.x()) { text_size.set_x(w); } int mw = maximum_width.get(*state); - if (text_size.x() > mw && mw > 0) { text_size.set_x(mw); } + if (mw > 0) { text_size.set_x(std::min(mw, text_size.x())); } text_size += conky::vec2i(0, last_font_height); last_font_height = font_height(); diff --git a/src/display-wayland.cc b/src/display-wayland.cc index e1c2f9d0b..ae80f5f9e 100644 --- a/src/display-wayland.cc +++ b/src/display-wayland.cc @@ -661,8 +661,8 @@ bool display_output_wayland::main_loop_wait(double t) { text_size.y() + 2 * border_total != height || scale_changed)) { /* clamp text_width to configured maximum */ if (maximum_width.get(*state)) { - int mw = global_window->scale * maximum_width.get(*state); - if (text_size.x() > mw && mw > 0) { text_size.set_x(mw); } + int mw = maximum_width.get(*state); + if (mw > 0) { text_size.set_x(std::min(mw, text_size.x())); } } /* pending scale will be applied by resizing the window */ diff --git a/src/display-x11.cc b/src/display-x11.cc index bda18b0fb..a7a4d98c6 100644 --- a/src/display-x11.cc +++ b/src/display-x11.cc @@ -666,7 +666,7 @@ bool handle_event( // don't apply dpi scaling to max pixel size int mw = maximum_width.get(*state); - if (text_size.x() > mw && mw > 0) { text_size.set_x(mw); } + if (mw > 0) { text_size.set_x(std::min(mw, text_size.x())); } } /* if position isn't what expected, set fixed pos