Hide window from taskbar

This commit is contained in:
Armin Friedl 2022-04-16 08:42:43 +02:00
parent 020924b569
commit 8cdfca3a62

View file

@ -6,6 +6,8 @@ use winit::event::{
WindowEvent::{CloseRequested, ReceivedCharacter}, WindowEvent::{CloseRequested, ReceivedCharacter},
}; };
use winit::event_loop::{ControlFlow, EventLoop}; use winit::event_loop::{ControlFlow, EventLoop};
use winit::platform::unix::x11::util::WindowType;
use winit::platform::unix::{WindowBuilderExtUnix, WindowExtUnix, XWindowType};
use winit::window::{Window, WindowBuilder}; use winit::window::{Window, WindowBuilder};
use self::core::roftl::Roftl; use self::core::roftl::Roftl;
@ -40,9 +42,40 @@ fn main() -> Result<(), Box<dyn Error>> {
let window = WindowBuilder::new() let window = WindowBuilder::new()
.with_decorations(false) .with_decorations(false)
.with_transparent(true) .with_transparent(true)
.with_title("roftl")
.with_visible(true)
.with_always_on_top(true)
.build(&event_loop) .build(&event_loop)
.expect("Could not create window"); .expect("Could not create window");
debug! {"Hide window from taskbar"}
let screen = window
.xlib_screen_id()
.expect("Could not get screen id of window");
let xcb_conn = unsafe {
xcb::Connection::from_raw_conn(
window.xcb_connection().unwrap() as *mut xcb::ffi::xcb_connection_t
)
};
let ewmh_conn = xcb_util::ewmh::Connection::connect(xcb_conn)
.map_err(|(e, _)| e)
.unwrap();
let xcb_window: xcb::xproto::Window =
window.xlib_window().expect("Cannot get xlib window") as u32;
xcb_util::ewmh::request_change_wm_state(
&ewmh_conn,
screen,
xcb_window,
xcb_util::ewmh::STATE_ADD,
ewmh_conn.WM_STATE(),
ewmh_conn.WM_STATE_SKIP_TASKBAR(),
xcb_util::ewmh::CLIENT_SOURCE_TYPE_NORMAL,
);
debug! {"Window id: {:?}", window.id()} debug! {"Window id: {:?}", window.id()}
debug! {"Draw primary state to window"} debug! {"Draw primary state to window"}