fullscreen fix?

This commit is contained in:
Janis 2022-05-17 16:46:40 +02:00
parent ae89404de3
commit 1d15ef6336
4 changed files with 55 additions and 26 deletions

View file

@ -21,6 +21,11 @@ pub trait WindowServerBackend {
fn focus_window(&self, window: Self::Window);
fn unfocus_window(&self, window: Self::Window);
fn raise_window(&self, window: Self::Window);
fn set_window_fullscreen_state(
&self,
window: Self::Window,
fullscreen: bool,
);
fn hide_window(&self, window: Self::Window);
fn kill_window(&self, window: Self::Window);
fn get_parent_window(&self, window: Self::Window) -> Option<Self::Window>;

View file

@ -818,9 +818,10 @@ impl XLib {
}
unsafe fn init_as_wm(&self) {
let mut window_attributes =
let mut window_attributes = unsafe {
std::mem::MaybeUninit::<xlib::XSetWindowAttributes>::zeroed()
.assume_init();
.assume_init()
};
window_attributes.event_mask = xlib::SubstructureRedirectMask
| xlib::StructureNotifyMask
@ -829,6 +830,7 @@ impl XLib {
| xlib::PointerMotionMask
| xlib::ButtonPressMask;
unsafe {
xlib::XChangeWindowAttributes(
self.connection.dpy(),
self.connection.root(),
@ -844,6 +846,7 @@ impl XLib {
xlib::XSetErrorHandler(Some(xlib_error_handler));
xlib::XSync(self.dpy(), 0);
}
self.ewmh_atoms.set_supported_atoms(self.connection.clone());
self.connection.delete_property(
@ -1723,6 +1726,30 @@ impl WindowServerBackend for XLib {
},
}
}
fn set_window_fullscreen_state(
&self,
window: Self::Window,
fullscreen: bool,
) {
if fullscreen {
self.connection.change_property_long(
window,
self.ewmh_atoms[EWMHAtom::NetWmState],
XA_WINDOW,
PropMode::Replace,
&[self.ewmh_atoms[EWMHAtom::NetWmStateFullscreen] as _],
);
} else {
self.connection.change_property_long(
window,
self.ewmh_atoms[EWMHAtom::NetWmState],
XA_WINDOW,
PropMode::Replace,
&[0 as _],
);
}
}
}
impl TryFrom<EWMHAtom> for WindowType {
@ -1748,7 +1775,7 @@ unsafe extern "C" fn xlib_error_handler(
_dpy: *mut x11::xlib::Display,
ee: *mut x11::xlib::XErrorEvent,
) -> std::os::raw::c_int {
let err_event = ee.as_ref().unwrap();
let err_event = unsafe { ee.as_ref().unwrap() };
let err = XlibError::from(err_event.error_code);
match err {

View file

@ -1,3 +1,5 @@
#![deny(unsafe_op_in_unsafe_fn)]
pub mod backends;
pub mod clients;
pub mod state;

View file

@ -203,16 +203,6 @@ where
},
));
// self.add_keybind(KeyBinding::new(
// KeyBind::new(VirtualKeyCode::Print),
// |wm, _| wm.spawn("screenshot.sh", &[]),
// ));
// self.add_keybind(KeyBinding::new(
// KeyBind::new(VirtualKeyCode::Print).with_mod(ModifierKey::Shift),
// |wm, _| wm.spawn("screenshot.sh", &["-edit"]),
// ));
self.add_keybind(KeyBinding::new(
KeyBind::new(VirtualKeyCode::M).with_mod(self.config.mod_key),
|wm, _| wm.handle_switch_stack(),
@ -488,6 +478,11 @@ where
Some(self.clients.get_border())
},
);
self.backend.set_window_fullscreen_state(
client.window,
client.is_fullscreen(),
);
};
self.arrange_clients();