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

[WIP] MacOS inputcapture #131

Merged
merged 9 commits into from
Aug 26, 2024
Merged

[WIP] MacOS inputcapture #131

merged 9 commits into from
Aug 26, 2024

Conversation

meck
Copy link
Contributor

@meck meck commented May 12, 2024

I had a stab at writing a macos input capture module as i was tired not being able to cross the pointer back and forth between mac and linux, and it seemed a good rust exercise. There as some things left mainly modifier handling and updating the bounds on a monitor config change. But i wanted to put it up as a draft for now if there is any other pointers or if i missed something in the architecture.

@feschber
Copy link
Owner

Very nice, thank you! Unfortunately my MacOS VM nuked itself so I will have to set that up again before I can test this... Sorry about thay

@feschber feschber marked this pull request as ready for review May 13, 2024 21:57
@feschber feschber mentioned this pull request May 14, 2024
4 tasks
@rohitsangwan01
Copy link

Works for me

src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
src/capture/macos.rs Outdated Show resolved Hide resolved
@feschber
Copy link
Owner

And just FYI: I'm still debating on whether or not Modifier events should even be handled "server side" at all.
The only backend that currently reports them is the wayland / layershell backend and similarly the only emulation backend that needs modifier events is the wlroots one.
Still good to have them but they also dont work in Windows and Libei Input Captures (even though libei should report them but apparently does not do so)

@meck
Copy link
Contributor Author

meck commented May 16, 2024

I see, im using Hyprland so wayland/wlroots is what im using. I guess removing the events would mean tracking modifier state in wlroots emulation.

@feschber
Copy link
Owner

I see, im using Hyprland so wayland/wlroots is what im using. I guess removing the events would mean tracking modifier state in wlroots emulation.

Yeah exactly. Definitely keep it in though! Better to have it working in MacOS now.

@meck
Copy link
Contributor Author

meck commented Jun 4, 2024

I hope to get back to this soon, haven't had the time, the only thing i wanted to add was detection of monitor layout changes, there is a API in CGDisplayRegisterReconfigurationCallback however it needs a CFRunLoop to run on the main thread for the callback to actually be called, That would mean a lot of architectural changes to rest of the project so I'm looking for alternatives.

@feschber
Copy link
Owner

feschber commented Jun 4, 2024

no worries! I just got round to testing this. One thing I'm noticing is that the mouse is behaving weird when dragging:
When I press the mouse down and drag it to the left and then release the mouse button, while the mouse is still moving, the mouse jumps back to its original position.

@arrowmancer
Copy link

Say we have both a Linux machine that we want connected to our MacOS machine (Apple silicon), are we supposed to build and use the same version (this branch) of Lan Mouse on both the Linux and Mac machine in order to e.g. have the pointer go back and forth, or is it sufficient to build this branch on my Mac? Because I seem to still have trouble having my cursor return from my mac once it's moved there (from my Linux machine).

Also, is anyone for whom this is working having no issues with e.g. having an ipad as a second monitor via sidecar at the same time Lan Mouse is running?

@feschber
Copy link
Owner

Say we have both a Linux machine that we want connected to our MacOS machine (Apple silicon), are we supposed to build and use the same version (this branch) of Lan Mouse on both the Linux and Mac machine in order to e.g. have the pointer go back and forth, or is it sufficient to build this branch on my Mac? Because I seem to still have trouble having my cursor return from my mac once it's moved there (from my Linux machine).

Also, is anyone for whom this is working having no issues with e.g. having an ipad as a second monitor via sidecar at the same time Lan Mouse is running?

You will need this branch on the mac side. On the Linux side, you can use the main branch. Keep in mind this is a work in progress.

@arrowmancer
Copy link

Say we have both a Linux machine that we want connected to our MacOS machine (Apple silicon), are we supposed to build and use the same version (this branch) of Lan Mouse on both the Linux and Mac machine in order to e.g. have the pointer go back and forth, or is it sufficient to build this branch on my Mac? Because I seem to still have trouble having my cursor return from my mac once it's moved there (from my Linux machine).
Also, is anyone for whom this is working having no issues with e.g. having an ipad as a second monitor via sidecar at the same time Lan Mouse is running?

You will need this branch on the mac side. On the Linux side, you can use the main branch. Keep in mind this is a work in progress.

The work-in-progress state of this PR is definitely understood, I'm just happy it exists for me to try out! Although sadly I think I'm currently not able to link up my linux and macos machines for the same reasons as here, i.e. the changes caused in the 6.1.1 update with libei: #140

I'd be happy to provide any logs!

@jmatsushita
Copy link

Hi there, thanks for this PR. Just wanted to report that the basic feature works also here with a mac m1/nix-darwin server and a nixos/gnome/wayland client. However:

  • modifier keys don't work (IIUC they works with wlroots, whereas with this setup, I'm using the Libei emulation on the nixos side)
  • the mouse wheel was inverted.

Also FYI, I gave a shot at using nixos/cosmic(-epoch) but that didn't work, I suppose this needs Smithay/smithay#1388

@b0o
Copy link

b0o commented Jul 26, 2024

This is working very well from Sway -> macOS, thank you!

Only issues are that my scroll direction is also inverted, and sometimes the Command key doesn't work (but is fixable by restarting both daemons). These are both issues on the main branch too, so I don't think it's anything specific to your PR.

@feschber
Copy link
Owner

This is working very well from Sway -> macOS, thank you!

Only issues are that my scroll direction is also inverted, and sometimes the Command key doesn't work (but is fixable by restarting both daemons). These are both issues on the main branch too, so I don't think it's anything specific to your PR.

Does the command key not work when pressed on MacOS or on the sway client? This PR is only concerned with inputs sent from macos to other devices.

@b0o
Copy link

b0o commented Jul 26, 2024

Only on macOS when sent from the Linux device.

@rohitsangwan01
Copy link

@meck now that the current project structure of LanMouse is changed, can you please update your PR accordingly ?

@feschber
Copy link
Owner

feschber commented Aug 1, 2024

@meck now that the current project structure of LanMouse is changed, can you please update your PR accordingly ?

I can rebase it this weekend

@feschber feschber mentioned this pull request Aug 9, 2024
@feschber
Copy link
Owner

@rohitsangwan01 sorry, could not get to it sooner, but it is now rebased.
I can not currently test this though, so lmk if there are any issues that popped up

@rohitsangwan01
Copy link

@feschber Thank you for the updates, i tested with Ubuntu <-> Mac, its not stable but worked for the first time

@rohitsangwan01
Copy link

@feschber any plan to merge this PR, its still atleast better then nothing, and can be improved in follow up Pr's i guess.
Till then maybe you can mark MacOS state as Beta

@feschber
Copy link
Owner

@feschber any plan to merge this PR, its still atleast better then nothing, and can be improved in follow up Pr's i guess.
Till then maybe you can mark MacOS state as Beta

@meck what do you think?

@meck
Copy link
Contributor Author

meck commented Aug 16, 2024

@feschber any plan to merge this PR, its still atleast better then nothing, and can be improved in follow up Pr's i guess.
Till then maybe you can mark MacOS state as Beta

@meck what do you think?

Hi, sorry for leaving this a bit behind. I've been swamped both in work and personally. The macOS side features i wanted to add was detection of resolution changes, there was some issues as i mentioned in earlier comment.
And I haven't tested it with any other client then macos -> hyprland.

I would like to finish it up, but I'm not sure when next I will have the time, but with those caveats I would be fine merging it as is marked as beta if @feschber is too.

@feschber feschber merged commit 9248007 into feschber:main Aug 26, 2024
7 checks passed
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.

6 participants