Tischel / TPie

FFXIV Dalamud plugin for ring-shaped hotbars
GNU Affero General Public License v3.0
34 stars 16 forks source link

Mouse jumps to the center of primary monitor (incorrectly) when opening nested ring #24

Closed Zenith-One closed 2 years ago

Zenith-One commented 2 years ago

As the title indicates, any time I open a nested ring with "keep previous ring center", my mouse cursor jumps to the center of my primary monitor. This behavior happens regardless of whether the FF window is on that monitor or not, or whether it's windowed or full screen.

Looking at the code, it seems the most likely culprit is this bit.

For reference, I'm running on Windows, and using TPie v1.2.1.0

Zenith-One commented 2 years ago

Looking at it further, I think the problem is that the code takes the coordinates of the center of the circle in the context of the FF window and then moves the mouse to those coordinates. However I think SetCursorPos uses system display as its baseline, not the FF window. In order to achieve the correct behavior using that method, I think you would need to somehow figure out where the FF window lives and then do some math.

Alternately if it is possible to check where the mouse position is in the FF window, you could find the difference between the mouse position in the FF window and the desired position to move it to within the FF window. Then, figure out the global mouse x/y, and apply the same difference to it.

For example, if the center of the pie should be at (50,50) in the FF window, but the mouse is at (30,60), the desired change would be (20,-10). Then, you find the global mouse x,y is say (1020, 986). So you set the mouse cursor position to (1040, 976)

Zenith-One commented 2 years ago

I didn't realize until just now that this is a duplicate of #23. Sorry about that!

Closing this one and condensing the above comments into one comment in the other user's issue.