fix: borderless example
This commit is contained in:
1 parent
332ec30954
commit
62f8e71f7f
3 files changed
+35
-5
No files matched your search
@@ -13,7 +13,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
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 {
|
||||||
class: "text-gray-400 bg-gray-900 body-font",
|
class: "text-gray-400 bg-gray-900 body-font",
|
||||||
onmousedown: move |_| window.drag(),
|
onmousedown: move |_| window.drag_window(),
|
||||||
div {
|
div {
|
||||||
class: "container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center",
|
class: "container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center",
|
||||||
a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
|
a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
|
||||||
@@ -23,13 +23,13 @@ fn app(cx: Scope) -> Element {
|
|||||||
button {
|
button {
|
||||||
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
||||||
onmousedown: |evt| evt.cancel_bubble(),
|
onmousedown: |evt| evt.cancel_bubble(),
|
||||||
onclick: move |_| window.minimize(true),
|
onclick: move |_| window.set_minimized(true),
|
||||||
"Minimize"
|
"Minimize"
|
||||||
}
|
}
|
||||||
button {
|
button {
|
||||||
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
||||||
onmousedown: |evt| evt.cancel_bubble(),
|
onmousedown: |evt| evt.cancel_bubble(),
|
||||||
onclick: move |_| window.close(),
|
onclick: move |_| window.close_window(),
|
||||||
"Close"
|
"Close"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ impl DesktopContext {
|
|||||||
let _ = self.proxy.send_event(UserWindowEvent::Maximize(maximized));
|
let _ = self.proxy.send_event(UserWindowEvent::Maximize(maximized));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set window visible or not
|
||||||
pub fn set_visible(&self, visible: bool) {
|
pub fn set_visible(&self, visible: bool) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::Visible(visible));
|
let _ = self.proxy.send_event(UserWindowEvent::Visible(visible));
|
||||||
}
|
}
|
||||||
@@ -62,6 +63,7 @@ impl DesktopContext {
|
|||||||
let _ = self.proxy.send_event(UserWindowEvent::FocusWindow);
|
let _ = self.proxy.send_event(UserWindowEvent::FocusWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// change window to fullscreen
|
||||||
pub fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
|
pub fn set_fullscreen(&self, fullscreen: Option<Fullscreen>) {
|
||||||
let _ = self
|
let _ = self
|
||||||
.proxy
|
.proxy
|
||||||
@@ -73,16 +75,23 @@ impl DesktopContext {
|
|||||||
let _ = self.proxy.send_event(UserWindowEvent::Resizable(resizable));
|
let _ = self.proxy.send_event(UserWindowEvent::Resizable(resizable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// set the window always on top
|
||||||
pub fn set_always_on_top(&self, top: bool) {
|
pub fn set_always_on_top(&self, top: bool) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::AlwaysOnTop(top));
|
let _ = self.proxy.send_event(UserWindowEvent::AlwaysOnTop(top));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set cursor visible or not
|
||||||
pub fn set_cursor_visible(&self, visible: bool) {
|
pub fn set_cursor_visible(&self, visible: bool) {
|
||||||
let _ = self
|
let _ = self
|
||||||
.proxy
|
.proxy
|
||||||
.send_event(UserWindowEvent::CursorVisible(visible));
|
.send_event(UserWindowEvent::CursorVisible(visible));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set cursor grab
|
||||||
|
pub fn set_cursor_grab(&self, grab: bool) {
|
||||||
|
let _ = self.proxy.send_event(UserWindowEvent::CursorGrab(grab));
|
||||||
|
}
|
||||||
|
|
||||||
/// set window title
|
/// set window title
|
||||||
pub fn set_title(&self, title: &str) {
|
pub fn set_title(&self, title: &str) {
|
||||||
let _ = self
|
let _ = self
|
||||||
@@ -90,12 +99,17 @@ impl DesktopContext {
|
|||||||
.send_event(UserWindowEvent::SetTitle(String::from(title)));
|
.send_event(UserWindowEvent::SetTitle(String::from(title)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// hide the menu
|
/// change window to borderless
|
||||||
pub fn set_decorations(&self, decoration: bool) {
|
pub fn set_decorations(&self, decoration: bool) {
|
||||||
let _ = self
|
let _ = self
|
||||||
.proxy
|
.proxy
|
||||||
.send_event(UserWindowEvent::SetDecorations(decoration));
|
.send_event(UserWindowEvent::SetDecorations(decoration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// skip/hidden the taskbar icon
|
||||||
|
pub fn set_skip_taskbar(&self, skip: bool) {
|
||||||
|
let _ = self.proxy.send_event(UserWindowEvent::SkipTaskBar(skip));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// use this function can get the `DesktopContext` context.
|
/// use this function can get the `DesktopContext` context.
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ use tao::{
|
|||||||
pub use wry;
|
pub use wry;
|
||||||
pub use wry::application as tao;
|
pub use wry::application as tao;
|
||||||
use wry::{
|
use wry::{
|
||||||
application::{event_loop::EventLoopProxy, window::Fullscreen},
|
application::{
|
||||||
|
event_loop::EventLoopProxy, platform::windows::WindowExtWindows, window::Fullscreen,
|
||||||
|
},
|
||||||
webview::RpcRequest,
|
webview::RpcRequest,
|
||||||
webview::{WebView, WebViewBuilder},
|
webview::{WebView, WebViewBuilder},
|
||||||
};
|
};
|
||||||
@@ -352,6 +354,12 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
window.set_cursor_visible(state);
|
window.set_cursor_visible(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::CursorGrab(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
let _ = window.set_cursor_grab(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UserWindowEvent::SetTitle(content) => {
|
UserWindowEvent::SetTitle(content) => {
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
@@ -365,6 +373,12 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
window.set_decorations(state);
|
window.set_decorations(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::SkipTaskBar(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_skip_taskbar(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::MainEventsCleared => {}
|
Event::MainEventsCleared => {}
|
||||||
@@ -390,9 +404,11 @@ pub enum UserWindowEvent {
|
|||||||
Fullscreen(Box<Option<Fullscreen>>),
|
Fullscreen(Box<Option<Fullscreen>>),
|
||||||
|
|
||||||
CursorVisible(bool),
|
CursorVisible(bool),
|
||||||
|
CursorGrab(bool),
|
||||||
|
|
||||||
SetTitle(String),
|
SetTitle(String),
|
||||||
SetDecorations(bool),
|
SetDecorations(bool),
|
||||||
|
SkipTaskBar(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DesktopController {
|
pub struct DesktopController {
|
||||||
|
|||||||
Reference in new issue
Block a user