Windows: improve changing scale values of display while app runs.

This commit is contained in:
ManoloFLTK 2024-03-01 14:00:43 +01:00
parent 266647d2a7
commit cc15700bdb
4 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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;
};

View File

@ -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.;
}