Basic full screen window
This commit is contained in:
parent
5a3f46d204
commit
5c9aa42c84
25
src/main.rs
25
src/main.rs
@ -5,11 +5,34 @@ use i_slint_backend_winit::{
|
|||||||
window::WindowAttributes,
|
window::WindowAttributes,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use slint::{LogicalPosition, LogicalSize};
|
||||||
slint::include_modules!();
|
slint::include_modules!();
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
// Configure X11 window attributes before Slint creates the window.
|
||||||
|
let window_attrs = |attrs: WindowAttributes| {
|
||||||
|
attrs
|
||||||
|
// Set the window type to Desktop so WMs avoid normal window rules, treat it as a full screen window.
|
||||||
|
.with_x11_window_type(vec![WindowType::Desktop])
|
||||||
|
// Make the window unmanaged. This prevents tiling WMs from reserving space or moving it.
|
||||||
|
.with_override_redirect(true)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Build and activate backend with X11 window-attribute hook.
|
||||||
|
let backend = Backend::builder()
|
||||||
|
.with_window_attributes_hook(window_attrs)
|
||||||
|
.build()?;
|
||||||
|
slint::platform::set_platform(Box::new(backend))?;
|
||||||
|
|
||||||
let ui = PowerMenu::new()?;
|
let ui = PowerMenu::new()?;
|
||||||
|
|
||||||
|
let screen_width = 1366;
|
||||||
|
let screen_height = 768;
|
||||||
|
|
||||||
|
ui.window().set_size(LogicalSize::new(screen_width as f32, screen_height as f32));
|
||||||
|
ui.window().set_position(LogicalPosition::new(0.0, 0.0));
|
||||||
|
|
||||||
ui.run();
|
ui.run();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
export component PowerMenu inherits Window {
|
export component PowerMenu inherits Window {
|
||||||
|
in property <int> screen-width: 1366;
|
||||||
|
in property <int> screen-height: 768;
|
||||||
|
|
||||||
background: #adadad57;
|
background: #adadad57;
|
||||||
no-frame: true;
|
no-frame: true;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user