When Wine starts in desktop mode, the Run dialog (opened via Start menu) shows an inactive title bar on the very first launch. Clicking elsewhere and re-opening the dialog restores the correct appearance. Root cause: during WM_INITDIALOG the dialog is still hidden, but SetFocus() on the edit control triggers set_active_window() via NtUserSetFocus(). At this point NtUserGetForegroundWindow() returns NULL because the wineserver sets foreground_input to NULL whenever the desktop window is made foreground (since the desktop cannot be a real foreground window). As a result WM_NCACTIVATE is sent with wParam=FALSE to the hidden dialog, clearing WIN_NCACTIVATED. When the dialog is subsequently shown, set_active_window() is not called again because the window was already registered as active, so WM_NCACTIVATE(TRUE) is never re-sent and the title bar is painted inactive. The same situation arises in root mode when winex11 explicitly calls NtUserSetForegroundWindowInternal(GetDesktopWindow()) on focus loss, which equally results in foreground_input=NULL. Fix: when set_active_window() sends WM_NCACTIVATE and there is no foreground window, treat the window being activated as if it were the foreground window rather than sending WM_NCACTIVATE(FALSE). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11074