From 3e6650eb2e3697e418a4b3fff49e94650e09db91 Mon Sep 17 00:00:00 2001 From: lm Date: Sun, 19 Oct 2025 18:47:46 +0200 Subject: [PATCH] Ensure Windows borderless window registers as taskbar app --- app/app.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index 23109ab..1289b3a 100644 --- a/app/app.py +++ b/app/app.py @@ -111,16 +111,27 @@ class ICRAApp( return GWL_EXSTYLE = -20 + GWL_HWNDPARENT = -8 WS_EX_TOOLWINDOW = 0x00000080 WS_EX_APPWINDOW = 0x00040000 SWP_NOSIZE = 0x0001 SWP_NOMOVE = 0x0002 SWP_NOZORDER = 0x0004 SWP_FRAMECHANGED = 0x0020 + SWP_NOOWNERZORDER = 0x0200 + SWP_SHOWWINDOW = 0x0040 user32 = ctypes.windll.user32 # type: ignore[attr-defined] shell32 = ctypes.windll.shell32 # type: ignore[attr-defined] + set_long = getattr(user32, "SetWindowLongPtrW", user32.SetWindowLongW) + get_long = getattr(user32, "GetWindowLongPtrW", user32.GetWindowLongW) + ptr_type = ctypes.c_longlong if ctypes.sizeof(ctypes.c_void_p) == 8 else ctypes.c_long + get_long.restype = ptr_type # type: ignore[attr-defined] + get_long.argtypes = [wintypes.HWND, ctypes.c_int] # type: ignore[attr-defined] + set_long.restype = ptr_type # type: ignore[attr-defined] + set_long.argtypes = [wintypes.HWND, ctypes.c_int, ptr_type] # type: ignore[attr-defined] + style = user32.GetWindowLongW(hwnd, GWL_EXSTYLE) new_style = (style & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW if new_style != style: @@ -132,9 +143,19 @@ class ICRAApp( 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED | SWP_SHOWWINDOW, ) - user32.ShowWindow(hwnd, 5) # SW_SHOW + + set_long(hwnd, GWL_HWNDPARENT, ptr_type(0)) + user32.SetWindowPos( + hwnd, + 0, + 0, + 0, + 0, + 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_SHOWWINDOW, + ) app_id = ctypes.c_wchar_p("ICRA.App") shell32.SetCurrentProcessExplicitAppUserModelID(app_id)