| 1 | #+AUTHOR: Tony |
| 2 | #+STARTUP: overview |
| 3 | |
| 4 | * Table of Contents :toc: |
| 5 | - [[#oxwm--dwm-but-better-and-oxidized][OXWM — DWM but Better (and oxidized)]] |
| 6 | - [[#project-structure][Project Structure]] |
| 7 | - [[#event-flow][Event Flow]] |
| 8 | - [[#key-bindings][Key Bindings]] |
| 9 | - [[#-installation--running-with-nix-flakes][⚙ Installation — Running with Nix Flakes]] |
| 10 | - [[#testing-xephyr-with-justfile][Testing Xephyr with Justfile]] |
| 11 | - [[#current-status][Current Status]] |
| 12 | - [[#working-features][Working Features]] |
| 13 | - [[#immediate-next-steps][Immediate Next Steps]] |
| 14 | - [[#long-term-roadmap][Long Term Roadmap]] |
| 15 | - [[#oxwm-development-todo][OXWM Development Todo]] |
| 16 | - [[#core-window-management-22][Core Window Management]] |
| 17 | - [[#tag-system-33][Tag System]] |
| 18 | - [[#status-bar-22][Status Bar]] |
| 19 | - [[#in-progress-bar-enhancements-03][IN PROGRESS Bar Enhancements]] |
| 20 | - [[#key-system-improvements-02][Key System Improvements]] |
| 21 | - [[#layout-system-04][Layout System]] |
| 22 | - [[#advanced-features-03][Advanced Features]] |
| 23 | - [[#polish--features][Polish & Features]] |
| 24 | - [[#architecture-notes][Architecture Notes]] |
| 25 | - [[#tag-system][Tag System]] |
| 26 | - [[#bar-design][Bar Design]] |
| 27 | - [[#configuration-philosophy][Configuration Philosophy]] |
| 28 | - [[#license][License]] |
| 29 | |
| 30 | * OXWM — DWM but Better (and oxidized) |
| 31 | A dynamic window manager written in Rust, inspired by dwm but designed to evolve |
| 32 | on its own. Configuration is done in Rust source code, keeping with the suckless |
| 33 | philosophy of *"edit + recompile."* |
| 34 | |
| 35 | * Project Structure |
| 36 | |
| 37 | #+begin_src sh |
| 38 | src/ |
| 39 | ├── main.rs |
| 40 | │ └── main() |
| 41 | │ └── Creates WindowManager and calls .run() |
| 42 | │ |
| 43 | ├── window_manager.rs [CORE - X11 event handling] |
| 44 | │ ├── struct WindowManager |
| 45 | │ │ ├── connection: RustConnection [X11 connection] |
| 46 | │ │ ├── windows: Vec<Window> [All managed windows] |
| 47 | │ │ ├── focused_window: Option<Window> |
| 48 | │ │ ├── layout: Box<dyn Layout> |
| 49 | │ │ ├── window_tags: HashMap<Window, TagMask> |
| 50 | │ │ ├── selected_tags: TagMask |
| 51 | │ │ └── bar: Bar [Status bar] |
| 52 | │ │ |
| 53 | │ ├── new() [Initialize WM, grab root, create bar] |
| 54 | │ ├── run() [Main event loop] |
| 55 | │ ├── handle_event() [Route X11 events] |
| 56 | │ │ ├── MapRequest → add window, apply layout, update bar |
| 57 | │ │ ├── UnmapNotify → remove window, update bar |
| 58 | │ │ ├── DestroyNotify → remove window, update bar |
| 59 | │ │ ├── KeyPress → get action, handle it |
| 60 | │ │ ├── ButtonPress → handle bar clicks |
| 61 | │ │ └── Expose → redraw bar |
| 62 | │ ├── handle_key_action() [Execute keyboard actions] |
| 63 | │ ├── remove_window() [Remove from Vec, reapply layout] |
| 64 | │ ├── set_focus() [Focus window, update visuals] |
| 65 | │ ├── cycle_focus() [Move focus to next/prev window] |
| 66 | │ ├── view_tag() [Switch to tag/workspace] |
| 67 | │ ├── move_to_tag() [Move window to tag] |
| 68 | │ ├── update_bar() [Calculate occupied tags, redraw bar] |
| 69 | │ ├── update_focus_visuals() [Set border colors] |
| 70 | │ └── apply_layout() [Position all windows below bar] |
| 71 | │ |
| 72 | ├── config.rs [CONFIGURATION - all settings here] |
| 73 | │ ├── BORDER_WIDTH, BORDER_FOCUSED, BORDER_UNFOCUSED |
| 74 | │ ├── TAG_COUNT, TAGS [Workspace configuration] |
| 75 | │ ├── TERMINAL, MODKEY |
| 76 | │ └── KEYBINDINGS [All keybinds as const array] |
| 77 | │ |
| 78 | ├── bar/ |
| 79 | │ ├── mod.rs [Re-exports, constants] |
| 80 | │ └── bar.rs |
| 81 | │ ├── struct Bar [Status bar window] |
| 82 | │ ├── new() [Create bar X11 window] |
| 83 | │ ├── draw() [Render tags with state indicators] |
| 84 | │ ├── handle_click() [Detect which tag was clicked] |
| 85 | │ └── invalidate() [Mark bar as needing redraw] |
| 86 | │ |
| 87 | ├── keyboard/ |
| 88 | │ ├── mod.rs [Re-exports] |
| 89 | │ ├── keycodes.rs [Key constants: Q, J, RETURN, etc] |
| 90 | │ └── handlers.rs |
| 91 | │ ├── enum KeyAction [Spawn, KillClient, FocusStack, ViewTag, etc] |
| 92 | │ ├── enum Arg [None, Int, Str, Array] |
| 93 | │ ├── setup_keybinds() [Register keys with X11] |
| 94 | │ └── handle_key_press() [Parse KeyPressEvent → KeyAction] |
| 95 | │ |
| 96 | └── layout/ |
| 97 | ├── mod.rs [Layout trait definition] |
| 98 | └── tiling.rs |
| 99 | └── TilingLayout::arrange() [Calculate window positions] |
| 100 | #+end_src |
| 101 | |
| 102 | * Event Flow |
| 103 | |
| 104 | 1. X11 event arrives → run() receives it |
| 105 | 2. handle_event() matches event type |
| 106 | 3. For KeyPress: |
| 107 | - keyboard::handle_key_press() → KeyAction |
| 108 | - handle_key_action() executes action |
| 109 | - update_bar() if tags/windows changed |
| 110 | 4. For Map/Unmap: |
| 111 | - Modify windows Vec and window_tags HashMap |
| 112 | - apply_layout() repositions everything (accounting for bar) |
| 113 | - update_bar() shows occupied tags |
| 114 | - update_focus_visuals() redraws borders |
| 115 | 5. For ButtonPress on bar: |
| 116 | - bar.handle_click() determines clicked tag |
| 117 | - view_tag() switches workspace |
| 118 | |
| 119 | * Key Bindings |
| 120 | |
| 121 | | Binding | Action | |
| 122 | |-----------------+-------------------------| |
| 123 | | Alt+Return | Spawn terminal | |
| 124 | | Alt+J/K | Cycle focus down/up | |
| 125 | | Alt+Q | Kill focused window | |
| 126 | | Alt+Shift+Q | Quit WM | |
| 127 | | Alt+1-9 | View tag 1-9 | |
| 128 | | Alt+Shift+1-9 | Move window to tag 1-9 | |
| 129 | | Alt+S | Screenshot (maim) | |
| 130 | |
| 131 | * ⚙ Installation — Running with Nix Flakes |
| 132 | You can set up a reproducible development environment with Rust, Cargo, Xephyr, xterm, and |
| 133 | just by using the flake. |
| 134 | |
| 135 | #+begin_src sh |
| 136 | git clone https://github.com/tonybanters/oxwm |
| 137 | cd oxwm |
| 138 | |
| 139 | # enter the dev shell |
| 140 | nix develop |
| 141 | |
| 142 | # build normally |
| 143 | cargo build |
| 144 | #+end_src |
| 145 | |
| 146 | * Testing Xephyr with Justfile |
| 147 | The =justfile= includes a =test= recipe that starts Xephyr on =:1=, launches |
| 148 | test clients (xterm, xclock), and runs oxwm in the foreground. |
| 149 | |
| 150 | #+begin_src sh |
| 151 | # inside nix develop |
| 152 | just test |
| 153 | #+end_src |
| 154 | |
| 155 | This should open a new Xephyr window. oxwm will attach to it and log X11 |
| 156 | events in your host terminal. Clients like xterm/xclock will appear inside Xephyr. |
| 157 | |
| 158 | * Current Status |
| 159 | ** Working Features |
| 160 | - ✓ X11 event handling and window management |
| 161 | - ✓ Tag system (9 workspaces) with keyboard switching |
| 162 | - ✓ Window focus cycling (Alt+J/K) |
| 163 | - ✓ Tiling layout with border indicators |
| 164 | - ✓ Status bar showing tags |
| 165 | - Visual indicators: selected (white), occupied (gray line), empty (dim) |
| 166 | - Click-to-switch tags |
| 167 | - Performance-optimized redrawing |
| 168 | - ✓ Basic keybindings (spawn, kill, focus, tags) |
| 169 | - ✓ Configuration via Rust constants in config.rs |
| 170 | |
| 171 | ** Immediate Next Steps |
| 172 | - [ ] Status text in bar (date, time, system info) |
| 173 | - [ ] dmenu integration for application launcher |
| 174 | - [ ] Additional widgets (clock, battery, etc.) |
| 175 | |
| 176 | ** Long Term Roadmap |
| 177 | - [ ] Multi-monitor support |
| 178 | - [ ] Additional layouts (monocle, floating, etc.) |
| 179 | - [ ] Per-window floating behavior |
| 180 | - [ ] Per-program rules (auto-tag assignment, floating rules) |
| 181 | - [ ] Master area resizing |
| 182 | - [ ] Window swapping in layout |
| 183 | - [ ] Configurable gaps between windows |
| 184 | - [ ] External bar support (polybar, lemonbar, etc.) |
| 185 | |
| 186 | * OXWM Development Todo |
| 187 | ** DONE Core Window Management [2/2] |
| 188 | - [X] Fix layout after program is closed (handle UnmapNotify events) |
| 189 | - [X] Add UnmapNotify to event handling |
| 190 | - [X] Remove closed windows from windows vector |
| 191 | - [X] Re-apply layout after window removal |
| 192 | - [X] Add keybind to swap focus between windows |
| 193 | - [X] Track focused window in WindowManager struct |
| 194 | - [X] Implement focus cycling logic |
| 195 | - [X] Add visual focus indication (borders/colors) |
| 196 | |
| 197 | ** DONE Tag System [3/3] |
| 198 | - [X] Implement tag/workspace system (9 tags) |
| 199 | - [X] Keybinds to switch tags (Alt+1-9) |
| 200 | - [X] Keybinds to move windows to tags (Alt+Shift+1-9) |
| 201 | |
| 202 | ** DONE Status Bar [2/2] |
| 203 | - [X] Create basic bar window at screen top |
| 204 | - [X] Display tag indicators with state (selected/occupied/empty) |
| 205 | |
| 206 | ** IN PROGRESS Bar Enhancements [0/3] |
| 207 | - [ ] Add status text area (right side of bar) |
| 208 | - [ ] Implement clock widget |
| 209 | - [ ] Add system information widgets |
| 210 | |
| 211 | ** TODO Key System Improvements [0/2] |
| 212 | - [ ] dmenu integration for application launching |
| 213 | - [ ] More spawn commands in config (screenshot, volume, etc.) |
| 214 | |
| 215 | ** TODO Layout System [0/4] |
| 216 | - [ ] Add monocle layout |
| 217 | - [ ] Add floating layout mode |
| 218 | - [ ] Handle window resize requests properly |
| 219 | - [ ] Add configurable gaps between windows |
| 220 | |
| 221 | ** TODO Advanced Features [0/3] |
| 222 | - [ ] Multi-monitor support |
| 223 | - [ ] Per-window rules (floating, tag assignment) |
| 224 | - [ ] Master area resizing keybinds |
| 225 | |
| 226 | ** Polish & Features |
| 227 | - [ ] Clean window destruction/cleanup |
| 228 | - [ ] Handle edge cases (empty window list, invalid windows) |
| 229 | - [ ] Better error messages and logging |
| 230 | - [ ] Proper font rendering in bar (currently using basic X11 text) |
| 231 | |
| 232 | * Architecture Notes |
| 233 | ** Tag System |
| 234 | Tags are implemented as bitmasks (TagMask = u32), allowing windows to belong to |
| 235 | multiple tags simultaneously (though current UI only supports single tags). |
| 236 | Each window has an associated TagMask in window_tags HashMap. |
| 237 | |
| 238 | ** Bar Design |
| 239 | The bar uses a performance-optimized approach: |
| 240 | - Only redraws when invalidate() is called |
| 241 | - Pre-calculates tag widths on creation |
| 242 | - Uses X11 graphics context for efficient drawing |
| 243 | - Click handling uses O(n) tag width lookup |
| 244 | |
| 245 | ** Configuration Philosophy |
| 246 | Following dwm's approach: all configuration is in Rust source code. No runtime |
| 247 | config files. Edit config.rs and recompile. This ensures type safety and |
| 248 | compile-time validation of all settings. |
| 249 | |
| 250 | * License |
| 251 | [[https://www.gnu.org/licenses/gpl-3.0.en.html][GPL]] |