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

Windows Fix Multiple Monitor Mouse Input #158

Open
wants to merge 12 commits into
base: 1.3
Choose a base branch
from

Conversation

FaithBeam
Copy link

@FaithBeam FaithBeam commented Feb 19, 2023

Hello! This PR fixes libuiohook's issue with multi-monitor mouse input and movement for Windows.

Very quickly, this is done by converting the low-level mouse hook coordinates that libuiohook returns to be relative to the virtual desktop. It creates an invisible window and listens for the WM_DISPLAYCHANGE event which is sent whenever a monitor changes position or resolution to get the width and height of monitors in relation to the primary monitor. I wrote some notes and examples here if you want to take a look: https://i.imgur.com/z3vKjtm.png

This video shows a modified demo_hook/post_async with the change. This change does not touch dpi stuff, so the calling application should set something like SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); to handle monitors that are not 100% scale.
https://youtu.be/YhrC_oLPtRM

The modified program listens for middle mouse button release and sends a right mouse button down and up at the current mouse coordinates.

This is the sample program: https://gist.github.com/FaithBeam/e90bad32fd2fef0c825cfa9c403f9e7b

Should fix #21.

@TolikPylypchuk
Copy link
Contributor

@FaithBeam this pull request is a little out of date - could you please rebase it on top of the 1.3 branch and resolve conflicts? Also, the original pull request contained a couple more commits - could you add them here as well?

@kwhat did you have a chance to review this pull request?

@FaithBeam
Copy link
Author

@TolikPylypchuk if @kwhat expresses interest in this, I'll update the PR.

@kwhat
Copy link
Owner

kwhat commented Jun 27, 2023

Ive looked at this vut i still dont understand why its needed.

@FaithBeam
Copy link
Author

FaithBeam commented Jun 28, 2023

It's been a while since I last looked at the code, but libuiohook doesn't calculate the correct coordinates for mouse input when multiple monitors are connected on Windows.

One monitor: works
Multiple monitors: broken

This PR fixes multiple monitor mouse input for Windows.

@FaithBeam FaithBeam closed this Jun 28, 2023
@FaithBeam
Copy link
Author

Sorry, I accidentally closed this. Reopening.

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.

3 participants