Skip to content

Fix Alt+F4 behavior to open shutdown box on desktop - #201

Closed
ZyyXD1 wants to merge 1 commit into
Lemxy:mainfrom
ZyyXD1:fix/alt-f4-desktop
Closed

ZyyXD1 wants to merge 1 commit into
Lemxy:mainfrom
ZyyXD1:fix/alt-f4-desktop

Conversation

@ZyyXD1

@ZyyXD1 ZyyXD1 commented Nov 27, 2026 •

Copy link
Copy Markdown

Fixes #189

Problem

With rust-explorer drawing the desktop, pressing Alt+F4 on it destroyed the desktop window and ended its process. The wallpaper and icons disappeared and no shut down dialog appeared.

Cause

The desktop window did not handle WM_CLOSE, so DefWindowProcW destroyed it.

Fix

  • The desktop now handles WM_CLOSE by opening a native task dialog: Shut down (focused by default), Restart, Sleep, Sign out and Cancel.
  • Only one dialog opens at a time. It runs on its own thread, so the desktop keeps working.
  • The sleep code moved from topbar to winrust-common, so both programs share it.
  • Dialog labels are in all five UI languages.
  • Closing normal file manager windows is unchanged.

Behaviour notes

  • Any other WM_CLOSE sent to the desktop also opens the dialog.
  • Shut down runs shutdown /s /t 0, the same command the top bar uses (no Fast Startup).
  • The dialog uses the standard Windows look, not the WinRust theme.

Testing

  • winrust-common tests pass (25/25), including the new power action test
  • rust-explorer tests pass
  • Alt+F4 on the desktop opens the dialog, and Esc leaves the desktop in place
  • Alt+F4 on a normal window closes only that window
  • Shut down, Restart, Sleep and Sign out each work

cargo test --workspace stops at a failing rtaskmgr-win32 test on my machine. That crate's tests also fail on fb1688a without this change. Test programs after it, including topbar, were not reached in that run.

Related

Changes to the hardware smoke tests in gpu.rs and hw.rs are not part of this PR. They will be submitted separately.

@Lemxy

Lemxy commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Thank you! Merged into the dev branch as a squash commit with you credited as co-author (Co-authored-by), and added you to CONTRIBUTORS.md; it goes to main and the next release from there. I moved the shut-down box into common and kept your topbar sleep_now change. Closing here because GitHub does not see squash merges as merged.

@Lemxy Lemxy closed this Nov 27, 2026
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.

Feature request: Alt+F4 on the desktop should open the shutdown/restart dialog

2 participants