Writing an OS Kernel from Scratch – Part 28: Window Manager — Controlling Windows via Keyboard
“No mouse? No problem! Real geeks control everything with the keyboard. Today, we implement a Window Manager (WM), moving and resizing windows via keyboard shortcuts!”
In previous posts, we built a userspace Display Server, Launcher, and multiple applications, but windows are still static:
- Fixed position
- Fixed size
- No title bar, borders, or decorations
Though we haven’t implemented a mouse driver yet, the keyboard is sufficient to control windows! Unix philosophy tells us: the keyboard is the ultimate interaction device.
Window Manager Architecture (No Mouse Version)
Core idea:
- Display Server: only responsible for compositing and rendering to screen
- Window Manager: as a special Client, manages all window decorations and keyboard interaction
- Normal Client: only draws the content area
Interaction via keyboard shortcuts:
| Action | Shortcut |
|——–|———-|
| Switch focus window | Alt+Tab |
| Move window | Alt+Arrow keys |
| Resize window | Alt+Shift+Arrow keys |
| Close window | Alt+F4 |
| Maximize | Alt+F10 |
i3, xmonad and other tiling window managers are keyboard-centric!
Comments