feat: add window api

This commit is contained in:
mrxiaozhuox committed 2022-02-10 16:59:28 +08:00
1 parent f28fb7165a
commit 01435d6aff
2 files changed
+21 -12

No files matched your search

+4 -2
View File
@@ -71,8 +71,10 @@ impl DesktopContext {
}
/// hide the menu
pub fn hide_menu(&self) {
let _ = self.proxy.send_event(UserWindowEvent::HideMenu);
pub fn set_decorations(&self, decoration: bool) {
let _ = self
.proxy
.send_event(UserWindowEvent::SetDecorations(decoration));
}
}
+17 -10
View File
@@ -72,7 +72,7 @@ use tao::{
pub use wry;
pub use wry::application as tao;
use wry::{
application::event_loop::EventLoopProxy,
application::{event_loop::EventLoopProxy, window::Fullscreen},
webview::RpcRequest,
webview::{WebView, WebViewBuilder},
};
@@ -315,12 +315,24 @@ pub fn launch_with_props<P: 'static + Send>(
window.set_maximized(state);
}
}
UserWindowEvent::Fullscreen(fullscreen) => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.set_fullscreen(*fullscreen.clone());
}
}
UserWindowEvent::FocusWindow => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.set_focus();
}
}
UserWindowEvent::Resizable(state) => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.set_resizable(state);
}
}
UserWindowEvent::SetTitle(content) => {
for webview in desktop.webviews.values() {
@@ -328,16 +340,10 @@ pub fn launch_with_props<P: 'static + Send>(
window.set_title(&content);
}
}
UserWindowEvent::Resizable(state) => {
UserWindowEvent::SetDecorations(state) => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.set_resizable(state);
}
}
UserWindowEvent::HideMenu => {
for webview in desktop.webviews.values() {
let window = webview.window();
window.hide_menu();
window.set_decorations(state);
}
}
}
@@ -360,9 +366,10 @@ pub enum UserWindowEvent {
Minimize(bool),
Maximize(bool),
Resizable(bool),
Fullscreen(Box<Option<Fullscreen>>),
SetTitle(String),
HideMenu,
SetDecorations(bool),
}
pub struct DesktopController {