added a way to add already existing windows to wm
This commit is contained in:
parent
df3c2e33ce
commit
d3b4fcbf18
|
@ -38,7 +38,7 @@ pub trait WindowServerBackend {
|
||||||
fn ungrab_cursor(&self);
|
fn ungrab_cursor(&self);
|
||||||
fn move_cursor(&self, window: Option<Self::Window>, position: Point<i32>);
|
fn move_cursor(&self, window: Option<Self::Window>, position: Point<i32>);
|
||||||
|
|
||||||
fn all_windows(&self) -> Vec<Self::Window>;
|
fn all_windows(&self) -> Option<Vec<Self::Window>>;
|
||||||
|
|
||||||
fn resize_window(&self, window: Self::Window, new_size: Point<i32>) {
|
fn resize_window(&self, window: Self::Window, new_size: Point<i32>) {
|
||||||
self.configure_window(window, Some(new_size), None, None);
|
self.configure_window(window, Some(new_size), None, None);
|
||||||
|
|
|
@ -858,8 +858,32 @@ impl WindowServerBackend for XLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_windows(&self) -> Vec<Self::Window> {
|
fn all_windows(&self) -> Option<Vec<Self::Window>> {
|
||||||
todo!()
|
let mut parent = 0;
|
||||||
|
let mut root = 0;
|
||||||
|
let mut children = std::ptr::null_mut();
|
||||||
|
let mut num_children = 0;
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
xlib::XQueryTree(
|
||||||
|
self.dpy(),
|
||||||
|
self.root,
|
||||||
|
&mut root,
|
||||||
|
&mut parent,
|
||||||
|
&mut children,
|
||||||
|
&mut num_children,
|
||||||
|
) != 0
|
||||||
|
}
|
||||||
|
.then(|| {
|
||||||
|
let windows = unsafe {
|
||||||
|
std::slice::from_raw_parts(children, num_children as usize)
|
||||||
|
.to_vec()
|
||||||
|
};
|
||||||
|
|
||||||
|
unsafe { xlib::XFree(children as *mut _) };
|
||||||
|
|
||||||
|
windows
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,8 @@ use state::WMConfig;
|
||||||
|
|
||||||
mod backends;
|
mod backends;
|
||||||
mod clients;
|
mod clients;
|
||||||
//mod clients2;
|
|
||||||
mod state;
|
mod state;
|
||||||
mod util;
|
mod util;
|
||||||
mod xlib;
|
|
||||||
|
|
||||||
pub mod error {
|
pub mod error {
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -253,6 +253,13 @@ where
|
||||||
|
|
||||||
self.add_vs_switch_keybinds();
|
self.add_vs_switch_keybinds();
|
||||||
|
|
||||||
|
// add all already existing windows to the WM
|
||||||
|
if let Some(windows) = self.backend.all_windows() {
|
||||||
|
windows
|
||||||
|
.into_iter()
|
||||||
|
.for_each(|window| self.new_client(window));
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue