summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-07-15 19:25:03 +0100
committertcmal <me@aria.rip>2024-07-15 20:44:58 +0100
commit7e3d3a9bae541d0a70c375567b9c9b280c60252e (patch)
treee353cecf2229790697fdbdfafd458b47b2e6278e /src/main.rs
parent4f97eac4f9983c8cfa6ee506a3a20b0abb33f2a3 (diff)
Handle fullscreen requests sent by clients
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 7c6c7bd..122f735 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,8 +29,8 @@ use nix::{
unistd::Pid,
};
use xcb::{
- x::{self, PropertyNotifyEvent},
- Connection as RawConnection, Event, Extension,
+ x::{self, ClientMessageEvent, PropertyNotifyEvent},
+ Connection as RawConnection, Event, Extension, Xid,
};
pub mod clients;
@@ -101,12 +101,13 @@ impl<'a> WM<'a> {
Event::X(x::Event::MapRequest(e)) => self.handle_map_request(&e)?,
Event::X(x::Event::UnmapNotify(e)) => self.handle_unmap_notify(&e),
- // // See focus.rs
+ // See focus.rs
Event::X(x::Event::EnterNotify(e)) => self.handle_enter_notify(&e),
Event::X(x::Event::FocusIn(e)) => self.handle_focus_in(&e),
- // // See below
+ // See below
Event::X(x::Event::PropertyNotify(e)) => self.handle_property_notify(&e),
+ Event::X(x::Event::ClientMessage(e)) => self.handle_client_message(&e),
_ => {}
}
}
@@ -127,10 +128,48 @@ impl<'a> WM<'a> {
if x::ATOM_WM_HINTS == e.atom() {
let focused = self.clients.is_focused(e.window());
if let Some(c) = self.clients.find_client_mut(e.window()) {
- c.sync_properties(&self.conn, focused);
+ c.sync_hints(&self.conn, focused);
}
}
}
+
+ /// Handle some common client requests set out by the EWMH spec
+ fn handle_client_message(&mut self, e: &ClientMessageEvent) {
+ let Some((mon, pos)) = self.clients.find_client_pos(e.window()) else {
+ return;
+ };
+
+ if e.format() != 32 {
+ return;
+ }
+
+ if dbg!(e.r#type()) == dbg!(self.conn.atoms.net_wm_state) {
+ let x::ClientMessageData::Data32(data) = e.data() else {
+ unreachable!();
+ };
+
+ if !(data[1] == self.conn.atoms.net_wm_fullscreen.resource_id()
+ || data[2] == self.conn.atoms.net_wm_fullscreen.resource_id())
+ {
+ return;
+ }
+
+ let mon_geom = self.clients.mon_geometry(mon);
+ let c = self.clients.client_mut(mon, pos).unwrap();
+ let fullscreen = match data[0] {
+ 1 => true,
+ 2 => !c.fullscreen(),
+ _ => false,
+ };
+
+ if fullscreen {
+ c.set_fullscreen(&self.conn, &mon_geom);
+ } else {
+ c.set_tiled(&self.conn);
+ }
+ self.clients.rearrange(&self.conn);
+ }
+ }
}
/// Cleanup this process' children and set some flags.