feat: no-op implementations (#64)

closes #63
This commit is contained in:
Amr Bashir
2024-03-07 18:38:52 +02:00
committed by GitHub
parent 89f9679570
commit 89199d930d
4 changed files with 64 additions and 3 deletions

5
.changes/no-op.md Normal file
View File

@@ -0,0 +1,5 @@
---
"global-hotkey": "patch"
---
Add no-op implementations for unsupported targets.

View File

@@ -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,
}

View File

@@ -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::*;

View File

@@ -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<Self> {
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(())
}
}