From d6f3d7c380ca16b4c5bac3d5d3de1e7334f07f8b Mon Sep 17 00:00:00 2001 From: saphid <4596216+saphid@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:10:00 +1000 Subject: [PATCH] Set Windows DPI coordinates before native plugin initialization --- ui/frame_pc_capture.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/frame_pc_capture.py b/ui/frame_pc_capture.py index 6d29874..0e3366c 100644 --- a/ui/frame_pc_capture.py +++ b/ui/frame_pc_capture.py @@ -27,6 +27,11 @@ class Native: def __init__(self, path=LIBRARY): self.dll_dirs = [] if sys.platform == 'win32': + # Set process coordinates before loading GStreamer: a plugin may + # create a helper HWND during discovery, after which it is too late. + user = C.WinDLL('user32') + user.SetProcessDpiAwarenessContext.argtypes = [C.c_void_p] + user.SetProcessDpiAwarenessContext(C.c_void_p(-4)) for folder in (path.parent, path.parent / 'bin'): self.dll_dirs.append(os.add_dll_directory(str(folder))) self.lib = C.CDLL(str(path)) @@ -208,8 +213,6 @@ class Windows: self.W = W self.user = C.WinDLL('user32', use_last_error=True) self.dwm = C.WinDLL('dwmapi') - self.user.SetProcessDpiAwarenessContext.argtypes = [C.c_void_p] - self.user.SetProcessDpiAwarenessContext(C.c_void_p(-4)) # per-monitor v2 self.user.IsWindow.argtypes = [W.HWND] self.user.IsWindowVisible.argtypes = [W.HWND] self.user.IsIconic.argtypes = [W.HWND]