Skip to content

Commit

Permalink
display: automatically update display scale
Browse files Browse the repository at this point in the history
This setting has been removed, since there is a property that actually
updates properly and dynamically based on which display the mpv window
is on. I figured this property existed, but I never bothered actually
adding it until now.
  • Loading branch information
torque committed Nov 5, 2022
1 parent fc714af commit 5d7a61a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/Mouse.moon
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
class Mouse
osdScale = settings['display-scale-factor']

@@x, @@y = -1, -1
@@_rawX, @@_rawY = -1, -1
@@inWindow, @@dead = false, true
@@clickX, @@clickY = -1, -1
@@clickPending = false

scaledPosition = ->
scaledPosition = =>
x, y = mp.get_mouse_pos!
return math.floor( x/osdScale ), math.floor( y/osdScale )
@_rawX, @_rawY = x, y
return math.floor( x/Window.osdScale ), math.floor( y/Window.osdScale )

@update: =>
oldX, oldY = @x, @y
@x, @y = scaledPosition!
@x, @y = scaledPosition @
if @dead and (oldX != @x or oldY != @y)
@dead = false
if not @dead and @clickPending
Expand All @@ -22,7 +22,7 @@ class Mouse

@cacheClick: =>
if not @dead
@clickX, @clickY = scaledPosition!
@clickX, @clickY = scaledPosition @
@clickPending = true
else
@dead = false
Expand Down
11 changes: 8 additions & 3 deletions src/Window.moon
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
class Window
osdScale = settings['display-scale-factor']
@@osdScale = mp.get_property_number("display-hidpi-scale", 1)

@@w, @@h = 0, 0
@@_rawW, @@_rawH = 0, 0

@update: =>
w, h = mp.get_osd_size!
osdScale = mp.get_property_number("display-hidpi-scale", 1)

@_rawW, @_rawH = w, h
w, h = math.floor( w/osdScale ), math.floor( h/osdScale )
if w != @w or h != @h
@w, @h = w, h

if w != @w or h != @h or osdScale != @osdScale
@w, @h, @osdScale = w, h, osdScale
return true
else
return false
7 changes: 0 additions & 7 deletions src/settings.moon
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ Sets the height of the rectangular area at the top of the screen that shows the
file name and system time when the mouse is hovered over it.
]]

settings['display-scale-factor'] = 1
helpText['display-scale-factor'] = [[
Acts as a multiplier to increase the size of every UI element. Useful for high-
DPI displays that cause the UI to be rendered too small (happens at least on
macOS).
]]

settings['default-style'] = [[\fnSource Sans Pro\b1\bord2\shad0\fs30\c&HFC799E&\3c&H2D2D2D&]]
helpText['default-style'] = [[
Default style that is applied to all UI elements. A string of ASS override tags.
Expand Down
5 changes: 0 additions & 5 deletions torque-progressbar.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ hover-zone-height=40
# file name and system time when the mouse is hovered over it.
top-hover-zone-height=40

# Acts as a multiplier to increase the size of every UI element. Useful for high-
# DPI displays that cause the UI to be rendered too small (happens at least on
# macOS).
display-scale-factor=1

# Default style that is applied to all UI elements. A string of ASS override tags.
# Individual elements have their own style settings which override the tags here.
# Changing the font will likely require changing the hover-time margin settings
Expand Down

0 comments on commit 5d7a61a

Please sign in to comment.