fix: osd resolution initializing incorrectly (#383)

* fix: only update resolution when it's > 0

* fix: only render after the resolution has been initialized

* chore: update type annotation to fix warning
This commit is contained in:
christoph-heinrich
2022-12-04 09:09:20 +01:00
committed by GitHub
parent b75ceb6d6f
commit 8b863a611f
3 changed files with 14 additions and 4 deletions

View File

@@ -268,7 +268,7 @@ end
--[[ STATE ]]
display = {width = 1280, height = 720, scale_x = 1, scale_y = 1}
display = {width = 1280, height = 720, scale_x = 1, scale_y = 1, initialized = false}
cursor = {hidden = true, x = 0, y = 0}
state = {
os = (function()
@@ -343,9 +343,11 @@ require('uosc_shared/lib/menus')
function update_display_dimensions()
local scale = (state.hidpi_scale or 1) * options.ui_scale
local real_width, real_height = mp.get_osd_size()
if real_width <= 0 then return end
local scaled_width, scaled_height = round(real_width / scale), round(real_height / scale)
display.width, display.height = scaled_width, scaled_height
display.scale_x, display.scale_y = real_width / scaled_width, real_height / scaled_height
display.initialized = true
-- Tell elements about this
Elements:trigger('display')