Skip to content

Commit

Permalink
macos: enable running lan-mouse on macos (#42)
Browse files Browse the repository at this point in the history
* macos: initial support

- adapted conditional compilation
- moved lan-mouse socket to ~/Library/Caches/lan-mouse-socket.sock instead of XDG_RUNTIME_DIR
- support for mouse input emulation
TODO: Keycode translation, input capture
  • Loading branch information
feschber committed Dec 9, 2023
1 parent 5a7e0cf commit e3f9947
Show file tree
Hide file tree
Showing 13 changed files with 419 additions and 21 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,23 @@ jobs:
name: lan-mouse-windows
path: target/release/lan-mouse.exe

macos-release-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew install gtk4 libadwaita
- name: Release Build
run: cargo build --release
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: lan-mouse-macos
path: target/release/lan-mouse

pre-release:
name: "Pre Release"
needs: [windows-release-build, linux-release-build]
needs: [windows-release-build, linux-release-build, macos-release-build]
runs-on: "ubuntu-latest"
steps:
- name: Download build artifacts
Expand All @@ -56,3 +70,4 @@ jobs:
files: |
lan-mouse-linux/lan-mouse
lan-mouse-windows/lan-mouse.exe
lan-mouse-macos/lan-mouse
16 changes: 16 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,19 @@ jobs:
with:
name: lan-mouse-windows
path: target/debug/lan-mouse.exe

build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew install gtk4 libadwaita
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: lan-mouse-macos
path: target/debug/lan-mouse
17 changes: 16 additions & 1 deletion .github/workflows/tagged-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,23 @@ jobs:
name: lan-mouse-windows
path: target/release/lan-mouse.exe

macos-release-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: brew install gtk4 libadwaita
- name: Release Build
run: cargo build --release
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: lan-mouse-macos
path: target/release/lan-mouse

tagged-release:
name: "Tagged Release"
needs: [windows-release-build, linux-release-build]
needs: [windows-release-build, linux-release-build, macos-release-build]
runs-on: "ubuntu-latest"
steps:
- name: Download build artifacts
Expand All @@ -50,3 +64,4 @@ jobs:
files: |
lan-mouse-linux/lan-mouse
lan-mouse-windows/lan-mouse.exe
lan-mouse-macos/lan-mouse
68 changes: 68 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ futures-core = "0.3.28"
futures = "0.3.28"
clap = { version="4.4.11", features = ["derive"] }

[target.'cfg(unix)'.dependencies]
[target.'cfg(all(unix, not(target_os="macos")))'.dependencies]
wayland-client = { version="0.30.2", optional = true }
wayland-protocols = { version="0.30.0", features=["client", "staging", "unstable"], optional = true }
wayland-protocols-wlr = { version="0.1.0", features=["client"], optional = true }
wayland-protocols-misc = { version="0.1.0", features=["client"], optional = true }
wayland-protocols-plasma = { version="0.1.0", features=["client"], optional = true }
x11 = { version = "2.21.0", features = ["xlib", "xtest"], optional = true }
gtk = { package = "gtk4", version = "0.7.2", features = ["v4_6"], optional = true }
adw = { package = "libadwaita", version = "0.5.2", features = ["v1_1"], optional = true }
ashpd = { version = "0.6.2", default-features = false, features = ["tokio"], optional = true }
reis = { git = "https://github.com/ids1024/reis", features = [ "tokio" ], optional = true }

[target.'cfg(unix)'.dependencies]
gtk = { package = "gtk4", version = "0.7.2", features = ["v4_6"], optional = true }
adw = { package = "libadwaita", version = "0.5.2", features = ["v1_1"], optional = true }

[target.'cfg(target_os="macos")'.dependencies]
core-graphics = { version = "0.23", features = ["highsierra"] }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = ["winuser"] }

Expand Down
11 changes: 7 additions & 4 deletions src/backend/consumer.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#[cfg(windows)]
pub mod windows;

#[cfg(all(unix, feature = "x11"))]
#[cfg(all(unix, feature = "x11", not(target_os = "macos")))]
pub mod x11;

#[cfg(all(unix, feature = "wayland"))]
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
pub mod wlroots;

#[cfg(all(unix, feature = "xdg_desktop_portal"))]
#[cfg(all(unix, feature = "xdg_desktop_portal", not(target_os = "macos")))]
pub mod xdg_desktop_portal;

#[cfg(all(unix, feature = "libei"))]
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
pub mod libei;

#[cfg(target_os = "macos")]
pub mod macos;

0 comments on commit e3f9947

Please sign in to comment.