Skip to content

Commit

Permalink
Revert "Detect High DPI on Linux Desktop" (#8184)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayaurora committed Mar 24, 2023
1 parent bb0578f commit e2c8f07
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 31 deletions.
7 changes: 0 additions & 7 deletions kivy/core/window/_window_sdl2.pyx
Expand Up @@ -266,13 +266,6 @@ cdef class _WindowSDL2Storage:
SDL_GetWindowSize(self.win, &w, &h)
return w, h


def _get_display_dpi(self):
cdef int display_index = SDL_GetWindowDisplayIndex(self.win)
cdef float horizontal_dpi = 0.
SDL_GetDisplayDPI(display_index, NULL, &horizontal_dpi, NULL)
return horizontal_dpi

def _set_cursor_state(self, value):
SDL_ShowCursor(value)

Expand Down
19 changes: 1 addition & 18 deletions kivy/core/window/window_sdl2.py
Expand Up @@ -403,24 +403,7 @@ def _update_density_and_dpi(self):
else:
self._density = self._win._get_gl_size()[0] / self._size[0]
if self._is_desktop:
# If the SDL window allows high DPI mode,
# then the window size and renderer size may be different.
# https://wiki.libsdl.org/SDL2/SDL_GetWindowSize
if self._density != 1.0:
dpi = self._density * 96.
else:
# Try to get the display DPI from SDL. This works in SDL2 on
# the X11 SDL2 backend, given that the X11 display
# is correctly configured.
display_dpi = self._win._get_display_dpi()
if display_dpi > 0.0:
dpi = display_dpi

# Change window DPI if it has changed.
# This will call reset_metrics under the hood,
# so only do it once and if it has changed.
if self.dpi != dpi:
self.dpi = dpi
self.dpi = self._density * 96.

def close(self):
self._win.teardown_window()
Expand Down
1 change: 0 additions & 1 deletion kivy/lib/sdl2.pxi
Expand Up @@ -552,7 +552,6 @@ cdef extern from "SDL.h":
cdef SDL_GLContext SDL_GL_CreateContext(SDL_Window* window)
cdef int SDL_GetNumVideoDisplays()
cdef int SDL_GetNumDisplayModes(int displayIndex)
cdef int SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
cdef int SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode)
cdef SDL_bool SDL_HasIntersection(SDL_Rect * A, SDL_Rect * B) nogil
cdef SDL_bool SDL_IntersectRect(SDL_Rect * A, SDL_Rect * B, SDL_Rect * result) nogil
Expand Down
2 changes: 1 addition & 1 deletion kivy/metrics.py
Expand Up @@ -259,7 +259,7 @@ def get_density(self, force_recompute=False):
elif platform == 'ios':
import ios
value = ios.get_scale()
elif platform in ('linux', 'macosx', 'win'):
elif platform in ('macosx', 'win'):
value = self.dpi / 96.

sync_pixel_scale(density=value)
Expand Down
8 changes: 4 additions & 4 deletions kivy/tests/test_properties.py
Expand Up @@ -415,19 +415,19 @@ def test_numeric_string_with_units_check(self, set_name):

a.set(wid, '55dp')
density = Metrics.density
self.assertAlmostEqual(a.get(wid), 55 * density, delta=1E-2)
self.assertEqual(a.get(wid), 55 * density)
self.assertEqual(a.get_format(wid), 'dp')

a.set(wid, u'55dp')
self.assertAlmostEqual(a.get(wid), 55 * density, delta=1E-2)
self.assertEqual(a.get(wid), 55 * density)
self.assertEqual(a.get_format(wid), 'dp')

a.set(wid, '99in')
self.assertAlmostEqual(a.get(wid), 9504.0 * density, delta=1E-2)
self.assertEqual(a.get(wid), 9504.0 * density)
self.assertEqual(a.get_format(wid), 'in')

a.set(wid, u'99in')
self.assertAlmostEqual(a.get(wid), 9504.0 * density, delta=1E-2)
self.assertEqual(a.get(wid), 9504.0 * density)
self.assertEqual(a.get_format(wid), 'in')


Expand Down

0 comments on commit e2c8f07

Please sign in to comment.