Skip to content

ADD: desktop right-drag, Shift+F10 and Menu key (#40) - #73

Merged
CodingDiego merged 1 commit into
masterfrom
feat/desktop-rdrag-keys
Oct 11, 2026
Merged

CodingDiego merged 1 commit into
masterfrom
feat/desktop-rdrag-keys

Conversation

@CodingDiego

Copy link
Copy Markdown
Owner

Closes #40.

What changes

Right-drag on desktop icons. The --desktop helper's mouse hook used to swallow every right press on the desktop's icon list, so a right-drag never started. Now, once the pointer leaves the drag box, the swallowed press is replayed with SendInput: an absolute move to the press point, the button down, then a move back to the pointer. The replay is tagged, so the hook lets it through, and Explorer runs its own right-drag and drop menu (Move here, Copy here, Create shortcuts here). A release that comes before the replay still gets rexplorer's menu.

Shift+F10 and the Menu key. These now open rexplorer's menu while the desktop list has the keyboard, which a new WH_KEYBOARD_LL hook detects. The key-down, its auto-repeats and its key-up are all swallowed. The menu covers the selection and opens at the focused icon; with nothing selected it opens the background menu at the cursor. While an icon is being renamed, the keys go to the edit box as before.

Keyboard focus after the menu. The desktop gets the keyboard back, as after Explorer's own menu, after any of these:

  • a cancel;
  • Rename (its edit box needs the keys);
  • View, Sort or Refresh;
  • Copy, Cut or Create shortcut.

Paste and other shell verbs keep the foreground, because they may open a window of their own. To support this, ContextMenu::show_in now returns the canonical verb it invoked (Picked::Invoked(String)).

Review (Opus) — defects fixed before this PR

  • The replay was gated on GetAsyncKeyState, which never sees a press the hook swallowed, so right-drag never fired. Now only the replay clears PRESSED, so a release that comes first can no longer leave a button stuck.
  • With swapped mouse buttons, SendInput presses physical buttons, so a right-drag became a left drag with no drop menu. It now uses LEFTDOWN when SM_SWAPBUTTON is set.
  • A desktop switch (Win+L, UAC, Ctrl+Alt+Del) between the press and the release could leave a phantom drag. An EVENT_SYSTEM_DESKTOPSWITCH WinEvent now clears that state.
  • Restoring the foreground could steal it after Alt+Tab. It now restores only while the helper still has the foreground.
  • Absolute coordinates came out one pixel short. Rounding now goes up, and a test checks that every pixel round-trips on three screen layouts.
  • The keyboard hook swallowed vkCode 0.

Tests

  • cargo build/test --release --locked with -D warnings: app 87, core 86, all passing.
  • New unit tests: menu_keys, virtual_screen_to_absolute, drag_box, verbs_that_return_the_keyboard.
  • Not run on a live desktop. That needs the helper replaced and input sent to the real desktop. Manual checks after installing:
    1. Right-click an icon, then the background: rexplorer's menu, as before.
    2. Right-drag an icon and release: the drop menu appears. Pick Cancel, then right-click in another app: its own menu appears, so no button is stuck.
    3. Select an icon and press Shift+F10, then the Menu key: rexplorer's menu at the icon. Press Esc, then the arrows: the desktop selection moves.
    4. Pick Rename from the menu and type: the text goes into the edit box.
    5. Copy an icon from the menu, then press Ctrl+V on the desktop: it pastes.
    6. F10 or Shift+F10 in other apps, and the Menu key in a text field: these behave as before.

🤖 Generated with Claude Code

The --desktop helper's mouse hook swallowed every right press on the desktop's
icon list, so a right-drag never started. Once the pointer leaves the drag box,
the press is now replayed with SendInput (tagged, passed through by the hook) so
Explorer runs its own right-drag and drop menu; a release before the replay
still gets our menu. Swapped buttons, desktop switches (Win+L, UAC) and
one-pixel rounding in absolute coordinates are handled.

A low-level keyboard hook answers Shift+F10 and the Menu key while the desktop
list has the keyboard: rexplorer's menu for the selection, at the focused icon.

After a cancelled menu, Rename, a view command, Copy, Cut or Create shortcut the
desktop gets the keyboard back, as after Explorer's own menu; Paste and other
shell verbs keep it. ContextMenu::show_in now reports the invoked verb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CodingDiego
CodingDiego merged commit 83de9f7 into master Oct 11, 2026
2 checks passed
@CodingDiego
CodingDiego deleted the feat/desktop-rdrag-keys branch October 11, 2026 18:23
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.

Parity: Desktop menu completeness

1 participant