diff --git a/kivy/core/window/__init__.py b/kivy/core/window/__init__.py index cfa6d4321..784a6d26c 100644 --- a/kivy/core/window/__init__.py +++ b/kivy/core/window/__init__.py @@ -420,7 +420,7 @@ class WindowBase(EventDispatcher): def _get_size(self): r = self._rotation w, h = self._size - if self._density != 1: + if platform == 'win' or self._density != 1: w, h = self._win._get_gl_size() if self.softinput_mode == 'resize': h -= self.keyboard_height @@ -519,7 +519,7 @@ class WindowBase(EventDispatcher): # make some property read-only def _get_width(self): _size = self._size - if self._density != 1: + if platform == 'win' or self._density != 1: _size = self._win._get_gl_size() r = self._rotation if r == 0 or r == 180: @@ -536,7 +536,7 @@ class WindowBase(EventDispatcher): '''Rotated window height''' r = self._rotation _size = self._size - if self._density != 1: + if platform == 'win' or self._density != 1: _size = self._win._get_gl_size() kb = self.keyboard_height if self.softinput_mode == 'resize' else 0 if r == 0 or r == 180: @@ -739,13 +739,13 @@ class WindowBase(EventDispatcher): ''' def _get_effective_size(self): - '''On density=1 and non-ios displays, return :attr:`system_size`, - else return scaled / rotated :attr:`size`. + '''On density=1 and non-ios / non-Windows displays, + return :attr:`system_size`, else return scaled / rotated :attr:`size`. Used by MouseMotionEvent.update_graphics() and WindowBase.on_motion(). ''' w, h = self.system_size - if platform == 'ios' or self._density != 1: + if platform in ('ios', 'win') or self._density != 1: w, h = self.size return w, h diff --git a/kivy/core/window/_window_sdl2.pyx b/kivy/core/window/_window_sdl2.pyx index b7570d9ba..669a14d6c 100644 --- a/kivy/core/window/_window_sdl2.pyx +++ b/kivy/core/window/_window_sdl2.pyx @@ -109,6 +109,10 @@ cdef class _WindowSDL2Storage: SDL_SetHintWithPriority(b'SDL_ANDROID_TRAP_BACK_BUTTON', b'1', SDL_HINT_OVERRIDE) + + # makes dpi aware of scale changes + if platform == "win": + SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, b"1") if SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0: self.die() diff --git a/kivy/core/window/window_sdl2.py b/kivy/core/window/window_sdl2.py index cea443bf5..3e1572050 100644 --- a/kivy/core/window/window_sdl2.py +++ b/kivy/core/window/window_sdl2.py @@ -981,8 +981,6 @@ class _WindowsSysDPIWatch: from ctypes import windll if msg == WM_DPICHANGED: - ow, oh = self.window.size - old_dpi = self.window.dpi def clock_callback(*args): if x_dpi != y_dpi: @@ -991,10 +989,6 @@ class _WindowsSysDPIWatch: self.window.dpi = x_dpi - # maintain the same window size - ratio = x_dpi / old_dpi - self.window.size = ratio * ow, ratio * oh - x_dpi = wParam & 0xFFFF y_dpi = wParam >> 16 Clock.schedule_once(clock_callback, -1) diff --git a/kivy/lib/sdl2.pxi b/kivy/lib/sdl2.pxi index 665c1bd9d..816bb0124 100644 --- a/kivy/lib/sdl2.pxi +++ b/kivy/lib/sdl2.pxi @@ -480,6 +480,8 @@ cdef extern from "SDL.h": cdef char *SDL_HINT_VIDEO_WIN_D3DCOMPILER cdef char *SDL_HINT_ACCELEROMETER_AS_JOYSTICK cdef char *SDL_HINT_ANDROID_TRAP_BACK_BUTTON + cdef char *SDL_HINT_WINDOWS_DPI_AWARENESS + cdef char *SDL_HINT_WINDOWS_DPI_SCALING cdef int SDL_QUERY = -1 cdef int SDL_IGNORE = 0