Skip to content

Fix ghost window on Windows by using proper dialog window flags#13201

Open
mattezell wants to merge 2 commits intokeepassxreboot:developfrom
mattezell:fix/update-check-dialog-ghost-window
Open

Fix ghost window on Windows by using proper dialog window flags#13201
mattezell wants to merge 2 commits intokeepassxreboot:developfrom
mattezell:fix/update-check-dialog-ghost-window

Conversation

@mattezell
Copy link
Copy Markdown

On Windows 11, the UpdateCheckDialog leaves behind a transparent, non-interactive ghost window frame that persists even after the KeePassXC process has fully exited. The only way to remove this phantom window is to reboot. This has been reported and reproduced by multiple users (see #9493).

The root cause is setWindowFlags(Qt::Window) in the UpdateCheckDialog constructor. Using bare Qt::Window on a QDialog causes Windows DWM (Desktop Window Manager) to create an independently managed top-level composition surface for the dialog. If the dialog's native HWND is not cleanly destroyed through the normal DestroyWindow -> WM_NCDESTROY sequence (e.g., during process exit while the dialog exists, or during an update installation), DWM is left with an orphaned composition surface -- the title bar, borders, and shadow that DWM draws itself -- which persists as a ghost frame even after the owning process is gone.

This change replaces Qt::Window with Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint, which:

  • Keeps the dialog properly associated with its parent window in DWM's composition tree
  • Preserves the expected title bar and close button appearance
  • Prevents the orphaned DWM frame by ensuring proper dialog window lifecycle management

Fixes #9493

Screenshots

N/A - This is a window flags change that prevents a ghost window artifact. The dialog's visual appearance remains the same.

Testing strategy

  1. Built and ran KeePassXC on Windows 11
  2. Triggered the update check dialog via Help -> Check for Updates
  3. Verified the dialog appears correctly with title bar and close button
  4. Closed the dialog and exited KeePassXC
  5. Confirmed no ghost window frame remains after process exit

Generative AI (Claude) was used to help identify the root cause and suggest the fix.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (change that adds functionality)
  • Breaking change (causes existing functionality to change)
  • Refactor (significant modification to existing code)
  • Documentation (non-code change)

Replace Qt::Window with Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint
in UpdateCheckDialog to prevent an orphaned DWM window frame on Windows 11.

Using bare Qt::Window on a QDialog causes Windows DWM to create an independently
managed top-level composition surface. If the dialog's native handle is not
cleanly destroyed (e.g., during process exit while the dialog exists), DWM can
leave behind a transparent, non-interactive ghost window frame that persists
even after the process is gone and can only be cleared by rebooting.

Using Qt::Dialog keeps the dialog properly associated with its parent window
in DWM's composition tree, preventing the orphaned frame.

Fixes keepassxreboot#9493
Copilot AI review requested due to automatic review settings March 26, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the UpdateCheckDialog window flags to ensure it behaves as a proper dialog on Windows, preventing an orphaned “ghost” window frame from being left behind by DWM after app exit (per #9493).

Changes:

  • Replaces setWindowFlags(Qt::Window) with dialog-appropriate flags (Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint) in UpdateCheckDialog.
  • Preserves expected title bar / close button while avoiding Windows 11 ghost frame behavior.

Comment thread src/gui/UpdateCheckDialog.cpp Outdated
@droidmonkey
Copy link
Copy Markdown
Member

Looks great but fix your code format

@mattezell
Copy link
Copy Markdown
Author

Fixed the indentation in 03b3c64. Thanks for the quick review!

@mattezell
Copy link
Copy Markdown
Author

@droidmonkey anything that I need to action on with this?

I see the failures, but they don't seem to be related to my change - and I also notice that many other PRs have failed in what seems to be basically the same way, almost as if it's environmental in the build / test env.

@droidmonkey
Copy link
Copy Markdown
Member

Unrelated, you are good to go here

@ForNeVeR

This comment was marked as off-topic.

@mattezell

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Software Update" window cannot be interacted with on Windows

4 participants