|
@@ -14,6 +14,7 @@ use tauri_runtime::{
|
|
|
DetachedWindow, PendingWindow, WindowEvent,
|
|
|
},
|
|
|
Dispatch, Error, Icon, Params, Result, RunEvent, RunIteration, Runtime, RuntimeHandle,
|
|
|
+ UserAttentionType,
|
|
|
};
|
|
|
|
|
|
#[cfg(feature = "menu")]
|
|
@@ -39,7 +40,10 @@ use wry::{
|
|
|
event::{Event, WindowEvent as WryWindowEvent},
|
|
|
event_loop::{ControlFlow, EventLoop, EventLoopProxy, EventLoopWindowTarget},
|
|
|
monitor::MonitorHandle,
|
|
|
- window::{Fullscreen, Icon as WindowIcon, Window, WindowBuilder as WryWindowBuilder, WindowId},
|
|
|
+ window::{
|
|
|
+ Fullscreen, Icon as WindowIcon, UserAttentionType as WryUserAttentionType, Window,
|
|
|
+ WindowBuilder as WryWindowBuilder, WindowId,
|
|
|
+ },
|
|
|
},
|
|
|
webview::{
|
|
|
FileDropEvent as WryFileDropEvent, RpcRequest as WryRpcRequest, RpcResponse, WebContext,
|
|
@@ -245,6 +249,19 @@ impl From<Position> for PositionWrapper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#[derive(Debug, Clone)]
|
|
|
+struct UserAttentionTypeWrapper(WryUserAttentionType);
|
|
|
+
|
|
|
+impl From<UserAttentionType> for UserAttentionTypeWrapper {
|
|
|
+ fn from(request_type: UserAttentionType) -> UserAttentionTypeWrapper {
|
|
|
+ let o = match request_type {
|
|
|
+ UserAttentionType::Critical => WryUserAttentionType::Critical,
|
|
|
+ UserAttentionType::Informational => WryUserAttentionType::Informational,
|
|
|
+ };
|
|
|
+ Self(o)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
pub struct WindowBuilderWrapper {
|
|
|
inner: WryWindowBuilder,
|
|
@@ -467,6 +484,7 @@ enum WindowMessage {
|
|
|
Hwnd(Sender<Hwnd>),
|
|
|
// Setters
|
|
|
Center(Sender<Result<()>>),
|
|
|
+ RequestUserAttention(Option<UserAttentionTypeWrapper>),
|
|
|
SetResizable(bool),
|
|
|
SetTitle(String),
|
|
|
Maximize,
|
|
@@ -680,6 +698,17 @@ impl Dispatch for WryDispatcher {
|
|
|
.map_err(|_| Error::FailedToSendMessage)
|
|
|
}
|
|
|
|
|
|
+ fn request_user_attention(&self, request_type: Option<UserAttentionType>) -> Result<()> {
|
|
|
+ self
|
|
|
+ .context
|
|
|
+ .proxy
|
|
|
+ .send_event(Message::Window(
|
|
|
+ self.window_id,
|
|
|
+ WindowMessage::RequestUserAttention(request_type.map(Into::into)),
|
|
|
+ ))
|
|
|
+ .map_err(|_| Error::FailedToSendMessage)
|
|
|
+ }
|
|
|
+
|
|
|
// Creates a window by dispatching a message to the event loop.
|
|
|
// Note that this must be called from a separate thread, otherwise the channel will introduce a deadlock.
|
|
|
fn create_window<P: Params<Runtime = Self::Runtime>>(
|
|
@@ -1341,6 +1370,9 @@ fn handle_event_loop(
|
|
|
WindowMessage::Center(tx) => {
|
|
|
tx.send(center_window(window)).unwrap();
|
|
|
}
|
|
|
+ WindowMessage::RequestUserAttention(request_type) => {
|
|
|
+ window.request_user_attention(request_type.map(|r| r.0));
|
|
|
+ }
|
|
|
WindowMessage::SetResizable(resizable) => window.set_resizable(resizable),
|
|
|
WindowMessage::SetTitle(title) => window.set_title(&title),
|
|
|
WindowMessage::Maximize => window.set_maximized(true),
|