summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/src/window.rs28
-rw-r--r--winit/src/program.rs10
2 files changed, 38 insertions, 0 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index ce6fd1b6..cdf3d80a 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -147,6 +147,18 @@ pub enum Action {
/// Screenshot the viewport of the window.
Screenshot(Id, oneshot::Sender<Screenshot>),
+
+ /// Enables mouse passthrough for the given window.
+ ///
+ /// This disables mouse events for the window and passes mouse events
+ /// through to whatever window is underneath.
+ EnableMousePassthrough(Id),
+
+ /// Disable mouse passthrough for the given window.
+ ///
+ /// This enables mouse events for the window and stops mouse events
+ /// from being passed to whatever is underneath.
+ DisableMousePassthrough(Id),
}
/// Subscribes to the frames of the window of the running application.
@@ -406,3 +418,19 @@ pub fn screenshot(id: Id) -> Task<Screenshot> {
crate::Action::Window(Action::Screenshot(id, channel))
})
}
+
+/// Enables mouse passthrough for the given window.
+///
+/// This disables mouse events for the window and passes mouse events
+/// through to whatever window is underneath.
+pub fn enable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
+ task::effect(crate::Action::Window(Action::EnableMousePassthrough(id)))
+}
+
+/// Disable mouse passthrough for the given window.
+///
+/// This enables mouse events for the window and stops mouse events
+/// from being passed to whatever is underneath.
+pub fn disable_mouse_passthrough<Message>(id: Id) -> Task<Message> {
+ task::effect(crate::Action::Window(Action::DisableMousePassthrough(id)))
+}
diff --git a/winit/src/program.rs b/winit/src/program.rs
index 89ec5ef9..52d8eb5f 100644
--- a/winit/src/program.rs
+++ b/winit/src/program.rs
@@ -1435,6 +1435,16 @@ fn run_action<P, C>(
));
}
}
+ window::Action::EnableMousePassthrough(id) => {
+ if let Some(window) = window_manager.get_mut(id) {
+ let _ = window.raw.set_cursor_hittest(false);
+ }
+ }
+ window::Action::DisableMousePassthrough(id) => {
+ if let Some(window) = window_manager.get_mut(id) {
+ let _ = window.raw.set_cursor_hittest(true);
+ }
+ }
},
Action::System(action) => match action {
system::Action::QueryInformation(_channel) => {