Set window type to dock

- `_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK`
- This lets an X11 WM treat it as a panel/dock
This commit is contained in:
Candifloss 2025-11-18 16:15:44 +05:30
parent d587a9866b
commit 04f2050af0
2 changed files with 22 additions and 7 deletions

View File

@ -7,10 +7,9 @@ authors = ["candifloss <candifloss.cc>"]
readme = "README.md"
[dependencies]
raw-window-handle = "0.6.2"
slint = { version = "1.14.1", features = ["raw-window-handle-06", "renderer-software"] }
i-slint-backend-winit = { version = "1.14.1", features = ["x11"] }
slint = { version = "1.14.1", features = ["backend-winit"] }
winit = { version = "0.30.12", features = ["x11rb"] }
x11rb = "0.13.2"
[build-dependencies]
slint-build = "1.14.1"

View File

@ -1,18 +1,34 @@
use slint::{LogicalPosition, LogicalSize};
use i_slint_backend_winit::{Backend, winit};
slint::include_modules!();
fn main() -> Result<(), Box<dyn std::error::Error>> {
use winit::platform::x11::{WindowAttributesExtX11, WindowType};
// Configure winit attributes before any Slint window is created.
let backend = Backend::builder()
.with_window_attributes_hook(|attrs| {
// Mark the X11 window as a dock so WMs treat it as a panel/topbar.
attrs
.with_x11_window_type(vec![WindowType::Dock])
// hide from taskbar / pagers (useful for panels)
//.with_skip_taskbar(true)
})
.build()?;
slint::platform::set_platform(Box::new(backend))?;
let bar_height = 25;
let bar_width = 1366;
let ui = TopBar::new()?;
ui.set_bar_width(bar_width);
ui.set_bar_height(bar_height);
ui.window()
.set_size(LogicalSize::new(bar_width as f32, bar_height as f32));
ui.window().set_position(LogicalPosition::new(0.0, 0.0));
ui.run()?;
ui.window().set_size(LogicalSize::new(bar_width as f32, bar_height as f32));
ui.window().set_position(LogicalPosition::new(0.0, 0.0));
ui.run()?;
Ok(())
}