web: fixed race for organize_hook

This commit is contained in:
Maxim Devaev 2025-05-18 00:39:10 +03:00
parent 49fb9a6f92
commit 70ca478a78
3 changed files with 7 additions and 4 deletions

View File

@ -982,7 +982,7 @@
<div class="window" id="stream-ocr-window"> <div class="window" id="stream-ocr-window">
<div class="hidden" id="stream-ocr-selection"></div> <div class="hidden" id="stream-ocr-selection"></div>
</div> </div>
<div class="window window-resizable" id="stream-window" data-show-maximized> <div class="window window-resizable" id="stream-window" data-show-maximized data-organize-hook>
<div class="window-header" id="stream-window-header"> <div class="window-header" id="stream-window-header">
<div class="window-grab">MJPEG</div> <div class="window-grab">MJPEG</div>
<div class="window-buttons"> <div class="window-buttons">

View File

@ -1,7 +1,7 @@
.window#stream-ocr-window .window#stream-ocr-window
.hidden#stream-ocr-selection .hidden#stream-ocr-selection
.window.window-resizable#stream-window(data-show-maximized) .window.window-resizable#stream-window(data-show-maximized data-organize-hook)
.window-header#stream-window-header .window-header#stream-window-header
.window-grab MJPEG .window-grab MJPEG
.window-buttons .window-buttons

View File

@ -564,7 +564,7 @@ function __WindowManager() {
let ah = el_win.__aspect_ratio_height; let ah = el_win.__aspect_ratio_height;
let gw = view.right - view.left; let gw = view.right - view.left;
let gh = view.bottom - view.top; let gh = view.bottom - view.top;
if (el_win.organize_hook && aw && ah) { if (aw && ah) {
// Умная машинерия только для aspect-ratio // Умная машинерия только для aspect-ratio
if (aw / gw < ah / gh) { if (aw / gw < ah / gh) {
el_win.style.width = ""; el_win.style.width = "";
@ -574,7 +574,10 @@ function __WindowManager() {
el_win.style.height = ""; el_win.style.height = "";
el_win.style.width = gw + "px"; el_win.style.width = gw + "px";
} }
} else { } else if (!el_win.hasAttribute("data-organize-hook")) {
// FIXME: Можно было бы проверять наличие organize_hook,
// но эвент от обзервера приходит раньше чем настроятся хуки.
// По идее это надо бы глобально исправить.
el_win.style.width = gw + "px"; el_win.style.width = gw + "px";
el_win.style.height = gh + "px"; el_win.style.height = gh + "px";
} }