-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
BugSomething isn't workingSomething isn't working
Description
Description
When running a new Wails app on Windows with StartHidden: true, the current window becomes unfocused.
To Reproduce
- Open any application on your Windows computer
- Call
wails.Runwith the optionStartHidden: true(among your other values). Make sure to add a delay before like `time.Sleep(5 * time.Second) to allow you to set up the rest of the bug. - Focus your application (that isn't Wails). Make sure it is focused by trying to enter text, for example.
- The Wails window should now open (in the background), and your application should lose focus.
Expected behaviour
When opening with StartHidden: true, the current open application does not lose focus
Screenshots
No response
Attempted Fixes
The root cause is in internal/frontend/desktop/windows/winc/form.go:171 In Center():
w32.SetWindowPos(fm.hwnd, w32.HWND_TOP, int(windowX), int(windowY), int(winWidth), int(winHeight), w32.SWP_NOSIZE)The SetWindowPos call uses HWND_TOP but does not include the SWP_NOACTIVATE flag. Without this flag, Windows activates the window when positioning it, which steals focus from the foreground application.
Proposed fix:
w32.SetWindowPos(fm.hwnd, w32.HWND_TOP, int(windowX), int(windowY), int(winWidth), int(winHeight), w32.SWP_NOSIZE|w32.SWP_NOACTIVATE)System Details
Wails Doctor
# Wails
Version | v2.11.0
# System
┌────────────────────────────────────────────────────────────────────────────────────────┐
| OS | Windows 10 Pro for Workstations |
| Version | 2009 (Build: 26200) |
| ID | 25H2 |
| Branding | Windows 11 Pro for Workstations |
| Go Version | go1.25.5 |
| Platform | windows |
| Architecture | arm64 |
| CPU | Apple Silicon |
| GPU | Parallels Display Adapter (WDDM) (Parallels) - Driver: 20.18.2612.57293 |
| Memory | 8GB |
└────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version |
| WebView2 | N/A | Installed | 143.0.3650.139 |
| Nodejs | N/A | Available | |
| npm | N/A | Available | |
| *upx | N/A | Available | |
| *nsis | N/A | Available | |
| |
└─────────────── * - Optional Dependency ────────────────┘
``Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working
Type
Projects
Status
Backlog