fix mobile build
This commit is contained in:
1 parent
885580f3af
commit
d1575b40d1
5 files changed
+57
-50
No files matched your search
@@ -37,6 +37,7 @@ slab = { workspace = true }
|
|||||||
futures-util = { workspace = true }
|
futures-util = { workspace = true }
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.2"
|
||||||
async-trait = "0.1.68"
|
async-trait = "0.1.68"
|
||||||
|
crossbeam-channel = "0.5.8"
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
[target.'cfg(any(target_os = "windows",target_os = "macos",target_os = "linux",target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use std::rc::Weak;
|
|||||||
use crate::create_new_window;
|
use crate::create_new_window;
|
||||||
use crate::events::IpcMessage;
|
use crate::events::IpcMessage;
|
||||||
use crate::query::QueryEngine;
|
use crate::query::QueryEngine;
|
||||||
use crate::shortcut::{ShortcutId, ShortcutRegistry, ShortcutRegistryError};
|
use crate::shortcut::{HotKey, ShortcutId, ShortcutRegistry, ShortcutRegistryError};
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
use crate::WebviewHandler;
|
use crate::WebviewHandler;
|
||||||
use dioxus_core::ScopeState;
|
use dioxus_core::ScopeState;
|
||||||
@@ -230,7 +230,7 @@ impl DesktopService {
|
|||||||
/// Linux: Only works on x11. See [this issue](https://github.com/tauri-apps/tao/issues/331) for more information.
|
/// Linux: Only works on x11. See [this issue](https://github.com/tauri-apps/tao/issues/331) for more information.
|
||||||
pub fn create_shortcut(
|
pub fn create_shortcut(
|
||||||
&self,
|
&self,
|
||||||
hotkey: global_hotkey::hotkey::HotKey,
|
hotkey: HotKey,
|
||||||
callback: impl FnMut() + 'static,
|
callback: impl FnMut() + 'static,
|
||||||
) -> Result<ShortcutId, ShortcutRegistryError> {
|
) -> Result<ShortcutId, ShortcutRegistryError> {
|
||||||
self.shortcut_manager
|
self.shortcut_manager
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ mod waker;
|
|||||||
mod webview;
|
mod webview;
|
||||||
|
|
||||||
use crate::query::QueryResult;
|
use crate::query::QueryResult;
|
||||||
|
use crate::shortcut::GlobalHotKeyEvent;
|
||||||
pub use cfg::{Config, WindowCloseBehaviour};
|
pub use cfg::{Config, WindowCloseBehaviour};
|
||||||
pub use desktop_context::DesktopContext;
|
pub use desktop_context::DesktopContext;
|
||||||
pub use desktop_context::{
|
pub use desktop_context::{
|
||||||
@@ -31,16 +32,6 @@ use dioxus_html::{native_bind::NativeFileEngine, FormData, HtmlEvent};
|
|||||||
use element::DesktopElement;
|
use element::DesktopElement;
|
||||||
use eval::init_eval;
|
use eval::init_eval;
|
||||||
use futures_util::{pin_mut, FutureExt};
|
use futures_util::{pin_mut, FutureExt};
|
||||||
#[cfg(any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
))]
|
|
||||||
use global_hotkey::GlobalHotKeyEvent;
|
|
||||||
use shortcut::ShortcutRegistry;
|
use shortcut::ShortcutRegistry;
|
||||||
pub use shortcut::{use_global_shortcut, ShortcutHandle, ShortcutId, ShortcutRegistryError};
|
pub use shortcut::{use_global_shortcut, ShortcutHandle, ShortcutId, ShortcutRegistryError};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|||||||
@@ -1,38 +1,51 @@
|
|||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use wry::application::accelerator::Accelerator;
|
use std::str::FromStr;
|
||||||
use wry::application::event_loop::EventLoopWindowTarget;
|
use wry::application::event_loop::EventLoopWindowTarget;
|
||||||
|
|
||||||
pub struct HotKey();
|
use dioxus_html::input_data::keyboard_types::Modifiers;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Accelerator;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct HotKey;
|
||||||
|
|
||||||
|
impl HotKey {
|
||||||
|
pub fn new(mods: Option<Modifiers>, key: Code) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn id(&self) -> u32 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for HotKey {
|
impl FromStr for HotKey {
|
||||||
type Err = ();
|
type Err = ();
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
Ok(HotKey())
|
Ok(HotKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ShortcutManager();
|
pub struct GlobalHotKeyManager();
|
||||||
|
|
||||||
impl ShortcutManager {
|
impl GlobalHotKeyManager {
|
||||||
pub fn new<T>(target: &EventLoopWindowTarget<T>) -> Self {
|
pub fn new() -> Result<Self, HotkeyError> {
|
||||||
Self()
|
Ok(Self())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(
|
pub fn register(&mut self, accelerator: HotKey) -> Result<HotKey, HotkeyError> {
|
||||||
&mut self,
|
Ok(HotKey)
|
||||||
accelerator: Accelerator,
|
|
||||||
) -> Result<GlobalShortcut, ShortcutManagerError> {
|
|
||||||
Ok(GlobalShortcut())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unregister(&mut self, id: ShortcutId) -> Result<(), ShortcutManagerError> {
|
pub fn unregister(&mut self, id: HotKey) -> Result<(), HotkeyError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unregister_all(&mut self) -> Result<(), ShortcutManagerError> {
|
pub fn unregister_all(&mut self, _: &[HotKey]) -> Result<(), HotkeyError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,33 +55,35 @@ use std::{error, fmt};
|
|||||||
/// An error whose cause the `ShortcutManager` to fail.
|
/// An error whose cause the `ShortcutManager` to fail.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ShortcutManagerError {
|
pub enum HotkeyError {
|
||||||
AcceleratorAlreadyRegistered(Accelerator),
|
AcceleratorAlreadyRegistered(Accelerator),
|
||||||
AcceleratorNotRegistered(Accelerator),
|
AcceleratorNotRegistered(Accelerator),
|
||||||
InvalidAccelerator(String),
|
HotKeyParseError(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for ShortcutManagerError {}
|
impl error::Error for HotkeyError {}
|
||||||
impl fmt::Display for ShortcutManagerError {
|
impl fmt::Display for HotkeyError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
match self {
|
match self {
|
||||||
ShortcutManagerError::AcceleratorAlreadyRegistered(e) => {
|
HotkeyError::AcceleratorAlreadyRegistered(e) => {
|
||||||
f.pad(&format!("hotkey already registered: {:?}", e))
|
f.pad(&format!("hotkey already registered: {:?}", e))
|
||||||
}
|
}
|
||||||
ShortcutManagerError::AcceleratorNotRegistered(e) => {
|
HotkeyError::AcceleratorNotRegistered(e) => {
|
||||||
f.pad(&format!("hotkey not registered: {:?}", e))
|
f.pad(&format!("hotkey not registered: {:?}", e))
|
||||||
}
|
}
|
||||||
ShortcutManagerError::InvalidAccelerator(e) => e.fmt(f),
|
HotkeyError::HotKeyParseError(e) => e.fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HotkeyError;
|
pub struct GlobalHotKeyEvent {
|
||||||
|
pub id: u32,
|
||||||
struct GlobalHotKeyEvent {
|
|
||||||
id: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type Code = dioxus::prelude::Code;
|
impl GlobalHotKeyEvent {
|
||||||
|
pub fn receiver() -> crossbeam_channel::Receiver<GlobalHotKeyEvent> {
|
||||||
|
crossbeam_channel::unbounded().1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct GlobalHotKeyManager {}
|
pub(crate) type Code = dioxus_html::input_data::keyboard_types::Code;
|
||||||
@@ -7,7 +7,16 @@ use wry::application::keyboard::ModifiersState;
|
|||||||
|
|
||||||
use crate::{desktop_context::DesktopContext, use_window};
|
use crate::{desktop_context::DesktopContext, use_window};
|
||||||
|
|
||||||
use global_hotkey::{
|
#[cfg(any(
|
||||||
|
target_os = "windows",
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "dragonfly",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
))]
|
||||||
|
pub use global_hotkey::{
|
||||||
hotkey::{Code, HotKey},
|
hotkey::{Code, HotKey},
|
||||||
Error as HotkeyError, GlobalHotKeyEvent, GlobalHotKeyManager,
|
Error as HotkeyError, GlobalHotKeyEvent, GlobalHotKeyManager,
|
||||||
};
|
};
|
||||||
@@ -61,7 +70,7 @@ impl ShortcutRegistry {
|
|||||||
|
|
||||||
pub(crate) fn add_shortcut(
|
pub(crate) fn add_shortcut(
|
||||||
&self,
|
&self,
|
||||||
hotkey: global_hotkey::hotkey::HotKey,
|
hotkey: HotKey,
|
||||||
callback: Box<dyn FnMut()>,
|
callback: Box<dyn FnMut()>,
|
||||||
) -> Result<ShortcutId, ShortcutRegistryError> {
|
) -> Result<ShortcutId, ShortcutRegistryError> {
|
||||||
let accelerator_id = hotkey.clone().id();
|
let accelerator_id = hotkey.clone().id();
|
||||||
@@ -168,15 +177,6 @@ impl IntoAccelerator for &str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
|
||||||
target_os = "windows",
|
|
||||||
target_os = "macos",
|
|
||||||
target_os = "linux",
|
|
||||||
target_os = "dragonfly",
|
|
||||||
target_os = "freebsd",
|
|
||||||
target_os = "netbsd",
|
|
||||||
target_os = "openbsd"
|
|
||||||
))]
|
|
||||||
/// Get a closure that executes any JavaScript in the WebView context.
|
/// Get a closure that executes any JavaScript in the WebView context.
|
||||||
pub fn use_global_shortcut(
|
pub fn use_global_shortcut(
|
||||||
cx: &ScopeState,
|
cx: &ScopeState,
|
||||||
|
|||||||
Reference in new issue
Block a user