summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-03-09 16:27:27 +0000
committerManolo Gouy <Manolo>2018-03-09 16:27:27 +0000
commit7f78b1ef1468bb8242fb7fb37e3f27d0a8052ce1 (patch)
tree517c45c18c7dc28f8d3a05662a75497c408c1dbe /src/drivers
parent12f628514771294102d2aa961373373a95ddab6b (diff)
Windows: remove necessity to compile with -DFLTK_HIDPI_SUPPORT to make WIN32 FLTK apps DPI-aware.
At this point, Windows FLTK apps detect HighDPI displays and rescale their GUI accordingly. They also all reply to ctrl/+/-/0/ keystrokes to enlarge/shrink/reset their windows. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12723 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx4
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx14
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H6
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx26
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx11
5 files changed, 2 insertions, 59 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
index c68bf7e20..58fc1a8f2 100644
--- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
+++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
@@ -60,12 +60,8 @@ Fl_GDI_Copy_Surface_Driver::Fl_GDI_Copy_Surface_Driver(int w, int h) : Fl_Copy_S
float factorw = (100.f * hmm) / hdots;
float factorh = (100.f * vmm) / vdots;
// Global display scaling factor: 1, 1.25, 1.5, 1.75, etc...
-#ifdef FLTK_HIDPI_SUPPORT
float scaling = Fl_Graphics_Driver::default_driver().scale();
((Fl_GDI_Graphics_Driver*)driver())->scale(scaling);
-#else
- float scaling = 1/((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor();
-#endif
RECT rect; rect.left = 0; rect.top = 0; rect.right = (LONG)((w*scaling) * factorw); rect.bottom = (LONG)((h*scaling) * factorh);
gc = CreateEnhMetaFile (NULL, NULL, &rect, NULL);
if (gc != NULL) {
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx
index c495b5223..3b86650c8 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx
@@ -86,9 +86,7 @@ static void set_xmap(Fl_XMap& xmap, COLORREF c, int lw) {
// xmap.pen = CreatePen(PS_SOLID, 1, xmap.rgb); // get a pen into xmap.pen
LOGBRUSH penbrush = {BS_SOLID, xmap.rgb, 0};
xmap.pen = ExtCreatePen(PS_GEOMETRIC | PS_ENDCAP_FLAT | PS_JOIN_ROUND, lw, &penbrush, 0, 0);
-#ifdef FLTK_HIDPI_SUPPORT
xmap.pwidth = lw;
-#endif
xmap.brush = -1;
}
@@ -100,11 +98,7 @@ void Fl_GDI_Graphics_Driver::color(Fl_Color i) {
Fl_Graphics_Driver::color(i);
Fl_XMap &xmap = fl_xmap[i];
int tw = line_width_ ? line_width_ : int(scale_); if (!tw) tw = 1;
- if (!xmap.pen
-#ifdef FLTK_HIDPI_SUPPORT
- || xmap.pwidth != tw
-#endif
- ) {
+ if (!xmap.pen || xmap.pwidth != tw) {
#if USE_COLORMAP
if (fl_palette) {
set_xmap(xmap, PALETTEINDEX(i), tw);
@@ -126,11 +120,7 @@ void Fl_GDI_Graphics_Driver::color(uchar r, uchar g, uchar b) {
COLORREF c = RGB(r,g,b);
Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) );
int tw = line_width_ ? line_width_ : int(scale_); if (!tw) tw = 1;
- if (!xmap.pen || c != xmap.rgb
-#ifdef FLTK_HIDPI_SUPPORT
- || tw != xmap.pwidth
-#endif
- ) {
+ if (!xmap.pen || c != xmap.rgb || tw != xmap.pwidth) {
clear_xmap(xmap);
set_xmap(xmap, c, tw);
}
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
index d6dfaf889..6fe3d49e1 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.H
@@ -42,9 +42,7 @@ protected:
static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM);
BOOL screen_cb(HMONITOR mon, HDC, LPRECT r);
int get_mouse_unscaled(int &mx, int &my);
-#ifdef FLTK_HIDPI_SUPPORT
void init_screen_scale_factors();
-#endif
public:
Fl_WinAPI_Screen_Driver() : Fl_Screen_Driver() {
@@ -86,7 +84,6 @@ public:
virtual void disable_im();
virtual void open_display_platform();
virtual void offscreen_size(Fl_Offscreen off, int &width, int &height);
-#if defined(FLTK_HIDPI_SUPPORT)
virtual APP_SCALING_CAPABILITY rescalable() {
return PER_SCREEN_APP_SCALING;
}
@@ -96,9 +93,6 @@ public:
virtual void scale(int n, float f) {
scale_of_screen[n] = f;
}
-#else
- float DWM_scaling_factor();
-#endif
virtual float desktop_scale_factor();
};
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
index 4521038f0..a675d1620 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -600,32 +600,6 @@ Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y,
return rgb;
}
-#ifndef FLTK_HIDPI_SUPPORT
-/* Returns the current desktop scaling factor for screen_num (1.75 for example)
- */
-float Fl_WinAPI_Screen_Driver::DWM_scaling_factor() {
- // Compute the global desktop scaling factor: 1, 1.25, 1.5, 1.75, etc...
- // This factor can be set in Windows 10 by
- // "Change the size of text, apps and other items" in display settings.
- // We don't cache this value because it can change while the app is running.
- HDC hdc = GetDC(NULL);
- int hr = GetDeviceCaps(hdc, HORZRES); // pixels visible to the app
-#ifndef DESKTOPHORZRES
-#define DESKTOPHORZRES 118
- /* As of 27 august 2016, the DESKTOPHORZRES flag for GetDeviceCaps()
- has disappeared from Microsoft online doc, but is quoted in numerous coding examples
- e.g., https://social.msdn.microsoft.com/Forums/en-US/6acc3b21-23a4-4a00-90b4-968a43e1ccc8/capture-screen-with-high-dpi?forum=vbgeneral
- It is necessary for the computation of the scaling factor at runtime as done here.
- */
-#endif
- int dhr = GetDeviceCaps(hdc, DESKTOPHORZRES); // true number of pixels on display
- ReleaseDC(NULL, hdc);
- float scaling = dhr/float(hr);
- scaling = int(scaling * 100 + 0.5)/100.; // round to 2 digits after decimal point
- return scaling;
-}
-
-#endif // ! FLTK_HIDPI_SUPPORT
void Fl_WinAPI_Screen_Driver::offscreen_size(Fl_Offscreen off, int &width, int &height)
{
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 278fe740a..3492f9d6d 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -103,16 +103,10 @@ RECT // frame of the decorated window in screen coordinates
GetWindowRect(fl_xid(win), &r);
}
int width, height;
-#ifdef FLTK_HIDPI_SUPPORT
RECT rc;
GetClientRect(fl_xid(win), &rc);
width = rc.right;
height = rc.bottom;
-#else
- float scaling = ((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor();
- width = int(win->w() * scaling);
- height = int(win->h() * scaling);
-#endif
bx = (r.right - r.left - width)/2;
if (bx < 1) bx = 1;
by = bx;
@@ -137,14 +131,9 @@ int Fl_WinAPI_Window_Driver::decorated_h()
{
int bt, bx, by;
border_width_title_bar_height(bx, by, bt);
-#ifdef FLTK_HIDPI_SUPPORT
float s = Fl::screen_driver()->scale(screen_num());
int mini_by = by/s; if (mini_by < 1) mini_by = 1;
return h() + (bt + by)/s + mini_by;
-#else
- float scaling = ((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->DWM_scaling_factor();
- return h() + bt/scaling + 2 * by +1;
-#endif
}