diff options
author | tcmal <me@aria.rip> | 2024-06-21 21:37:11 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-06-21 21:37:11 +0100 |
commit | 1c893ed1ff1dc26f4dcc425e756d56f752142ebd (patch) | |
tree | 3802b2c1ee8b07f41509728372a3461ecb78c433 /src | |
parent | 28d1cbca91c35175137ec8f9a9f816f3448467b6 (diff) |
remove incorrect flushing of xcb buffer
Diffstat (limited to 'src')
-rw-r--r-- | src/clients/client.rs | 8 | ||||
-rw-r--r-- | src/clients/hints.rs | 1 | ||||
-rw-r--r-- | src/clients/mod.rs | 14 | ||||
-rw-r--r-- | src/focus.rs | 14 | ||||
-rw-r--r-- | src/keys.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 60 |
6 files changed, 37 insertions, 61 deletions
diff --git a/src/clients/client.rs b/src/clients/client.rs index 3648f0c..3b33b5f 100644 --- a/src/clients/client.rs +++ b/src/clients/client.rs @@ -3,7 +3,7 @@ use xcb::{ ChangeProperty, ChangeWindowAttributes, ConfigWindow, ConfigureNotifyEvent, ConfigureWindow, Cw, EventMask, MapWindow, SendEvent, SendEventDest, Window, }, - VoidCookie, VoidCookieChecked, Xid, + VoidCookieChecked, Xid, }; use crate::{config::BORDER_WIDTH, conn_info::Connection}; @@ -43,7 +43,6 @@ impl Client { } /// Send a configure configure notify event with the current geometry. - /// This function does not check for success, so `conn.flush()` should be called after. pub fn configure_notify(&self, conn: &Connection<'_>) { conn.send_request(&SendEvent { destination: SendEventDest::Window(self.window), @@ -64,7 +63,6 @@ impl Client { } /// Set this client's geometry, also updating the X11 window if needed. - /// This function does not check for success, so `conn.flush()` should be called after. pub fn set_geom( &mut self, conn: &Connection<'_>, @@ -99,7 +97,6 @@ impl Client { } /// Set the border colour of the X11 window to the given value (see `crate::colours::Colours`) - /// This function does not check for success, so `conn.flush()` should be called after. pub fn set_border(&self, conn: &Connection<'_>, colour: u32) { conn.send_request(&ChangeWindowAttributes { window: self.window(), @@ -108,7 +105,6 @@ impl Client { } /// Ensure this client is currently mapped / visible - /// This function does not check for success, so `conn.flush()` should be called after. pub fn ensure_mapped(&mut self, conn: &Connection<'_>) { if !self.mapped { conn.send_request(&MapWindow { @@ -124,7 +120,6 @@ impl Client { } /// Set the event mask for this window - /// This function does not check for success, so `conn.flush()` should be called after. pub fn set_event_mask( &self, conn: &Connection<'_>, @@ -137,7 +132,6 @@ impl Client { } /// Sync the non-geometry related properties with EWMH hints - /// This function does not check for success, so `conn.flush()` should be called after. pub fn sync_properties(&mut self, conn: &Connection<'_>, focused: bool) { let Some(mut hints) = hints::Xwm::get(conn, self.window) else { return; diff --git a/src/clients/hints.rs b/src/clients/hints.rs index 0250401..dd5bcf7 100644 --- a/src/clients/hints.rs +++ b/src/clients/hints.rs @@ -60,7 +60,6 @@ impl Xwm { } /// Set these WM hints on the given window. - /// This function does not check for success, so `conn.flush()` should be called after. pub fn apply(&self, conn: &Connection<'_>, window: Window) { conn.send_request(&ChangeProperty { mode: PropMode::Replace, diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 70e3798..c7df881 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -30,7 +30,6 @@ impl WM<'_> { // - Border width // - Size and position if floating c.configure_notify(&self.conn); - self.conn.flush()?; } else { // Configure it as requested, and sort the rest when we actually map the window self.conn.send_and_check_request(&ConfigureWindow { @@ -53,17 +52,13 @@ impl WM<'_> { pub(crate) fn handle_configure_notify(&mut self, e: &ConfigureNotifyEvent) -> Result<()> { if e.window() == self.conn.root() { self.clients.update_geometry(&self.conn)?; - self.conn.flush()?; } Ok(()) } /// Removing destroyed windows from the client list and rearrange. - pub(crate) fn handle_destroy_notify(&mut self, e: &DestroyNotifyEvent) -> Result<()> { + pub(crate) fn handle_destroy_notify(&mut self, e: &DestroyNotifyEvent) { self.clients.unmanage(&self.conn, e.window(), true); - self.conn.flush()?; - - Ok(()) } /// Map a window, starting to manage it if needed. @@ -85,13 +80,11 @@ impl WM<'_> { // Start managing, and map window self.clients.manage(&self.conn, e.window()); - self.conn.flush()?; - Ok(()) } /// When a window is unmapped, either stop managing it or update its state. - pub(crate) fn handle_unmap_notify(&mut self, e: &UnmapNotifyEvent) -> Result<()> { + pub(crate) fn handle_unmap_notify(&mut self, e: &UnmapNotifyEvent) { if let Some(c) = self.clients.find_client_mut(e.window()) { if e.is_from_send_event() { let cookie = c.set_withdrawn(&self.conn, true); @@ -100,10 +93,7 @@ impl WM<'_> { } else { self.clients.unmanage(&self.conn, e.window(), false); } - self.conn.flush()?; } - - Ok(()) } } diff --git a/src/focus.rs b/src/focus.rs index 0c9512f..65bf65e 100644 --- a/src/focus.rs +++ b/src/focus.rs @@ -1,33 +1,27 @@ use xcb::x::{EnterNotifyEvent, FocusInEvent, NotifyDetail, NotifyMode}; -use crate::{error::Result, WM}; +use crate::WM; impl WM<'_> { /// When a new window is entered, focus it. - pub fn handle_enter_notify(&mut self, e: &EnterNotifyEvent) -> Result<()> { + pub fn handle_enter_notify(&mut self, e: &EnterNotifyEvent) { if (e.mode() != NotifyMode::Normal || e.detail() == NotifyDetail::Inferior) && e.event() != self.conn.root() { - return Ok(()); + return; } if let Some((mon, pos)) = self.clients.find_client_pos(e.event()) { self.clients.refocus(&self.conn, mon, pos); - self.conn.flush()?; } - - Ok(()) } /// When a new window requests focus, focus it. - pub fn handle_focus_in(&mut self, e: &FocusInEvent) -> Result<()> { + pub fn handle_focus_in(&mut self, e: &FocusInEvent) { if !self.clients.is_focused(e.event()) { if let Some((mon, pos)) = self.clients.find_client_pos(e.event()) { self.clients.refocus(&self.conn, mon, pos); - self.conn.flush()?; } } - - Ok(()) } } diff --git a/src/keys.rs b/src/keys.rs index 08cd46d..3103f41 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -71,7 +71,6 @@ fn grab_keys(conn: &mut Connection<'_>) -> Result<()> { } // Ensure all requests succeeded - conn.flush()?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index 7758cac..54d893c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,42 +47,42 @@ impl<'a> WM<'a> { pub fn event_loop(&mut self) -> Result<()> { loop { - match self.conn.wait_for_event()? { - // See keys.rs - Event::X(x::Event::KeyPress(e)) => self.handle_key_press(&e), - Event::X(x::Event::MappingNotify(e)) => self.handle_mapping_notify(&e)?, - - // See clients/mod.rs - Event::X(x::Event::ConfigureRequest(e)) => self.handle_configure_request(&e)?, - Event::X(x::Event::ConfigureNotify(e)) => self.handle_configure_notify(&e)?, - Event::X(x::Event::DestroyNotify(e)) => self.handle_destroy_notify(&e)?, - 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 - Event::X(x::Event::EnterNotify(e)) => self.handle_enter_notify(&e)?, - Event::X(x::Event::FocusIn(e)) => self.handle_focus_in(&e)?, - - // // See below - Event::X(x::Event::PropertyNotify(e)) => self.handle_property_notify(&e)?, - _ => {} + match self.conn.wait_for_event() { + Ok(x) => match x { + // See keys.rs + Event::X(x::Event::KeyPress(e)) => self.handle_key_press(&e), + Event::X(x::Event::MappingNotify(e)) => self.handle_mapping_notify(&e)?, + + // See clients/mod.rs + Event::X(x::Event::ConfigureRequest(e)) => self.handle_configure_request(&e)?, + Event::X(x::Event::ConfigureNotify(e)) => self.handle_configure_notify(&e)?, + Event::X(x::Event::DestroyNotify(e)) => self.handle_destroy_notify(&e), + 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 + Event::X(x::Event::EnterNotify(e)) => self.handle_enter_notify(&e), + Event::X(x::Event::FocusIn(e)) => self.handle_focus_in(&e), + + // // See below + Event::X(x::Event::PropertyNotify(e)) => self.handle_property_notify(&e), + _ => {} + }, + Err(e) => { + eprintln!("error in event loop: {e:#?}\ncontinuing anyway"); + } }; + self.conn.flush()?; } } /// Handle a property notify event, by doing *todo* - fn handle_property_notify(&mut self, e: &PropertyNotifyEvent) -> Result<()> { - match e.atom() { - x::ATOM_WM_HINTS => { - 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); - self.conn.flush()?; - } - - Ok(()) + fn handle_property_notify(&mut self, e: &PropertyNotifyEvent) { + 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); } - _ => Ok(()), } } } |