diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/atoms.rs | 2 | ||||
-rw-r--r-- | src/clients.rs | 22 | ||||
-rw-r--r-- | src/cursors.rs | 2 | ||||
-rw-r--r-- | src/error.rs | 21 | ||||
-rw-r--r-- | src/focus.rs | 17 | ||||
-rw-r--r-- | src/keys.rs | 12 | ||||
-rw-r--r-- | src/main.rs | 57 |
7 files changed, 103 insertions, 30 deletions
diff --git a/src/atoms.rs b/src/atoms.rs index 363e07c..4dfcf47 100644 --- a/src/atoms.rs +++ b/src/atoms.rs @@ -1,4 +1,4 @@ -use crate::Result; +use crate::error::*; use xcb::Connection; #[derive(Debug)] diff --git a/src/clients.rs b/src/clients.rs index 70a44fa..6a3d71c 100644 --- a/src/clients.rs +++ b/src/clients.rs @@ -1,9 +1,13 @@ use xcb::{ + x::{ + ConfigureNotifyEvent, ConfigureRequestEvent, DestroyNotifyEvent, MapRequestEvent, + UnmapNotifyEvent, + }, xinerama::{self, ScreenInfo}, Extension, }; -use crate::{Error, Result, WM}; +use crate::{error::*, WM}; #[derive(Debug, Default)] pub struct ClientList(Vec<MonitorInfo>); @@ -101,4 +105,20 @@ impl WM<'_> { Ok(()) } + + pub(crate) fn handle_configure_request(&mut self, e: ConfigureRequestEvent) -> Result<()> { + todo!() + } + pub(crate) fn handle_configure_notify(&mut self, e: ConfigureNotifyEvent) -> Result<()> { + todo!() + } + pub(crate) fn handle_destroy_notify(&mut self, e: DestroyNotifyEvent) -> Result<()> { + todo!() + } + pub(crate) fn handle_map_request(&mut self, e: MapRequestEvent) -> Result<()> { + todo!() + } + pub(crate) fn handle_unmap_notify(&mut self, e: UnmapNotifyEvent) -> Result<()> { + todo!() + } } diff --git a/src/cursors.rs b/src/cursors.rs index 1e5fbd3..2cb8f0e 100644 --- a/src/cursors.rs +++ b/src/cursors.rs @@ -1,4 +1,4 @@ -use crate::Result; +use crate::error::*; use xcb::{ x::{CreateGlyphCursor, Cursor, Font, OpenFont}, Connection, diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..e12ae2c --- /dev/null +++ b/src/error.rs @@ -0,0 +1,21 @@ +use thiserror::Error; + +pub 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), +} diff --git a/src/focus.rs b/src/focus.rs new file mode 100644 index 0000000..d2b1f10 --- /dev/null +++ b/src/focus.rs @@ -0,0 +1,17 @@ +use xcb::x::{self, EnterNotifyEvent, FocusInEvent, MotionNotifyEvent}; + +use crate::{error::*, WM}; + +impl WM<'_> { + pub(crate) fn handle_enter_notify(&self, e: EnterNotifyEvent) -> Result<()> { + todo!() + } + + pub(crate) fn handle_focus_in(&self, e: FocusInEvent) -> Result<()> { + todo!() + } + + pub(crate) fn handle_motion_notify(&self, e: MotionNotifyEvent) -> Result<()> { + todo!() + } +} diff --git a/src/keys.rs b/src/keys.rs new file mode 100644 index 0000000..6cf28a6 --- /dev/null +++ b/src/keys.rs @@ -0,0 +1,12 @@ +use crate::{error::*, WM}; +use xcb::x::{KeyPressEvent, MappingNotifyEvent}; + +impl WM<'_> { + pub(crate) fn handle_key_press(&mut self, e: KeyPressEvent) -> Result<()> { + todo!() + } + + pub(crate) fn handle_mapping_notify(&mut self, e: MappingNotifyEvent) -> Result<()> { + todo!() + } +} 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 |