Implement compositor core
Summary
Implement the core compositor that manages windows, composites them to the screen, and handles client connections. This is the display server for meniOS.
Background
The compositor is the heart of the GUI stack. It:
- Manages window surfaces from clients
- Composites windows to screen in Z-order
- Routes input events to appropriate windows
- Implements the window protocol
Goals
- Window surface management
- Scene graph and rendering pipeline
- Client connection handling
- Damage tracking and dirty rectangles
- Double buffering and vsync
Implementation
Compositor Structure
```c struct compositor { cairo_surface_t *screen; // Framebuffer struct window *windows; // Window list struct window *focused; // Focused window struct event_queue *events; // Input events int socket_fd; // Unix socket int damage_dirty; // Needs repaint };
struct window { uint32_t id; int x, y, width, height; int mapped, visible; cairo_surface_t *surface; // Shared memory struct window *next, *prev; }; ```
Render Loop
```c while (running) { handle_client_messages(); handle_input_events(); if (damage_dirty) { composite_windows(); flip_buffers(); } vsync_wait(); } ```
Timeline
Total: 3-4 weeks
Definition of Done
- [ ] Compositor runs as userland daemon
- [ ] Can accept client connections
- [ ] Can create and display windows
- [ ] Composites multiple windows
- [ ] Input routing works
- [ ] Smooth 60fps rendering
Dependencies
- #396: Cairo (rendering)
- #397: Pixman (compositing)
- #399: Input events
- #400: Mouse cursor
- #401: Shared memory
- #402: Unix sockets
See docs/road/road_to_gui.md for complete roadmap.