|
@@ -1092,6 +1092,7 @@ pub enum WindowMessage {
|
|
|
Title(Sender<String>),
|
|
|
CurrentMonitor(Sender<Option<MonitorHandle>>),
|
|
|
PrimaryMonitor(Sender<Option<MonitorHandle>>),
|
|
|
+ MonitorFromPoint(Sender<Option<MonitorHandle>>, (f64, f64)),
|
|
|
AvailableMonitors(Sender<Vec<MonitorHandle>>),
|
|
|
#[cfg(any(
|
|
|
target_os = "linux",
|
|
@@ -1578,6 +1579,21 @@ impl<T: UserEvent> WindowDispatch<T> for WryWindowDispatcher<T> {
|
|
|
Ok(window_getter!(self, WindowMessage::PrimaryMonitor)?.map(|m| MonitorHandleWrapper(m).into()))
|
|
|
}
|
|
|
|
|
|
+ fn monitor_from_point(&self, x: f64, y: f64) -> Result<Option<Monitor>> {
|
|
|
+ let (tx, rx) = channel();
|
|
|
+
|
|
|
+ let _ = send_user_message(
|
|
|
+ &self.context,
|
|
|
+ Message::Window(self.window_id, WindowMessage::MonitorFromPoint(tx, (x, y))),
|
|
|
+ );
|
|
|
+
|
|
|
+ Ok(
|
|
|
+ rx.recv()
|
|
|
+ .map_err(|_| crate::Error::FailedToReceiveMessage)?
|
|
|
+ .map(|m| MonitorHandleWrapper(m).into()),
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
fn available_monitors(&self) -> Result<Vec<Monitor>> {
|
|
|
Ok(
|
|
|
window_getter!(self, WindowMessage::AvailableMonitors)?
|
|
@@ -2149,6 +2165,15 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
|
|
|
.map(|m| MonitorHandleWrapper(m).into())
|
|
|
}
|
|
|
|
|
|
+ fn monitor_from_point(&self, x: f64, y: f64) -> Option<Monitor> {
|
|
|
+ self
|
|
|
+ .context
|
|
|
+ .main_thread
|
|
|
+ .window_target
|
|
|
+ .monitor_from_point(x, y)
|
|
|
+ .map(|m| MonitorHandleWrapper(m).into())
|
|
|
+ }
|
|
|
+
|
|
|
fn available_monitors(&self) -> Vec<Monitor> {
|
|
|
self
|
|
|
.context
|
|
@@ -2407,6 +2432,15 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
|
|
.map(|m| MonitorHandleWrapper(m).into())
|
|
|
}
|
|
|
|
|
|
+ fn monitor_from_point(&self, x: f64, y: f64) -> Option<Monitor> {
|
|
|
+ self
|
|
|
+ .context
|
|
|
+ .main_thread
|
|
|
+ .window_target
|
|
|
+ .monitor_from_point(x, y)
|
|
|
+ .map(|m| MonitorHandleWrapper(m).into())
|
|
|
+ }
|
|
|
+
|
|
|
fn available_monitors(&self) -> Vec<Monitor> {
|
|
|
self
|
|
|
.context
|
|
@@ -2643,6 +2677,9 @@ fn handle_user_message<T: UserEvent>(
|
|
|
WindowMessage::Title(tx) => tx.send(window.title()).unwrap(),
|
|
|
WindowMessage::CurrentMonitor(tx) => tx.send(window.current_monitor()).unwrap(),
|
|
|
WindowMessage::PrimaryMonitor(tx) => tx.send(window.primary_monitor()).unwrap(),
|
|
|
+ WindowMessage::MonitorFromPoint(tx, (x, y)) => {
|
|
|
+ tx.send(window.monitor_from_point(x, y)).unwrap()
|
|
|
+ }
|
|
|
WindowMessage::AvailableMonitors(tx) => {
|
|
|
tx.send(window.available_monitors().collect()).unwrap()
|
|
|
}
|