diff --git a/.changes/no-op.md b/.changes/no-op.md new file mode 100644 index 0000000..ea3e1fe --- /dev/null +++ b/.changes/no-op.md @@ -0,0 +1,5 @@ +--- +"global-hotkey": "patch" +--- + +Add no-op implementations for unsupported targets. diff --git a/src/lib.rs b/src/lib.rs index dbee080..3a9a319 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,9 +63,9 @@ use hotkey::HotKey; /// Describes the state of the [`HotKey`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum HotKeyState { - /// The [`HotKey`] is pressed (the key is down). + /// The [`HotKey`] is pressed (the key is down). Pressed, - /// The [`HotKey`] is released (the key is up). + /// The [`HotKey`] is released (the key is up). Released, } diff --git a/src/platform_impl/mod.rs b/src/platform_impl/mod.rs index e308eb6..cf02ed6 100644 --- a/src/platform_impl/mod.rs +++ b/src/platform_impl/mod.rs @@ -5,11 +5,29 @@ #[cfg(target_os = "windows")] #[path = "windows/mod.rs"] mod platform; -#[cfg(target_os = "linux")] +#[cfg(any( + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" +))] #[path = "x11/mod.rs"] mod platform; #[cfg(target_os = "macos")] #[path = "macos/mod.rs"] mod platform; +#[cfg(not(any( + target_os = "windows", + target_os = "linux", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd", + target_os = "macos" +)))] +#[path = "no-op.rs"] +mod platform; + pub(crate) use self::platform::*; diff --git a/src/platform_impl/no-op.rs b/src/platform_impl/no-op.rs new file mode 100644 index 0000000..13f16ae --- /dev/null +++ b/src/platform_impl/no-op.rs @@ -0,0 +1,38 @@ +// Copyright 2022-2022 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT +// Copyright 2022-2022 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use crate::hotkey::HotKey; + +pub struct GlobalHotKeyManager {} + +impl GlobalHotKeyManager { + pub fn new() -> crate::Result { + Ok(Self {}) + } + + pub fn register(&self, hotkey: HotKey) -> crate::Result<()> { + Ok(()) + } + + pub fn unregister(&self, hotkey: HotKey) -> crate::Result<()> { + Ok(()) + } + + pub fn register_all(&self, hotkeys: &[HotKey]) -> crate::Result<()> { + for hotkey in hotkeys { + self.register(*hotkey)?; + } + Ok(()) + } + + pub fn unregister_all(&self, hotkeys: &[HotKey]) -> crate::Result<()> { + for hotkey in hotkeys { + self.unregister(*hotkey)?; + } + Ok(()) + } +}