| 1 | #+AUTHOR: Tony |
| 2 | #+STARTUP: overview |
| 3 | |
| 4 | * OXWM — DWM but Better (and oxidized) |
| 5 | A dynamic window manager written in Rust, inspired by dwm but designed to evolve |
| 6 | on its own. Configuration is done in Rust source code, keeping with the suckless |
| 7 | philosophy of *"edit + recompile."* |
| 8 | |
| 9 | This project is still in its early stages. Currently, it can claim ownership of |
| 10 | an X display and log incoming events. |
| 11 | |
| 12 | * Project Structure |
| 13 | |
| 14 | ** src/ |
| 15 | *** main.rs |
| 16 | - main() :: Creates WindowManager and calls .run() |
| 17 | |
| 18 | *** window_manager.rs (CORE) |
| 19 | Handles all X11 events and window management |
| 20 | |
| 21 | **** struct WindowManager |
| 22 | - connection :: X11 connection |
| 23 | - windows :: Vec<Window> (all managed windows) |
| 24 | - focused_window :: Option<Window> |
| 25 | - layout :: Box<dyn Layout> |
| 26 | |
| 27 | **** Methods |
| 28 | - new() :: Initialize WM, grab root window |
| 29 | - run() :: Main event loop |
| 30 | - handle_event() :: Routes X11 events |
| 31 | - MapRequest → add window, apply layout |
| 32 | - UnmapNotify → remove window |
| 33 | - DestroyNotify → remove window |
| 34 | - KeyPress → get action, handle it |
| 35 | - handle_key_action() :: Execute keyboard actions |
| 36 | - remove_window() :: Remove from Vec, reapply layout |
| 37 | - set_focus() :: Focus window, update visuals |
| 38 | - cycle_focus() :: Move focus to next window |
| 39 | - update_focus_visuals() :: Set border colors |
| 40 | - apply_layout() :: Position all windows |
| 41 | |
| 42 | *** keyboard/ |
| 43 | **** mod.rs |
| 44 | - Re-exports public interface |
| 45 | |
| 46 | **** keycodes.rs |
| 47 | - Key constants (Q, J, RETURN, etc) |
| 48 | |
| 49 | **** handlers.rs |
| 50 | - enum KeyAction :: SpawnTerminal, CloseWindow, CycleWindow, Quit, None |
| 51 | - setup_keybinds() :: Register keys with X11 |
| 52 | - handle_key_press() :: Parse key → return KeyAction |
| 53 | |
| 54 | *** layout/ |
| 55 | **** mod.rs |
| 56 | - Layout trait definition |
| 57 | |
| 58 | **** tiling.rs |
| 59 | - TilingLayout :: Implementation |
| 60 | - arrange() :: Calculate window positions |
| 61 | |
| 62 | * Event Flow |
| 63 | |
| 64 | 1. X11 event arrives → run() receives it |
| 65 | 2. handle_event() matches event type |
| 66 | 3. For KeyPress: |
| 67 | - keyboard::handle_key_press() → KeyAction |
| 68 | - handle_key_action() executes action |
| 69 | 4. For Map/Unmap: |
| 70 | - Modify windows Vec |
| 71 | - apply_layout() repositions everything |
| 72 | - update_focus_visuals() redraws borders |
| 73 | |
| 74 | * Key Bindings |
| 75 | |
| 76 | | Binding | Action | |
| 77 | |---------------+----------------------| |
| 78 | | Alt+Return | Spawn terminal | |
| 79 | | Alt+J | Cycle focus | |
| 80 | | Alt+Shift+Q | Close focused window | |
| 81 | | Alt+Shift+Q | Quit WM | |
| 82 | |
| 83 | * ⚙ Installation — Running with Nix Flakes |
| 84 | You can set up a reproducible development environment with Rust, Cargo, Xephyr, xterm, and |
| 85 | just by using the flake. |
| 86 | |
| 87 | #+begin_src sh |
| 88 | git clone https://github.com/tonybanters/oxwm |
| 89 | cd oxwm |
| 90 | |
| 91 | # enter the dev shell |
| 92 | nix develop |
| 93 | |
| 94 | # build normally |
| 95 | cargo build |
| 96 | #+end_src |
| 97 | |
| 98 | * Testing Xephyr with Justfile |
| 99 | The =justfile= includes a =test= recipe that starts Xephyr on =:1=, launches |
| 100 | test clients (xterm, xclock), and runs oxwm in the foreground. |
| 101 | |
| 102 | #+begin_src sh |
| 103 | # inside nix develop |
| 104 | just test |
| 105 | #+end_src |
| 106 | |
| 107 | This should open a new Xephyr window. oxwm will attach to it and log X11 |
| 108 | events in your host terminal. Clients like xterm/xclock will appear inside Xephyr. |
| 109 | |
| 110 | * OXWM Todo List: |
| 111 | ** TODO Reorganization Tasks [1/2] |
| 112 | - [X] Move keyboard module to folder structure: |
| 113 | - [X] Create =src/keyboard/mod.rs= with re-exports |
| 114 | - [X] Move constants to =src/keyboard/keycodes.rs= |
| 115 | - [X] Move key handlers to =src/keyboard/handlers.rs= |
| 116 | - [X] Update imports in main.rs and window_manager.rs |
| 117 | - [ ] Create =src/config.rs= in root directory for future configuration system |
| 118 | |
| 119 | ** TODO Core Window Management [1/2] |
| 120 | - [X] Fix layout after program is closed (handle UnmapNotify events) |
| 121 | - [X] Add UnmapNotify to event handling |
| 122 | - [X] Remove closed windows from windows vector |
| 123 | - [X] Re-apply layout after window removal |
| 124 | - [ ] Add keybind to swap focus between windows |
| 125 | - [ ] Track focused window in WindowManager struct |
| 126 | - [ ] Implement focus cycling logic |
| 127 | - [ ] Add visual focus indication (borders/colors) |
| 128 | |
| 129 | ** Key System Improvements |
| 130 | - [ ] Connect config.rs to keyboard system for dynamic keybind generation |
| 131 | - [ ] Add more dwm-like keybinds: |
| 132 | - [ ] Window focus switching (Alt+J/K) |
| 133 | - [ ] Master area resizing |
| 134 | - [ ] Layout switching |
| 135 | - [ ] Workspace/tag management |
| 136 | - [ ] Better error handling for failed key grabs |
| 137 | |
| 138 | ** Layout System |
| 139 | - [ ] Add more layout types (monocle, floating) |
| 140 | - [ ] Handle window resize requests properly |
| 141 | - [ ] Add configurable gaps between windows |
| 142 | - [ ] Implement layout switching keybinds |
| 143 | |
| 144 | ** Polish & Features |
| 145 | - [ ] Clean window destruction/cleanup |
| 146 | - [ ] Handle edge cases (empty window list, invalid windows) |
| 147 | - [ ] Add status bar integration |
| 148 | - [ ] Better error messages and logging |
| 149 | |
| 150 | ** Priority |
| 151 | Reorganization and UnmapNotify handling should be immediate priorities. |
| 152 | |
| 153 | * Status |
| 154 | - Rust + x11rb skeleton running |
| 155 | - Nix flake devShell available |
| 156 | - =just test= launches Xephyr, clients, and oxwm |
| 157 | |
| 158 | * License |
| 159 | [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL]] |