| @@ -20,6 +20,7 @@ local opts = { · 19 unmodified lines |
| 20 | font = "", | 20 | font = "", |
| 21 | font_size = 16, | 21 | font_size = 16, |
| 22 | border_size = 1, | 22 | border_size = 1, |
| | 23 | scale_with_window = "auto", |
| 23 | case_sensitive = true, | 24 | case_sensitive = true, |
| 24 | history_dedup = true, | 25 | history_dedup = true, |
| 25 | font_hw_ratio = 'auto', | 26 | font_hw_ratio = 'auto', |
| @@ -230,6 +231,30 @@ local function ass_escape(str) · 204 unmodified lines |
| 230 | return mp.command_native({'escape-ass', str}) | 231 | return mp.command_native({'escape-ass', str}) |
| 231 | end | 232 | end |
| 232 | | 233 | |
| | 234 | local function should_scale() |
| | 235 | return opts.scale_with_window == "yes" or |
| | 236 | (opts.scale_with_window == "auto" and mp.get_property_native("osd-scale-by-window")) |
| | 237 | end |
| | 238 | |
| | 239 | local function get_scaled_osd_dimensions() |
| | 240 | local w, h, aspect = mp.get_osd_size() |
| | 241 | |
| | 242 | if w == 0 then |
| | 243 | return 0, 0 |
| | 244 | end |
| | 245 | |
| | 246 | if should_scale() then |
| | 247 | h = 720 |
| | 248 | w = 720 * aspect |
| | 249 | end |
| | 250 | |
| | 251 | local scale = mp.get_property_native('display-hidpi-scale') |
| | 252 | w = w / scale |
| | 253 | h = h / scale |
| | 254 | |
| | 255 | return w, h |
| | 256 | end |
| | 257 | |
| 233 | local function calculate_max_log_lines() | 258 | local function calculate_max_log_lines() |
| 234 | if not mp.get_property_native('vo-configured') | 259 | if not mp.get_property_native('vo-configured') |
| 235 | or not mp.get_property_native('video-osd') then | 260 | or not mp.get_property_native('video-osd') then |
| @@ -239,8 +264,7 @@ local function calculate_max_log_lines() · 3 unmodified lines |
| 239 | select(2, mp.get_property('term-status-msg'):gsub('\\n', '')) | 264 | select(2, mp.get_property('term-status-msg'):gsub('\\n', '')) |
| 240 | end | 265 | end |
| 241 | | 266 | |
| 242 | return math.floor(mp.get_property_native('osd-height') | 267 | return math.floor(select(2, get_scaled_osd_dimensions()) |
| 243 | / mp.get_property_native('display-hidpi-scale', 1) | | |
| 244 | * (1 - global_margins.t - global_margins.b) | 268 | * (1 - global_margins.t - global_margins.b) |
| 245 | / opts.font_size | 269 | / opts.font_size |
| 246 | -- Subtract 1 for the input line and 1 for the newline | 270 | -- Subtract 1 for the input line and 1 for the newline |
| @@ -476,10 +500,7 @@ local function update() · 229 unmodified lines |
| 476 | return | 500 | return |
| 477 | end | 501 | end |
| 478 | | 502 | |
| 479 | local screenx, screeny = mp.get_osd_size() | 503 | local screenx, screeny = get_scaled_osd_dimensions() |
| 480 | local dpi_scale = mp.get_property_native('display-hidpi-scale', 1) | | |
| 481 | screenx = screenx / dpi_scale | | |
| 482 | screeny = screeny / dpi_scale | | |
| 483 | | 504 | |
| 484 | local bottom_left_margin = 6 | 505 | local bottom_left_margin = 6 |
| 485 | | 506 | |
| @@ -784,16 +805,16 @@ local function handle_enter() · 298 unmodified lines |
| 784 | end | 805 | end |
| 785 | | 806 | |
| 786 | local function determine_hovered_item() | 807 | local function determine_hovered_item() |
| 787 | local height = mp.get_property_native('osd-height') | 808 | local height = select(2, get_scaled_osd_dimensions()) |
| 788 | if height == 0 then | 809 | local y = mp.get_property_native('mouse-pos').y |
| 789 | return | 810 | if should_scale() then |
| | 811 | y = y * 720 / mp.get_property_native('osd-height') |
| 790 | end | 812 | end |
| 791 | | 813 | y = y - global_margins.t * height |
| 792 | local y = mp.get_property_native('mouse-pos').y - global_margins.t * height | | |
| 793 | -- Calculate how many lines could be printed without decreasing them for | 814 | -- Calculate how many lines could be printed without decreasing them for |
| 794 | -- the input line and OSC. | 815 | -- the input line and OSC. |
| 795 | local max_lines = height / mp.get_property_native('display-hidpi-scale') | 816 | local max_lines = height / mp.get_property_native('display-hidpi-scale', 1) |
| 796 | / opts.font_size | 817 | / opts.font_size |
| 797 | local clicked_line = math.floor(y / height * max_lines + .5) | 818 | local clicked_line = math.floor(y / height * max_lines + .5) |
| 798 | | 819 | |
| 799 | local offset = first_match_to_print - 1 | 820 | local offset = first_match_to_print - 1 |