Skip to content

Commit

Permalink
mate-hud: Reinstate get_dpi() for dpi calculation
Browse files Browse the repository at this point in the history
I realise that Gdk.Screen.width, Gdk.Screen.width_mm, Gdk.Screen.height and Gdk.Screen.height_mm now generate deprecation warnings, but this dpi calculation is accurate for regular DPI, HiDPI and a multi-display configurations.
  • Loading branch information
flexiondotorg committed Apr 12, 2022
1 parent 3d9f430 commit 41d5de2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion usr/lib/mate-hud/mate-hud
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,16 @@ def get_menu(menuKeys):
# Calculate display DPI value
screen = window.get_screen()
scale = window.get_scale_factor()
dpi = scale * screen.get_resolution()

def get_dpi(pixels, mm):
if mm >= 1:
return scale * pixels / (mm / 25.4)
else:
return 0

width_dpi = get_dpi(screen.width(), screen.width_mm())
height_dpi = get_dpi(screen.height(), screen.height_mm())
dpi = scale * (width_dpi + height_dpi) / 2

rofi_theme = get_rofi_theme()
mate_hud_themes = [ 'mate-hud', 'mate-hud-hidpi', 'mate-hud-rounded', 'mate-hud-rounded-hidpi' ]
Expand Down

0 comments on commit 41d5de2

Please sign in to comment.