feat: commit code

This commit is contained in:
mrxiaozhuox committed 2022-02-11 10:36:29 +08:00
1 parent 557201816b
commit da0f596cde
3 files changed
+26 -6

No files matched your search

+2
View File
@@ -9,6 +9,8 @@ fn main() {
fn app(cx: Scope) -> Element { fn app(cx: Scope) -> Element {
let window = dioxus::desktop::use_window(&cx); let window = dioxus::desktop::use_window(&cx);
// window.set_fullscreen(true);
cx.render(rsx!( cx.render(rsx!(
link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" } link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" }
header { header {
+3 -3
View File
@@ -1,7 +1,7 @@
use std::rc::Rc; use std::rc::Rc;
use dioxus_core::ScopeState; use dioxus_core::ScopeState;
use wry::application::{event_loop::EventLoopProxy, window::Fullscreen}; use wry::application::event_loop::EventLoopProxy;
use crate::UserWindowEvent; use crate::UserWindowEvent;
@@ -64,10 +64,10 @@ impl DesktopContext {
} }
/// change window to fullscreen /// change window to fullscreen
pub fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) { pub fn set_fullscreen(&self, fullscreen: bool) {
let _ = self let _ = self
.proxy .proxy
.send_event(UserWindowEvent::Fullscreen(Box::new(fullscreen))); .send_event(UserWindowEvent::Fullscreen(fullscreen));
} }
/// set resizable state /// set resizable state
+21 -3
View File
@@ -292,6 +292,11 @@ pub fn launch_with_props<P: 'static + Send>(
let window = webview.window(); let window = webview.window();
// start to drag the window. // start to drag the window.
// if the drag_window have any err. we don't do anything. // if the drag_window have any err. we don't do anything.
if window.fullscreen().is_some() {
return;
}
let _ = window.drag_window(); let _ = window.drag_window();
} }
} }
@@ -321,10 +326,23 @@ pub fn launch_with_props<P: 'static + Send>(
window.set_maximized(state); window.set_maximized(state);
} }
} }
UserWindowEvent::Fullscreen(fullscreen) => { UserWindowEvent::Fullscreen(state) => {
for webview in desktop.webviews.values() { for webview in desktop.webviews.values() {
let window = webview.window(); let window = webview.window();
window.set_fullscreen(*fullscreen.clone());
let current_monitor = window.current_monitor();
if current_monitor.is_none() {
return;
}
let fullscreen = if state {
Some(Fullscreen::Borderless(current_monitor))
} else {
None
};
window.set_fullscreen(fullscreen);
} }
} }
UserWindowEvent::FocusWindow => { UserWindowEvent::FocusWindow => {
@@ -393,7 +411,7 @@ pub enum UserWindowEvent {
Maximize(bool), Maximize(bool),
Resizable(bool), Resizable(bool),
AlwaysOnTop(bool), AlwaysOnTop(bool),
Fullscreen(Box<Option<Fullscreen>>), Fullscreen(bool),
CursorVisible(bool), CursorVisible(bool),
CursorGrab(bool), CursorGrab(bool),