From 04f2050af0dd7c83c1fa788707593cfd6ca89c3f Mon Sep 17 00:00:00 2001 From: Candifloss Date: Tue, 18 Nov 2025 16:15:44 +0530 Subject: [PATCH] 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 --- Cargo.toml | 5 ++--- src/main.rs | 24 ++++++++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ac894f..69635f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,9 @@ authors = ["candifloss "] 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" diff --git a/src/main.rs b/src/main.rs index d629a6a..8fe8372 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,34 @@ use slint::{LogicalPosition, LogicalSize}; +use i_slint_backend_winit::{Backend, winit}; slint::include_modules!(); fn main() -> Result<(), Box> { + 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(()) }