diff options
authorwm4 <wm4@nowhere>2019-12-20 12:53:56 +0100
committerwm4 <wm4@nowhere>2019-12-20 13:00:39 +0100
commit05cd4c9e08f93943bd74f70bf7827fdbf952f17b (patch)
parentac474631c1b0a3f98b0e4cb22127afe0f8eb9292 (diff)
console: use hidpi scale reporting
I decided to factor this into the user's scale option (instead of somehow using it as default if the user has not specified it), because it makes the option handling simpler, and won't break things like per-screen DPI if the user only wants to scale the console font by a factor.
2 files changed, 11 insertions, 3 deletions
diff --git a/DOCS/man/console.rst b/DOCS/man/console.rst
index 89726b72a6..3c83d7e877 100644
--- a/DOCS/man/console.rst
+++ b/DOCS/man/console.rst
@@ -89,7 +89,10 @@ Configurable Options
Default: 1
All drawing is scaled by this value, including the text borders and the
- cursor. Change it if you have a high-DPI display.
+ cursor.
+ If the VO backend in use has HiDPI scale reporting implemented, the option
+ value is scaled with the reported HiDPI scale.
Default: unset (picks a hardcoded font depending on detected platform)
diff --git a/player/lua/console.lua b/player/lua/console.lua
index bc74b5d313..c59874cd32 100644
--- a/player/lua/console.lua
+++ b/player/lua/console.lua
@@ -143,9 +143,13 @@ end
function update()
pending_update = false
+ local dpi_scale = mp.get_property_native("display-hidpi-scale", 1.0)
+ dpi_scale = dpi_scale * opts.scale
local screenx, screeny, aspect = mp.get_osd_size()
- screenx = screenx / opts.scale
- screeny = screeny / opts.scale
+ screenx = screenx / dpi_scale
+ screeny = screeny / dpi_scale
-- Clear the OSD if the REPL is not active
if not repl_active then
@@ -675,6 +679,7 @@ end)
-- PlayRes of the OSD will need to be adjusted.
mp.observe_property('osd-width', 'native', update)
mp.observe_property('osd-height', 'native', update)
+mp.observe_property('display-hidpi-scale', 'native', update)
-- Enable log messages. In silent mode, mpv will queue log messages in a buffer
-- until enable_messages is called again without the silent: prefix.