Skip to content

Add mouse button (M3/M4/M5) support for client cycling and minimize-all - #135

Open
SiegEPS wants to merge 3 commits into
Proopai:unified-source-buildfrom
SiegEPS:feature/mouse-button-cycling
Open

Add mouse button (M3/M4/M5) support for client cycling and minimize-all#135
SiegEPS wants to merge 3 commits into
Proopai:unified-source-buildfrom
SiegEPS:feature/mouse-button-cycling

Conversation

@SiegEPS

@SiegEPS SiegEPS commented Jun 7, 2026

Copy link
Copy Markdown

What

Adds the middle mouse button (M3) and side buttons M4/M5 - with optional
Control/Shift/Alt modifiers - as triggers for the cycle groups and
Minimize-All, alongside the existing keyboard hotkeys.

How

  • New MouseHookHandler / MouseHookNativeMethods: a single shared
    low-level mouse hook (WH_MOUSE_LL) with a small binding registry,
    exact-modifier matching, and bound-button swallowing (unbound buttons
    pass through).
  • ThumbnailManager routes mouse tokens to the hook and keyboard tokens
    to RegisterHotKey, reusing the existing CycleGroupNForward/Backward
    and MinimizeAllClients config lists (tokens like M5, Control+M4).
  • WindowManager.ActivateWindow uses AttachThreadInput so hook-triggered
    activation can change the foreground window (Windows otherwise refuses it
    from a background context).

Config

Mouse tokens go in the existing hotkey lists, e.g.:
"CycleGroup1ForwardHotkeys": [ "F14", "M5", "Control+M5" ]
Accepts M3/Middle/MButton, M4/Mouse4/XButton1, M5/Mouse5/XButton2.

Testing

Builds clean on both Windows and Linux targets. Verified live with real
EVE clients and in isolation (forward/back cycling switches the actual
foreground window; unbound buttons pass through). README docs added.

SiegEPS added 3 commits June 7, 2026 15:27
Cycle hotkeys previously used RegisterHotKey, which is keyboard-only.
Add a shared low-level mouse hook (WH_MOUSE_LL) so the middle button and
side buttons M4/M5 - with optional Control/Shift/Alt modifiers - can
trigger the cycle groups and minimize-all.

Mouse buttons share the existing CycleGroupNForward/BackwardHotkeys and
MinimizeAllClientsHotkeys config lists; tokens like M5 or Control+M4
are routed to the hook while keyboard tokens still use RegisterHotKey.
Only bound buttons are swallowed, so unbound clicks pass through.
Windows refuses SetForegroundWindow from a process that did not receive
the last input event, so cycling triggered by the global mouse hook only
flashed the target's taskbar button instead of activating it. Attach to
the foreground window's input thread before SetForegroundWindow to gain
the right to change the foreground, then detach. Paths that already hold
that right (thumbnail click, keyboard hotkey) are unaffected.
The mouse hook invoked the cycle action (CycleNextClient ->
ForceSetForegroundWindow: AttachThreadInput + SetForegroundWindow) directly
inside the WH_MOUSE_LL callback, which runs on the system input path. Doing the
foreground switch there could wedge the target window's input queue, leaving the
EVE client unresponsive until the foreground state was reset by other means.

Capture the UI SynchronizationContext when the hook is installed and post the
cycle action to it, so the work runs in the normal message pump - exactly like
the keyboard hotkey (WM_HOTKEY) path, which never exhibited the hang. The hook
now returns immediately after swallowing the bound button.
@izakbar

izakbar commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

@SiegEPS not ignoring this!
I have pulled it into a dev branch and been doing some testing
It largely seems to work - but I am having total mouse lockout when switching quickly (maybe 2-3 clicks per sec to cycle 7 toons) and can only get mouse control again after ctrl-alt-del and task manager foo.
I suspect it might the input hook - but need to test some more. sometimes the switch seems slower than previously too - but again need bit more testing,.
It is key that switching is as fast as possible - especially for high toon count users.

@SiegEPS

SiegEPS commented Jun 13, 2026

Copy link
Copy Markdown
Author

Sure, you are having that problem even after the most recent commit? I haven't seen it but can test more.

@izakbar

izakbar commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

OOo will pull that in and see :)

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.

2 participants