From cc15700bdb918699b6977140f27f6183efc3ac76 Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:00:43 +0100 Subject: [PATCH] Windows: improve changing scale values of display while app runs. --- src/Fl_Screen_Driver.H | 1 + src/Fl_Screen_Driver.cxx | 9 ++++++++- src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H | 1 + src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H index f6da764a7..6371e57e9 100644 --- a/src/Fl_Screen_Driver.H +++ b/src/Fl_Screen_Driver.H @@ -247,6 +247,7 @@ public: virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win); virtual void reset_spot(); virtual void set_status(int X, int Y, int W, int H); + virtual float base_scale(int numscreen); }; #endif // !FL_SCREEN_DRIVER_H diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index fbb4aa4c2..e0a9f0f71 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -505,7 +505,7 @@ int Fl_Screen_Driver::scale_handler(int event) } top = Fl::next_window(top); } - static float initial_scale = screen_dr->scale(screen); + float initial_scale = screen_dr->base_scale(screen); #if defined(TEST_SCALING) // test scaling factors: lots of values from 0.3 to 8.0 static float scaling_values[] = { @@ -791,6 +791,13 @@ size_t Fl_Screen_Driver::convert_crlf(char *s, size_t len) { return len; } + +float Fl_Screen_Driver::base_scale(int numscreen) { + static float base = scale(numscreen); + return base; +} + + /** \} \endcond diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H index 816b667f6..b038fc5f1 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H @@ -97,6 +97,7 @@ public: // these two are implemented in Fl_get_key_win32.cxx int event_key(int) FL_OVERRIDE; int get_key(int) FL_OVERRIDE; + float base_scale(int numscreen) FL_OVERRIDE; }; diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx index 83f8f8973..df6906bb4 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx @@ -483,3 +483,8 @@ int Fl_WinAPI_Screen_Driver::screen_num_unscaled(int x, int y) } return screen; } + + +float Fl_WinAPI_Screen_Driver::base_scale(int numscreen) { + return dpi[numscreen][0] / 96.; +}