Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Windows Precision Touchpad support for Simple Window Switcher #516

Closed
LukeGotBored opened this issue Dec 6, 2021 · 2 comments
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@LukeGotBored
Copy link

Hi there! I was testing some trackpad gestures when I noticed that swiping left/right with 3 fingers still brings up the windows 11 activity switcher, even though the window switcher is set to windows 10

valinet added a commit that referenced this issue Dec 6, 2021
@valinet
Copy link
Owner

valinet commented Dec 6, 2021

Hi

Well, I don't know exactly on what version you are. If you upgrade to the latest pre-release (at least 40.5), the window switcher that gets invoked when using gestures based on what you set in Properties is:

  • Windows 11 - the Windows 11 window switcher is presented
  • Windows 10 - the original Windows 10 window switcher is presented
  • Windows NT - the Windows 11 window switcher is presented
  • Simple Windows Switcher - the original Windows 10 window switcher is presented

The reason for the last 2 decisions is complicated. I will describe below what information I have on this matter. I am assuming we are talking about Windows Precision Touchpads here.

Firstly, the way gestures invoke the window switcher is via some internal, undocumented mechanism, not by simulating an Alt+Tab press in software. The reason for that is because an initial swipe indeed invokes the switcher, but it remains on-screen until the fingers are lifted (so something like Ctrl+Alt+Tab). But it also cycles through the list as you move the fingers left/right, as if pressing the key combination again, although that's not really the case if you manually assign that shortcut in Settings (i.e. it is sent only once, when you initially swipe). Also, when you lift the fingers, the switcher switches to the application currently highlighted in it. So yeah, it's definitely not a software simulation of pressing Alt+Tab. It's some other mechanism, which, of course, is entirely internal and undocumented, as it's usually the case with almost every interesting thing in this OS.

Naturally, neither the Windows NT switcher, which is a legacy component hosted directly in the user space keyboard filter, in csrss is not aware of that interface, nor is my custom Simple Window Switcher aware of that. So both of these do not override when that interface is invoked, so the Windows 11 switcher is still invoked. A solution to this would be, of course, to manually map Ctrl+Alt+Tab for the swipe left/right actions in Settings when using Simple Window Switcher. This will indeed bring the legacy up the correct switcher, although further swiping would make no modification in it. You'd need to lift the fingers and swipe again to have it react, and also press some key to accept the highlight.

To solve that up, there isn't an easy fix:

  • Gestures with more than 3 fingers are reserved for the exclusive use of the operating system, as far as I know. There does not seem to be any Windows Precision Touchpad API that would communicate you the gestural status of the device. WM_TOUCH or WM_GESTURE messages are not generated when using the touchpad, at least that's how it is on my Dell XPS 15 7590. This would be the ideal solution, if there was somehow an official API for this that would communicate this in a straightforward manner and would allow applications to register their custom handlers for 3/4 finger gestures and receive notifications for that. One can always dream...
  • Determining what that undocumented Alt+Tab interface is and hooking into that would be ideal, but it is pretty hard to do. Idk, maybe it lives in twinui.pcshell.dll, as other shell stuff lives there, maybe somewhere else, idk, I haven't looked into that. This, of course, comes with all the pitfalls of hooking stuff, and depending how the actual thing looks when/if we find it, hooking using symbol information might be the only way to do this, and this would yet again introduce another dependency on symbols. The happy case would be for it to be a callback-based interface hosted by whatever component, in which case we could reverse engineer how it works, register a callback and be notified of events by it as well, similarly to how the window switcher receieves global notifications for when the keyboard layout changes (there is no public API for that, but InputSwitch.dll exposes an interface which can be used to set up a callback routine in one's application that gets notified). But idk if that's the case. Anyway, if implemented, this would be like the ideal solution above, basically work as the original, only problem is, it's very hard to determine how the damn thing works internally without access to the source code or at least some pointers for them. It's doable, yet it's another of those things which takes ages to do and get it done and I am kind of tired of these... I have some ideas, but it's a lot of trial and error to get done right. Exploring the MultitaskingView... functions in twinui.pcshell.dll is a good starting point.
  • There would be another solution of setting custom shortcuts for 3 or 4 finger right/left swipes in the Settings to Ctrl+Alt+Tab and Ctrl+Shift+Alt+Tab. Once that invokes the window switcher, use raw input messages to determine how many fingers are present on the touchpad and move the selection after the fingers moved some amount and switch to the selected window when the fingers are lifted. Basically, more or less reimplement Windows' built-in handler or these. This is the most documented doable way, but it poses several disadvantages:
    • The user has to manually configure the shortcuts in Settings.
    • Precision Touchpad gesture handling has to be pretty much reimplemented.
    • Have to retrieve the settings from registry and parse them to determine whether the user configured left/right swipes or other swipes and with how many fingers.
    • Configuring shortcut keys for gestures has a nasty limitations: the dispatcher seems to be in explorer.exe or maybe ShellExperienceHost.exe. The problem with that is it runs as the standard user, at its low integrity level, so the key combinations cannot be sent when the foreground process is running at a higher integrity level (e.g. when the foreground application is running as administrator). This is a general limitation of their entire architecture. Set any gesture in Settings to trigger a key combination and observe how it fails to work in Task Scheduler or Task Manager (which are automatically elevated), or any elevated app. It's pretty stupid, if you ask me, especially considering this is an OS level feature, but it is what it is.
    • So yeah, this solution is the most complex and best you could get with sticking to official methods, but I think it has too many limitations to be worth continuing down its path. It would also take ages to properly implement to its maximum potential.

So yeah, that's the story of this. To mitigate this in the mean time, regarding gestures for the Windows NT and Simple Window Switcher, I included some code that just shows the Windows 11 window switcher when doing a gesture with the Windows NT switcher enabled, or the Windows 10 switcher when doing a gesture with the Simple Window Switcher enabled. For the moment, it works, although, yeah, ideally, the Simple Window Switcher should be activatable and navigatable using touchpad gestures.

Of course, a contribution in this area would be more than great. Each and very day I realize how much work is actually needed in actually shipping an operating system and its interface. The more I learn stuff, the more I feel that I know so few and that there's so much unknown out there...

tl;dr This is a hard one to properly fix.

@valinet valinet added enhancement New feature or request help wanted Extra attention is needed labels Dec 6, 2021
@valinet valinet changed the title Trackpad gestures still bring windows 11's window switcher Implement Windows Precision Touchpad support for Simple Window Switcher Dec 6, 2021
@valinet valinet pinned this issue Dec 28, 2021
@valinet valinet closed this as completed Dec 28, 2021
@Vipin2003
Copy link

  1. Can you add the R-to-L swipe (like the Win10 Switcher have) in Simple Window Switcher (sws) as it was very helpful. Win10 Switcher have this ability but not Win11 nor SWS. It will really enhance the use of SWS.
  2. There is a bug with sws that if we are using 3-F gesture to switch and accidently swipe UP, it opens the win7 switcher over the sws. I've already marked it in Issues.
  3. Please add a option to disable the "swipe down to open clock" while switching in every switcher.

@Amrsatrio Amrsatrio unpinned this issue Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants