feschber / lan-mouse

mouse & keyboard sharing via LAN
GNU General Public License v3.0
2.17k stars 60 forks source link

cursor bound to single screen #83

Open jpeeler opened 6 months ago

jpeeler commented 6 months ago

With the merge of #81, I was able to test lan-mouse for the first time between a Linux server and MacOS client. I'm using multiple screens and see that when the mouse works on the remote client screen, it is not able to continue to the adjoining screens.

I was kind of hoping that the mouse would automatically release on the edge when traversing to go back to the server. Unsure if that's because of the above issue or if you have to press the release keys by design.

(Unrelated, but there is some keyboard weirdness with the server not passing through keystrokes that are already mapped for usage in the compositor. Will report that later in another issue.)

feschber commented 6 months ago

Yes, this is macos related. The API is a bit weird there: https://github.com/feschber/lan-mouse/blob/5cc8cda19d2bef25cff0d767361d0622a8fbf3e8/src/backend/consumer/macos.rs#L120

Problem is that unless the absolute mouse position is restricted to screen boundaries, the relative motion gets lost in fullscreen applications. I currently restrict it to the primary screen. Need to fix that but have not yet found the time.

diff --git a/src/backend/consumer/macos.rs b/src/backend/consumer/macos.rs
index 954ec2b..3c45e13 100644
--- a/src/backend/consumer/macos.rs
+++ b/src/backend/consumer/macos.rs
@@ -135,8 +135,8 @@ impl EventConsumer for MacOSConsumer {
                         }
                     };

-                    mouse_location.x = (mouse_location.x + relative_x).clamp(min_x, max_x - 1.);
-                    mouse_location.y = (mouse_location.y + relative_y).clamp(min_y, max_y - 1.);
+                    mouse_location.x = (mouse_location.x + relative_x);
+                    mouse_location.y = (mouse_location.y + relative_y);

                     let mut event_type = CGEventType::MouseMoved;
                     if self.button_state.left {

This patch should remove this restriction but therefore breaks fullscreen apps that grab the mouse

(safe the patch to a file (e.g. patch) and run

git apply < patch
feschber commented 6 months ago

(Unrelated, but there is some keyboard weirdness with the server not passing through keystrokes that are already mapped for usage in the compositor. Will report that later in another issue.)

What compositor are you using on the server side?

jpeeler commented 6 months ago

That restriction removal works, but then seems to let the mouse descend off the edge display forever.

I'm using hyprland. Would you like a separate issue made?

feschber commented 6 months ago

A yeah, Hyprland has some issues.

https://github.com/hyprwm/Hyprland/issues/4465 https://github.com/hyprwm/Hyprland/issues/4464

But there is nothing I can fix on my end.

jpeeler commented 5 months ago

Good news, shortcuts-inhibit is now implemented.

https://github.com/hyprwm/Hyprland/pull/4889 is requesting for testing, specifically for 4665 but maybe 4464 is also potentially fixed?

Maybe you already saw all of this, but figured getting your input on the fix would be nice.

feschber commented 5 months ago

Yes I have seen it but not hat the time to test until now. Both are fixed :) And shortcuts inhibit also work. That's great news.