diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/src/main.rs b/src/main.rs index adacdfd..c2b32a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,35 +1,18 @@ use atoms::InternedAtoms; use clients::ClientList; use cursors::Cursors; -use thiserror::Error; +use error::*; use xcb::{ - x::{self, ChangeWindowAttributes, Window}, - Connection, Extension, + x::{self, ChangeWindowAttributes, PropertyNotifyEvent, Window}, + Connection, Event, Extension, }; mod atoms; mod clients; mod cursors; - -type Result<T, E = Error> = std::result::Result<T, E>; - -#[derive(Debug, Error)] -pub enum Error { - #[error("xcb returned screen that doesn't exist")] - NoSuchScreen, - - #[error("other wm is running")] - OtherWMRunning, - - #[error("connection error: {0}")] - ConnectionError(#[from] xcb::ConnError), - - #[error("protocol error: {0}")] - ProtocolError(#[from] xcb::ProtocolError), - - #[error("generic xcb error: {0}")] - XCBError(#[from] xcb::Error), -} +mod error; +mod focus; +mod keys; fn main() -> Result<()> { // todo: cli stuff @@ -119,14 +102,34 @@ impl WM<'_> { loop { match self.conn.wait_for_event()? { - e => { - dbg!(e); - // TODO: actually deal with events - } + // todo: keybinding related stuff + Event::X(x::Event::KeyPress(e)) => self.handle_key_press(e)?, + Event::X(x::Event::MappingNotify(e)) => self.handle_mapping_notify(e)?, + + // todo: windows coming and going + 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)?, + + // todo: focus stuff + Event::X(x::Event::EnterNotify(e)) => self.handle_enter_notify(e)?, + Event::X(x::Event::FocusIn(e)) => self.handle_focus_in(e)?, + Event::X(x::Event::MotionNotify(e)) => self.handle_motion_notify(e)?, + + // todo: other + Event::X(x::Event::PropertyNotify(e)) => self.handle_property_notify(e)?, + _ => {} }; } } + + fn handle_property_notify(&self, e: PropertyNotifyEvent) -> Result<()> { + todo!() + } } + fn cleanup_process_children() { // todo: dont transform children into zombies when they terminate // todo: cleanup zombies |