Skip to content

Commit

Permalink
feat(win): add kanata native Windows GUI tray app (#990)
Browse files Browse the repository at this point in the history
Add a `gui` feature allowing compiling kanata as a native tray-only
Windows GUI application. This greatly simplifies launching the app on
startup instead of resorting to hacks like this:

	#193

It gets rid of the console window and also allows UIAccess to work in
elevated apps. There is a kanata-tray project which helps with the
former, but doesn't allow UIAccess.

	issue: (rszyma/kanata-tray#19)

It also supports custom icon indicator per config and per layer within
the same config, as well as (re)loading configs. Other configs are
passed as cli args in the `.lnk` file

It also supports being launched from a console as a regular cli app, so
it's possible to replace the main `kanata.exe` with this or let it be
some separate `kanata-tray.exe` file

It also opens an avenue to more interesting ideas, but will add those in
a separate issue #991
  • Loading branch information
eugenesvk committed May 7, 2024
1 parent b683ad6 commit a41b473
Show file tree
Hide file tree
Showing 50 changed files with 2,724 additions and 1,231 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ jobs:
- name: Run clippy simulated output
run: cargo clippy --all --features=simulated_output,cmd -- -D warnings

- name: Run tests gui
run: cargo test --all --features=gui
- name: Run clippy gui
run: cargo clippy --all --features=gui -- -D warnings

build-test-clippy-macos:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
79 changes: 70 additions & 9 deletions Cargo.lock

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

20 changes: 19 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"tcp_protocol",
"simulated_input",
"windows_key_tester",
"win_dbg_logger",
]
exclude = [
"wasm",
Expand Down Expand Up @@ -79,7 +80,23 @@ winapi = { version = "0.3.9", features = [
"timeapi",
"mmsystem",
] }
native-windows-gui = { version = "1.0.12", default_features = false }
windows-sys = { version = "0.52.0", features = [
"Win32_Devices_DeviceAndDriverInstallation",
"Win32_Devices_Usb",
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_Security",
"Win32_System_Diagnostics_Debug",
"Win32_System_Registry",
"Win32_System_Threading",
"Win32_UI_Controls",
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
], optional=true }
win_dbg_logger = { path = "win_dbg_logger", optional = true }
native-windows-gui = { version = "1.0.13", default_features = false}
native-windows-derive = { version = "1.0.5", default_features = false, optional = true }
regex = { version = "1.10.4", optional = true }
kanata-interception = { version = "0.2.0", optional = true }

[target.'cfg(target_os = "windows")'.build-dependencies]
Expand All @@ -98,6 +115,7 @@ cmd = ["kanata-parser/cmd"]
interception_driver = ["kanata-interception", "kanata-parser/interception_driver"]
simulated_output = ["indoc"]
wasm = [ "instant/wasm-bindgen" ]
gui = ["win_manifest","native-windows-derive","win_dbg_logger","win_dbg_logger/simple_shared","kanata-parser/gui","native-windows-gui/tray-notification","native-windows-gui/message-window","native-windows-gui/menu","native-windows-gui/cursor","native-windows-gui/high-dpi","native-windows-gui/embed-resource","native-windows-gui/image-decoder","native-windows-gui/notice","dep:windows-sys"]

[profile.release]
opt-level = "z"
Expand Down
Loading

0 comments on commit a41b473

Please sign in to comment.