Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plugins/topbar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,15 @@ unsafe fn keys(vks: &[u16]) {
vks.iter().rev().for_each(|&v| send(v, true));
}

/// Releases `vk` alone: a swallowed key-up handed back to the shell as a synthetic one (see `run::kb_hook`).
unsafe fn key_up(vk: u16) {
let mut i: INPUT = zeroed();
i.r#type = INPUT_KEYBOARD;
i.Anonymous.ki.wVk = vk;
i.Anonymous.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &i, size_of::<INPUT>() as i32);
}

/// WM_CLOSE. A window of an elevated app ignores it from our normal-rights process (UIPI), so then
/// ask for admin once (UAC) and let an elevated taskkill send the close request.
unsafe fn close_window(w: HWND) {
Expand Down
10 changes: 9 additions & 1 deletion plugins/topbar/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,16 @@ pub(crate) unsafe extern "system" fn kb_hook(n: i32, w: WPARAM, l: LPARAM) -> LR
if down {
WIN_ALONE.store(true, Relaxed);
} else if WIN_ALONE.swap(false, Relaxed) {
keys(&[0xE8]); // an unassigned key between press and release: Windows no longer opens its own Start
// A lone Win *release* is what opens Windows' own Start. An E8 sent from here used to be queued behind
// the release already being dispatched, so the shell sometimes saw no other key in time and opened its
// Start on top of ours. Swallow the real release and hand the shell an E8 and then a synthetic Win-up:
// it sees a key between down and up (so no Start), and the synthetic up still clears the Win key for
// everything else (our own hook skips it: injected). A Win+key chord never reaches here: the key down
// clears WIN_ALONE before the release.
keys(&[0xE8]);
key_up(k.vkCode as u16);
PostMessageW(BAR.load(Relaxed) as HWND, WIN_START, 0, 0);
return 1;
}
} else if down {
WIN_ALONE.store(false, Relaxed); // Win+something else: a shortcut, not a Start press
Expand Down