lib.rs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. //! [![](https://github.com/tauri-apps/tauri/raw/dev/.github/splash.png)](https://tauri.app)
  5. //!
  6. //! Internal runtime between Tauri and the underlying webview runtime.
  7. #![doc(
  8. html_logo_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png",
  9. html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png"
  10. )]
  11. #![cfg_attr(doc_cfg, feature(doc_cfg))]
  12. use raw_window_handle::RawDisplayHandle;
  13. use serde::Deserialize;
  14. use std::{fmt::Debug, sync::mpsc::Sender};
  15. use tauri_utils::{ProgressBarState, Theme};
  16. use url::Url;
  17. /// Types useful for interacting with a user's monitors.
  18. pub mod monitor;
  19. pub mod webview;
  20. pub mod window;
  21. use monitor::Monitor;
  22. use webview::WindowBuilder;
  23. use window::{
  24. dpi::{PhysicalPosition, PhysicalSize, Position, Size},
  25. CursorIcon, DetachedWindow, PendingWindow, RawWindow, WindowEvent,
  26. };
  27. use http::{
  28. header::{InvalidHeaderName, InvalidHeaderValue},
  29. method::InvalidMethod,
  30. status::InvalidStatusCode,
  31. };
  32. pub type WindowEventId = u32;
  33. /// Type of user attention requested on a window.
  34. #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
  35. #[serde(tag = "type")]
  36. pub enum UserAttentionType {
  37. /// ## Platform-specific
  38. /// - **macOS:** Bounces the dock icon until the application is in focus.
  39. /// - **Windows:** Flashes both the window and the taskbar button until the application is in focus.
  40. Critical,
  41. /// ## Platform-specific
  42. /// - **macOS:** Bounces the dock icon once.
  43. /// - **Windows:** Flashes the taskbar button until the application is in focus.
  44. Informational,
  45. }
  46. #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
  47. #[serde(tag = "type")]
  48. pub enum DeviceEventFilter {
  49. /// Always filter out device events.
  50. Always,
  51. /// Filter out device events while the window is not focused.
  52. Unfocused,
  53. /// Report all device events regardless of window focus.
  54. Never,
  55. }
  56. impl Default for DeviceEventFilter {
  57. fn default() -> Self {
  58. Self::Unfocused
  59. }
  60. }
  61. #[derive(Debug, thiserror::Error)]
  62. #[non_exhaustive]
  63. pub enum Error {
  64. /// Failed to create webview.
  65. #[error("failed to create webview: {0}")]
  66. CreateWebview(Box<dyn std::error::Error + Send + Sync>),
  67. /// Failed to create window.
  68. #[error("failed to create window")]
  69. CreateWindow,
  70. /// The given window label is invalid.
  71. #[error("Window labels must only include alphanumeric characters, `-`, `/`, `:` and `_`.")]
  72. InvalidWindowLabel,
  73. /// Failed to send message to webview.
  74. #[error("failed to send message to the webview")]
  75. FailedToSendMessage,
  76. /// Failed to receive message from webview.
  77. #[error("failed to receive message from webview")]
  78. FailedToReceiveMessage,
  79. /// Failed to serialize/deserialize.
  80. #[error("JSON error: {0}")]
  81. Json(#[from] serde_json::Error),
  82. /// Failed to load window icon.
  83. #[error("invalid icon: {0}")]
  84. InvalidIcon(Box<dyn std::error::Error + Send + Sync>),
  85. /// Failed to get monitor on window operation.
  86. #[error("failed to get monitor")]
  87. FailedToGetMonitor,
  88. #[error("Invalid header name: {0}")]
  89. InvalidHeaderName(#[from] InvalidHeaderName),
  90. #[error("Invalid header value: {0}")]
  91. InvalidHeaderValue(#[from] InvalidHeaderValue),
  92. #[error("Invalid status code: {0}")]
  93. InvalidStatusCode(#[from] InvalidStatusCode),
  94. #[error("Invalid method: {0}")]
  95. InvalidMethod(#[from] InvalidMethod),
  96. #[error("Infallible error, something went really wrong: {0}")]
  97. Infallible(#[from] std::convert::Infallible),
  98. #[error("the event loop has been closed")]
  99. EventLoopClosed,
  100. }
  101. /// Result type.
  102. pub type Result<T> = std::result::Result<T, Error>;
  103. /// Window icon.
  104. #[derive(Debug, Clone)]
  105. pub struct Icon {
  106. /// RGBA bytes of the icon.
  107. pub rgba: Vec<u8>,
  108. /// Icon width.
  109. pub width: u32,
  110. /// Icon height.
  111. pub height: u32,
  112. }
  113. /// A type that can be used as an user event.
  114. pub trait UserEvent: Debug + Clone + Send + 'static {}
  115. impl<T: Debug + Clone + Send + 'static> UserEvent for T {}
  116. /// Event triggered on the event loop run.
  117. #[derive(Debug)]
  118. #[non_exhaustive]
  119. pub enum RunEvent<T: UserEvent> {
  120. /// Event loop is exiting.
  121. Exit,
  122. /// Event loop is about to exit
  123. ExitRequested {
  124. tx: Sender<ExitRequestedEventAction>,
  125. },
  126. /// An event associated with a window.
  127. WindowEvent {
  128. /// The window label.
  129. label: String,
  130. /// The detailed event.
  131. event: WindowEvent,
  132. },
  133. /// Application ready.
  134. Ready,
  135. /// Sent if the event loop is being resumed.
  136. Resumed,
  137. /// Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin.
  138. ///
  139. /// This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop.
  140. MainEventsCleared,
  141. /// Emitted when the user wants to open the specified resource with the app.
  142. #[cfg(any(target_os = "macos", target_os = "ios"))]
  143. Opened { urls: Vec<url::Url> },
  144. /// A custom event defined by the user.
  145. UserEvent(T),
  146. }
  147. /// Action to take when the event loop is about to exit
  148. #[derive(Debug)]
  149. pub enum ExitRequestedEventAction {
  150. /// Prevent the event loop from exiting
  151. Prevent,
  152. }
  153. /// Metadata for a runtime event loop iteration on `run_iteration`.
  154. #[derive(Debug, Clone, Default)]
  155. pub struct RunIteration {
  156. pub window_count: usize,
  157. }
  158. /// Application's activation policy. Corresponds to NSApplicationActivationPolicy.
  159. #[cfg(target_os = "macos")]
  160. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  161. #[non_exhaustive]
  162. pub enum ActivationPolicy {
  163. /// Corresponds to NSApplicationActivationPolicyRegular.
  164. Regular,
  165. /// Corresponds to NSApplicationActivationPolicyAccessory.
  166. Accessory,
  167. /// Corresponds to NSApplicationActivationPolicyProhibited.
  168. Prohibited,
  169. }
  170. /// A [`Send`] handle to the runtime.
  171. pub trait RuntimeHandle<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static {
  172. type Runtime: Runtime<T, Handle = Self>;
  173. /// Creates an `EventLoopProxy` that can be used to dispatch user events to the main event loop.
  174. fn create_proxy(&self) -> <Self::Runtime as Runtime<T>>::EventLoopProxy;
  175. /// Create a new webview window.
  176. fn create_window<F: Fn(RawWindow) + Send + 'static>(
  177. &self,
  178. pending: PendingWindow<T, Self::Runtime>,
  179. before_webview_creation: Option<F>,
  180. ) -> Result<DetachedWindow<T, Self::Runtime>>;
  181. /// Run a task on the main thread.
  182. fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>;
  183. fn raw_display_handle(&self) -> RawDisplayHandle;
  184. fn primary_monitor(&self) -> Option<Monitor>;
  185. fn available_monitors(&self) -> Vec<Monitor>;
  186. /// Shows the application, but does not automatically focus it.
  187. #[cfg(target_os = "macos")]
  188. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  189. fn show(&self) -> Result<()>;
  190. /// Hides the application.
  191. #[cfg(target_os = "macos")]
  192. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  193. fn hide(&self) -> Result<()>;
  194. /// Finds an Android class in the project scope.
  195. #[cfg(target_os = "android")]
  196. fn find_class<'a>(
  197. &self,
  198. env: &mut jni::JNIEnv<'a>,
  199. activity: &jni::objects::JObject<'_>,
  200. name: impl Into<String>,
  201. ) -> std::result::Result<jni::objects::JClass<'a>, jni::errors::Error>;
  202. /// Dispatch a closure to run on the Android context.
  203. ///
  204. /// The closure takes the JNI env, the Android activity instance and the possibly null webview.
  205. #[cfg(target_os = "android")]
  206. fn run_on_android_context<F>(&self, f: F)
  207. where
  208. F: FnOnce(&mut jni::JNIEnv, &jni::objects::JObject, &jni::objects::JObject) + Send + 'static;
  209. }
  210. pub trait EventLoopProxy<T: UserEvent>: Debug + Clone + Send + Sync {
  211. fn send_event(&self, event: T) -> Result<()>;
  212. }
  213. #[derive(Default)]
  214. pub struct RuntimeInitArgs {
  215. #[cfg(windows)]
  216. pub msg_hook: Option<Box<dyn FnMut(*const std::ffi::c_void) -> bool + 'static>>,
  217. }
  218. /// The webview runtime interface.
  219. pub trait Runtime<T: UserEvent>: Debug + Sized + 'static {
  220. /// The message dispatcher.
  221. type Dispatcher: Dispatch<T, Runtime = Self>;
  222. /// The runtime handle type.
  223. type Handle: RuntimeHandle<T, Runtime = Self>;
  224. /// The proxy type.
  225. type EventLoopProxy: EventLoopProxy<T>;
  226. /// Creates a new webview runtime. Must be used on the main thread.
  227. fn new(args: RuntimeInitArgs) -> Result<Self>;
  228. /// Creates a new webview runtime on any thread.
  229. #[cfg(any(windows, target_os = "linux"))]
  230. #[cfg_attr(doc_cfg, doc(cfg(any(windows, target_os = "linux"))))]
  231. fn new_any_thread(args: RuntimeInitArgs) -> Result<Self>;
  232. /// Creates an `EventLoopProxy` that can be used to dispatch user events to the main event loop.
  233. fn create_proxy(&self) -> Self::EventLoopProxy;
  234. /// Gets a runtime handle.
  235. fn handle(&self) -> Self::Handle;
  236. /// Create a new webview window.
  237. fn create_window<F: Fn(RawWindow) + Send + 'static>(
  238. &self,
  239. pending: PendingWindow<T, Self>,
  240. before_webview_creation: Option<F>,
  241. ) -> Result<DetachedWindow<T, Self>>;
  242. fn primary_monitor(&self) -> Option<Monitor>;
  243. fn available_monitors(&self) -> Vec<Monitor>;
  244. /// Sets the activation policy for the application. It is set to `NSApplicationActivationPolicyRegular` by default.
  245. #[cfg(target_os = "macos")]
  246. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  247. fn set_activation_policy(&mut self, activation_policy: ActivationPolicy);
  248. /// Shows the application, but does not automatically focus it.
  249. #[cfg(target_os = "macos")]
  250. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  251. fn show(&self);
  252. /// Hides the application.
  253. #[cfg(target_os = "macos")]
  254. #[cfg_attr(doc_cfg, doc(cfg(target_os = "macos")))]
  255. fn hide(&self);
  256. /// Change the device event filter mode.
  257. ///
  258. /// Since the DeviceEvent capture can lead to high CPU usage for unfocused windows, [`tao`]
  259. /// will ignore them by default for unfocused windows on Windows. This method allows changing
  260. /// the filter to explicitly capture them again.
  261. ///
  262. /// ## Platform-specific
  263. ///
  264. /// - ** Linux / macOS / iOS / Android**: Unsupported.
  265. ///
  266. /// [`tao`]: https://crates.io/crates/tao
  267. fn set_device_event_filter(&mut self, filter: DeviceEventFilter);
  268. /// Runs the one step of the webview runtime event loop and returns control flow to the caller.
  269. #[cfg(desktop)]
  270. fn run_iteration<F: Fn(RunEvent<T>) + 'static>(&mut self, callback: F) -> RunIteration;
  271. /// Run the webview runtime.
  272. fn run<F: FnMut(RunEvent<T>) + 'static>(self, callback: F);
  273. }
  274. /// Webview dispatcher. A thread-safe handle to the webview API.
  275. pub trait Dispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'static {
  276. /// The runtime this [`Dispatch`] runs under.
  277. type Runtime: Runtime<T>;
  278. /// The window builder type.
  279. type WindowBuilder: WindowBuilder;
  280. /// Run a task on the main thread.
  281. fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>;
  282. /// Registers a window event handler.
  283. fn on_window_event<F: Fn(&WindowEvent) + Send + 'static>(&self, f: F) -> WindowEventId;
  284. /// Runs a closure with the platform webview object as argument.
  285. fn with_webview<F: FnOnce(Box<dyn std::any::Any>) + Send + 'static>(&self, f: F) -> Result<()>;
  286. /// Open the web inspector which is usually called devtools.
  287. #[cfg(any(debug_assertions, feature = "devtools"))]
  288. fn open_devtools(&self);
  289. /// Close the web inspector which is usually called devtools.
  290. #[cfg(any(debug_assertions, feature = "devtools"))]
  291. fn close_devtools(&self);
  292. /// Gets the devtools window's current open state.
  293. #[cfg(any(debug_assertions, feature = "devtools"))]
  294. fn is_devtools_open(&self) -> Result<bool>;
  295. // GETTERS
  296. /// Returns the webview's current URL.
  297. fn url(&self) -> Result<Url>;
  298. /// Returns the scale factor that can be used to map logical pixels to physical pixels, and vice versa.
  299. fn scale_factor(&self) -> Result<f64>;
  300. /// Returns the position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
  301. fn inner_position(&self) -> Result<PhysicalPosition<i32>>;
  302. /// Returns the position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
  303. fn outer_position(&self) -> Result<PhysicalPosition<i32>>;
  304. /// Returns the physical size of the window's client area.
  305. ///
  306. /// The client area is the content of the window, excluding the title bar and borders.
  307. fn inner_size(&self) -> Result<PhysicalSize<u32>>;
  308. /// Returns the physical size of the entire window.
  309. ///
  310. /// These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
  311. fn outer_size(&self) -> Result<PhysicalSize<u32>>;
  312. /// Gets the window's current fullscreen state.
  313. fn is_fullscreen(&self) -> Result<bool>;
  314. /// Gets the window's current minimized state.
  315. fn is_minimized(&self) -> Result<bool>;
  316. /// Gets the window's current maximized state.
  317. fn is_maximized(&self) -> Result<bool>;
  318. /// Gets the window's current focus state.
  319. fn is_focused(&self) -> Result<bool>;
  320. /// Gets the window’s current decoration state.
  321. fn is_decorated(&self) -> Result<bool>;
  322. /// Gets the window’s current resizable state.
  323. fn is_resizable(&self) -> Result<bool>;
  324. /// Gets the window's native maximize button state.
  325. ///
  326. /// ## Platform-specific
  327. ///
  328. /// - **Linux / iOS / Android:** Unsupported.
  329. fn is_maximizable(&self) -> Result<bool>;
  330. /// Gets the window's native minize button state.
  331. ///
  332. /// ## Platform-specific
  333. ///
  334. /// - **Linux / iOS / Android:** Unsupported.
  335. fn is_minimizable(&self) -> Result<bool>;
  336. /// Gets the window's native close button state.
  337. ///
  338. /// ## Platform-specific
  339. ///
  340. /// - **iOS / Android:** Unsupported.
  341. fn is_closable(&self) -> Result<bool>;
  342. /// Gets the window's current visibility state.
  343. fn is_visible(&self) -> Result<bool>;
  344. /// Gets the window's current title.
  345. fn title(&self) -> Result<String>;
  346. /// Returns the monitor on which the window currently resides.
  347. ///
  348. /// Returns None if current monitor can't be detected.
  349. fn current_monitor(&self) -> Result<Option<Monitor>>;
  350. /// Returns the primary monitor of the system.
  351. ///
  352. /// Returns None if it can't identify any monitor as a primary one.
  353. fn primary_monitor(&self) -> Result<Option<Monitor>>;
  354. /// Returns the list of all the monitors available on the system.
  355. fn available_monitors(&self) -> Result<Vec<Monitor>>;
  356. /// Returns the `ApplicationWindow` from gtk crate that is used by this window.
  357. #[cfg(any(
  358. target_os = "linux",
  359. target_os = "dragonfly",
  360. target_os = "freebsd",
  361. target_os = "netbsd",
  362. target_os = "openbsd"
  363. ))]
  364. fn gtk_window(&self) -> Result<gtk::ApplicationWindow>;
  365. /// Returns the vertical [`gtk::Box`] that is added by default as the sole child of this window.
  366. #[cfg(any(
  367. target_os = "linux",
  368. target_os = "dragonfly",
  369. target_os = "freebsd",
  370. target_os = "netbsd",
  371. target_os = "openbsd"
  372. ))]
  373. fn default_vbox(&self) -> Result<gtk::Box>;
  374. fn raw_window_handle(&self) -> Result<raw_window_handle::RawWindowHandle>;
  375. /// Returns the current window theme.
  376. fn theme(&self) -> Result<Theme>;
  377. // SETTERS
  378. /// Centers the window.
  379. fn center(&self) -> Result<()>;
  380. /// Opens the dialog to prints the contents of the webview.
  381. fn print(&self) -> Result<()>;
  382. /// Requests user attention to the window.
  383. ///
  384. /// Providing `None` will unset the request for user attention.
  385. fn request_user_attention(&self, request_type: Option<UserAttentionType>) -> Result<()>;
  386. /// Create a new webview window.
  387. fn create_window<F: Fn(RawWindow) + Send + 'static>(
  388. &mut self,
  389. pending: PendingWindow<T, Self::Runtime>,
  390. before_webview_creation: Option<F>,
  391. ) -> Result<DetachedWindow<T, Self::Runtime>>;
  392. /// Updates the window resizable flag.
  393. fn set_resizable(&self, resizable: bool) -> Result<()>;
  394. /// Updates the window's native maximize button state.
  395. ///
  396. /// ## Platform-specific
  397. ///
  398. /// - **macOS:** Disables the "zoom" button in the window titlebar, which is also used to enter fullscreen mode.
  399. /// - **Linux / iOS / Android:** Unsupported.
  400. fn set_maximizable(&self, maximizable: bool) -> Result<()>;
  401. /// Updates the window's native minimize button state.
  402. ///
  403. /// ## Platform-specific
  404. ///
  405. /// - **Linux / iOS / Android:** Unsupported.
  406. fn set_minimizable(&self, minimizable: bool) -> Result<()>;
  407. /// Updates the window's native close button state.
  408. ///
  409. /// ## Platform-specific
  410. ///
  411. /// - **Linux:** "GTK+ will do its best to convince the window manager not to show a close button.
  412. /// Depending on the system, this function may not have any effect when called on a window that is already visible"
  413. /// - **iOS / Android:** Unsupported.
  414. fn set_closable(&self, closable: bool) -> Result<()>;
  415. /// Updates the window title.
  416. fn set_title<S: Into<String>>(&self, title: S) -> Result<()>;
  417. /// Naviagte to the given URL.
  418. fn navigate(&self, url: Url) -> Result<()>;
  419. /// Maximizes the window.
  420. fn maximize(&self) -> Result<()>;
  421. /// Unmaximizes the window.
  422. fn unmaximize(&self) -> Result<()>;
  423. /// Minimizes the window.
  424. fn minimize(&self) -> Result<()>;
  425. /// Unminimizes the window.
  426. fn unminimize(&self) -> Result<()>;
  427. /// Shows the window.
  428. fn show(&self) -> Result<()>;
  429. /// Hides the window.
  430. fn hide(&self) -> Result<()>;
  431. /// Closes the window.
  432. fn close(&self) -> Result<()>;
  433. /// Updates the decorations flag.
  434. fn set_decorations(&self, decorations: bool) -> Result<()>;
  435. /// Updates the shadow flag.
  436. fn set_shadow(&self, enable: bool) -> Result<()>;
  437. /// Updates the window alwaysOnTop flag.
  438. fn set_always_on_top(&self, always_on_top: bool) -> Result<()>;
  439. /// Updates the window visibleOnAllWorkspaces flag.
  440. fn set_visible_on_all_workspaces(&self, visible_on_all_workspaces: bool) -> Result<()>;
  441. /// Prevents the window contents from being captured by other apps.
  442. fn set_content_protected(&self, protected: bool) -> Result<()>;
  443. /// Resizes the window.
  444. fn set_size(&self, size: Size) -> Result<()>;
  445. /// Updates the window min size.
  446. fn set_min_size(&self, size: Option<Size>) -> Result<()>;
  447. /// Updates the window max size.
  448. fn set_max_size(&self, size: Option<Size>) -> Result<()>;
  449. /// Updates the window position.
  450. fn set_position(&self, position: Position) -> Result<()>;
  451. /// Updates the window fullscreen state.
  452. fn set_fullscreen(&self, fullscreen: bool) -> Result<()>;
  453. /// Bring the window to front and focus.
  454. fn set_focus(&self) -> Result<()>;
  455. /// Updates the window icon.
  456. fn set_icon(&self, icon: Icon) -> Result<()>;
  457. /// Whether to hide the window icon from the taskbar or not.
  458. fn set_skip_taskbar(&self, skip: bool) -> Result<()>;
  459. /// Grabs the cursor, preventing it from leaving the window.
  460. ///
  461. /// There's no guarantee that the cursor will be hidden. You should
  462. /// hide it by yourself if you want so.
  463. fn set_cursor_grab(&self, grab: bool) -> Result<()>;
  464. /// Modifies the cursor's visibility.
  465. ///
  466. /// If `false`, this will hide the cursor. If `true`, this will show the cursor.
  467. fn set_cursor_visible(&self, visible: bool) -> Result<()>;
  468. // Modifies the cursor icon of the window.
  469. fn set_cursor_icon(&self, icon: CursorIcon) -> Result<()>;
  470. /// Changes the position of the cursor in window coordinates.
  471. fn set_cursor_position<Pos: Into<Position>>(&self, position: Pos) -> Result<()>;
  472. /// Ignores the window cursor events.
  473. fn set_ignore_cursor_events(&self, ignore: bool) -> Result<()>;
  474. /// Starts dragging the window.
  475. fn start_dragging(&self) -> Result<()>;
  476. /// Executes javascript on the window this [`Dispatch`] represents.
  477. fn eval_script<S: Into<String>>(&self, script: S) -> Result<()>;
  478. /// Sets the taskbar progress state.
  479. ///
  480. /// ## Platform-specific
  481. ///
  482. /// - **Linux / macOS**: Progress bar is app-wide and not specific to this window. Only supported desktop environments with `libunity` (e.g. GNOME).
  483. /// - **iOS / Android:** Unsupported.
  484. fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>;
  485. }