aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/DEFAULTS.md338
-rw-r--r--docs/GUI_SETTINGS.md382
-rw-r--r--docs/IMPLEMENTATION_STATUS.md336
-rw-r--r--docs/PLATFORM_IMPLEMENTATION.md636
4 files changed, 1692 insertions, 0 deletions
diff --git a/docs/DEFAULTS.md b/docs/DEFAULTS.md
new file mode 100644
index 0000000..dfd030e
--- /dev/null
+++ b/docs/DEFAULTS.md
@@ -0,0 +1,338 @@
+# SRDWM Default Configuration Reference
+
+## Overview
+This document describes all default configuration values and available options for SRDWM. These defaults provide a sensible starting point that works well across all platforms.
+
+## Configuration Structure
+
+### Global Settings (`general.*`)
+```lua
+srd.set("general.default_layout", "dynamic") -- Default: "dynamic"
+srd.set("general.smart_placement", true) -- Default: true
+srd.set("general.window_gap", 8) -- Default: 8
+srd.set("general.border_width", 2) -- Default: 2
+srd.set("general.animations", true) -- Default: true
+srd.set("general.animation_duration", 200) -- Default: 200ms
+srd.set("general.focus_follows_mouse", false) -- Default: false
+srd.set("general.mouse_follows_focus", true) -- Default: true
+srd.set("general.auto_raise", false) -- Default: false
+srd.set("general.auto_focus", true) -- Default: true
+```
+
+### Monitor Settings (`monitor.*`)
+```lua
+srd.set("monitor.primary_layout", "dynamic") -- Default: "dynamic"
+srd.set("monitor.secondary_layout", "tiling") -- Default: "tiling"
+srd.set("monitor.auto_detect", true) -- Default: true
+srd.set("monitor.primary_workspace", 1) -- Default: 1
+srd.set("monitor.workspace_count", 10) -- Default: 10
+```
+
+### Window Behavior (`window.*`)
+```lua
+srd.set("window.focus_follows_mouse", false) -- Default: false
+srd.set("window.mouse_follows_focus", true) -- Default: true
+srd.set("window.auto_raise", false) -- Default: false
+srd.set("window.auto_focus", true) -- Default: true
+srd.set("window.raise_on_focus", true) -- Default: true
+srd.set("window.remember_position", true) -- Default: true
+srd.set("window.remember_size", true) -- Default: true
+srd.set("window.remember_state", true) -- Default: true
+```
+
+### Workspace Settings (`workspace.*`)
+```lua
+srd.set("workspace.count", 10) -- Default: 10
+srd.set("workspace.names", {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"})
+srd.set("workspace.auto_switch", false) -- Default: false
+srd.set("workspace.persistent", true) -- Default: true
+srd.set("workspace.auto_back_and_forth", false) -- Default: false
+```
+
+### Performance Settings (`performance.*`)
+```lua
+srd.set("performance.vsync", true) -- Default: true
+srd.set("performance.max_fps", 60) -- Default: 60
+srd.set("performance.window_cache_size", 100) -- Default: 100
+srd.set("performance.event_queue_size", 1000) -- Default: 1000
+srd.set("performance.layout_timeout", 16) -- Default: 16ms
+srd.set("performance.enable_caching", true) -- Default: true
+```
+
+### Debug Settings (`debug.*`)
+```lua
+srd.set("debug.logging", true) -- Default: true
+srd.set("debug.log_level", "info") -- Default: "info"
+srd.set("debug.profile", false) -- Default: false
+srd.set("debug.trace_events", false) -- Default: false
+srd.set("debug.show_layout_bounds", false) -- Default: false
+srd.set("debug.show_window_geometry", false) -- Default: false
+```
+
+## Layout-Specific Defaults
+
+### Tiling Layout (`layout.tiling.*`)
+```lua
+srd.layout.configure("tiling", {
+ split_ratio = 0.5, -- Default: 0.5
+ master_ratio = 0.6, -- Default: 0.6
+ auto_swap = true, -- Default: true
+ gaps = {
+ inner = 8, -- Default: 8
+ outer = 16 -- Default: 16
+ },
+ behavior = {
+ new_window_master = false, -- Default: false
+ auto_balance = true, -- Default: true
+ preserve_ratio = true -- Default: true
+ }
+})
+```
+
+### Dynamic Layout (`layout.dynamic.*`)
+```lua
+srd.layout.configure("dynamic", {
+ snap_threshold = 50, -- Default: 50
+ grid_size = 6, -- Default: 6
+ cascade_offset = 30, -- Default: 30
+ smart_placement = true, -- Default: true
+ gaps = {
+ inner = 8, -- Default: 8
+ outer = 16 -- Default: 16
+ },
+ behavior = {
+ remember_positions = true, -- Default: true
+ auto_arrange = true, -- Default: true
+ overlap_prevention = true -- Default: true
+ }
+})
+```
+
+### Floating Layout (`layout.floating.*`)
+```lua
+srd.layout.configure("floating", {
+ default_position = "center", -- Default: "center"
+ remember_position = true, -- Default: true
+ always_on_top = false, -- Default: false
+ gaps = {
+ inner = 0, -- Default: 0
+ outer = 16 -- Default: 16
+ },
+ behavior = {
+ allow_resize = true, -- Default: true
+ allow_move = true, -- Default: true
+ snap_to_edges = true -- Default: true
+ }
+})
+```
+
+## Theme Defaults
+
+### Colors (`theme.colors.*`)
+```lua
+srd.theme.set_colors({
+ background = "#2e3440", -- Default: Nord dark
+ foreground = "#eceff4", -- Default: Nord light
+ primary = "#88c0d0", -- Default: Nord blue
+ secondary = "#81a1c1", -- Default: Nord blue-gray
+ accent = "#5e81ac", -- Default: Nord blue
+ error = "#bf616a", -- Default: Nord red
+ warning = "#ebcb8b", -- Default: Nord yellow
+ success = "#a3be8c" -- Default: Nord green
+})
+```
+
+### Window Decorations (`theme.decorations.*`)
+```lua
+srd.theme.set_decorations({
+ border = {
+ width = 2, -- Default: 2
+ active_color = "#88c0d0", -- Default: Nord blue
+ inactive_color = "#2e3440", -- Default: Nord dark
+ focused_style = "solid", -- Default: "solid"
+ unfocused_style = "solid" -- Default: "solid"
+ },
+ title_bar = {
+ height = 24, -- Default: 24
+ show = true, -- Default: true
+ font = "JetBrains Mono 10", -- Default: "JetBrains Mono 10"
+ background = "#2e3440", -- Default: Nord dark
+ foreground = "#eceff4" -- Default: Nord light
+ }
+})
+```
+
+## Key Binding Defaults
+
+### Essential Bindings
+```lua
+-- Layout switching
+srd.bind("Mod4+1", function() srd.layout.set("tiling") end) -- Default: Mod4+1
+srd.bind("Mod4+2", function() srd.layout.set("dynamic") end) -- Default: Mod4+2
+srd.bind("Mod4+3", function() srd.layout.set("floating") end) -- Default: Mod4+3
+
+-- Window management
+srd.bind("Mod4+q", function() srd.window.close() end) -- Default: Mod4+q
+srd.bind("Mod4+m", function() srd.window.minimize() end) -- Default: Mod4+m
+srd.bind("Mod4+f", function() srd.window.maximize() end) -- Default: Mod4+f
+
+-- Window movement (vim-style)
+srd.bind("Mod4+h", function() srd.window.focus("left") end) -- Default: Mod4+h
+srd.bind("Mod4+j", function() srd.window.focus("down") end) -- Default: Mod4+j
+srd.bind("Mod4+k", function() srd.window.focus("up") end) -- Default: Mod4+k
+srd.bind("Mod4+l", function() srd.window.focus("right") end) -- Default: Mod4+l
+
+-- Workspace management
+srd.bind("Mod4+Tab", function() srd.workspace.next() end) -- Default: Mod4+Tab
+srd.bind("Mod4+Shift+Tab", function() srd.workspace.prev() end) -- Default: Mod4+Shift+Tab
+
+-- Quick actions
+srd.bind("Mod4+d", function() srd.spawn("rofi -show drun") end) -- Default: Mod4+d
+srd.bind("Mod4+Return", function() srd.spawn("alacritty") end) -- Default: Mod4+Return
+```
+
+## Platform-Specific Defaults
+
+### Linux (X11/Wayland)
+```lua
+-- Auto-detect backend
+srd.set("platform.backend", "auto") -- Default: "auto"
+
+-- X11 specific
+srd.set("platform.x11.use_ewmh", true) -- Default: true
+srd.set("platform.x11.use_netwm", true) -- Default: true
+
+-- Wayland specific
+srd.set("platform.wayland.use_xdg_shell", true) -- Default: true
+srd.set("platform.wayland.use_layer_shell", true) -- Default: true
+```
+
+### Windows
+```lua
+-- Windows specific
+srd.set("platform.windows.use_dwm", true) -- Default: true
+srd.set("platform.windows.use_win32", true) -- Default: true
+srd.set("platform.windows.global_hooks", true) -- Default: true
+```
+
+### macOS
+```lua
+-- macOS specific
+srd.set("platform.macos.use_cocoa", true) -- Default: true
+srd.set("platform.macos.use_core_graphics", true) -- Default: true
+srd.set("platform.macos.accessibility_enabled", true) -- Default: true
+```
+
+## Configuration File Locations
+
+### Linux
+- **Config**: `~/.config/srdwm/srd/`
+- **Themes**: `~/.config/srdwm/themes/`
+- **Scripts**: `~/.config/srdwm/scripts/`
+- **Cache**: `~/.cache/srdwm/`
+- **Logs**: `~/.local/share/srdwm/logs/`
+
+### Windows
+- **Config**: `%APPDATA%\srdwm\srd\`
+- **Themes**: `%APPDATA%\srdwm\themes\`
+- **Scripts**: `%APPDATA%\srdwm\scripts\`
+- **Cache**: `%LOCALAPPDATA%\srdwm\cache\`
+- **Logs**: `%LOCALAPPDATA%\srdwm\logs\`
+
+### macOS
+- **Config**: `~/Library/Application Support/srdwm/srd/`
+- **Themes**: `~/Library/Application Support/srdwm/themes/`
+- **Scripts**: `~/Library/Application Support/srdwm/scripts/`
+- **Cache**: `~/Library/Caches/srdwm/`
+- **Logs**: `~/Library/Logs/srdwm/`
+
+## Environment Variables
+
+```bash
+# Configuration path override
+export SRDWM_CONFIG_PATH="/path/to/config"
+
+# Theme override
+export SRDWM_THEME="nord"
+
+# Debug level
+export SRDWM_DEBUG_LEVEL="debug"
+
+# Platform override
+export SRDWM_PLATFORM="wayland"
+
+# Performance settings
+export SRDWM_MAX_FPS="120"
+export SRDWM_VSYNC="false"
+```
+
+## Reset to Defaults
+
+To reset any setting to its default value:
+
+```lua
+-- Reset specific setting
+srd.reset("general.window_gap")
+
+-- Reset all settings
+srd.reset_all()
+
+-- Reset specific category
+srd.reset_category("general")
+```
+
+## Validation Rules
+
+### Numeric Values
+- **Gaps**: 0-100 pixels
+- **Border width**: 0-20 pixels
+- **Animation duration**: 0-1000ms
+- **FPS**: 30-240
+- **Cache size**: 10-10000
+
+### String Values
+- **Layout names**: Must be registered layouts
+- **Theme names**: Must be valid theme files
+- **Font names**: Must be system fonts
+- **Color values**: Must be valid hex colors
+
+### Boolean Values
+- **Features**: true/false
+- **Debug options**: true/false
+- **Performance options**: true/false
+
+## Best Practices
+
+1. **Start with defaults**: Don't change settings unless necessary
+2. **Test changes**: Always test configuration changes
+3. **Backup configs**: Keep backups of working configurations
+4. **Use comments**: Document custom configurations
+5. **Validate syntax**: Use `srd.validate_config()` before reloading
+
+## Troubleshooting
+
+### Common Issues
+- **Config not loading**: Check file permissions and syntax
+- **Settings not applying**: Verify setting names and values
+- **Performance issues**: Check performance settings
+- **Layout problems**: Verify layout configuration
+
+### Debug Commands
+```lua
+-- Check configuration status
+srd.debug.config_status()
+
+-- Validate current configuration
+srd.debug.validate_config()
+
+-- Show current settings
+srd.debug.show_settings()
+
+-- Performance profiling
+srd.debug.profile_start()
+srd.debug.profile_stop()
+```
+
+This documentation provides a comprehensive reference for all default values and configuration options in SRDWM.
+
+
diff --git a/docs/GUI_SETTINGS.md b/docs/GUI_SETTINGS.md
new file mode 100644
index 0000000..bc892b5
--- /dev/null
+++ b/docs/GUI_SETTINGS.md
@@ -0,0 +1,382 @@
+# SRDWM GUI Settings Program
+
+## Overview
+The SRDWM GUI Settings program provides a user-friendly interface for configuring the window manager without editing Lua files directly. It integrates seamlessly with existing system settings structures on Windows, macOS, and Linux.
+
+## Architecture
+
+### Cross-Platform GUI Framework
+- **Linux**: GTK4 with native desktop integration
+- **Windows**: WinUI 3 with Windows Settings integration
+- **macOS**: SwiftUI with System Preferences integration
+
+### System Integration
+- **Windows**: Appears in Windows Settings > System > Window Manager
+- **macOS**: Appears in System Preferences > Desktop & Screen Saver > Window Manager
+- **Linux**: Appears in GNOME Settings, KDE System Settings, etc.
+
+## Main Interface
+
+### 1. General Settings Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ General Settings │
+├─────────────────────────────────────────────────────────┤
+│ Default Layout: [Dynamic ▼] │
+│ Smart Window Placement: ☑ │
+│ Window Gap: [8] pixels │
+│ Border Width: [2] pixels │
+│ Enable Animations: ☑ │
+│ Animation Duration: [200] ms │
+│ │
+│ Focus Follows Mouse: ☐ │
+│ Mouse Follows Focus: ☑ │
+│ Auto Raise Windows: ☐ │
+│ Auto Focus Windows: ☑ │
+└─────────────────────────────────────────────────────────┘
+```
+
+### 2. Key Bindings Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ Key Bindings │
+├─────────────────────────────────────────────────────────┤
+│ Layout Switching │
+│ ├─ Tiling Layout: [Mod4+1] [Change] [Remove] │
+│ ├─ Dynamic Layout: [Mod4+2] [Change] [Remove] │
+│ └─ Floating Layout: [Mod4+3] [Change] [Remove] │
+│ │
+│ Window Management │
+│ ├─ Close Window: [Mod4+q] [Change] [Remove] │
+│ ├─ Minimize Window: [Mod4+m] [Change] [Remove] │
+│ └─ Maximize Window: [Mod4+f] [Change] [Remove] │
+│ │
+│ [Add New Binding] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### 3. Layouts Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ Layouts │
+├─────────────────────────────────────────────────────────┤
+│ Tiling Layout │
+│ ├─ Split Ratio: [50]% [Reset] │
+│ ├─ Master Ratio: [60]% [Reset] │
+│ ├─ Auto Swap: ☑ │
+│ └─ Gaps: Inner [8] Outer [16] [Reset] │
+│ │
+│ Dynamic Layout │
+│ ├─ Snap Threshold: [50]px [Reset] │
+│ ├─ Grid Size: [6] [Reset] │
+│ ├─ Cascade Offset: [30]px [Reset] │
+│ └─ Smart Placement: ☑ │
+│ │
+│ [Add Custom Layout] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### 4. Themes Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ Themes │
+├─────────────────────────────────────────────────────────┤
+│ Current Theme: [Nord ▼] [Preview] │
+│ │
+│ Colors │
+│ ├─ Background: [■] #2e3440 [Change] │
+│ ├─ Foreground: [■] #eceff4 [Change] │
+│ ├─ Primary: [■] #88c0d0 [Change] │
+│ └─ Secondary: [■] #81a1c1 [Change] │
+│ │
+│ Window Decorations │
+│ ├─ Border Width: [2]px [Reset] │
+│ ├─ Title Bar Height: [24]px [Reset] │
+│ └─ Font: [JetBrains Mono 10] [Change] │
+│ │
+│ [Import Theme] [Export Theme] [Create New] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### 5. Window Rules Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ Window Rules │
+├─────────────────────────────────────────────────────────┤
+│ Rule 1: Firefox → Dynamic Layout │
+│ ├─ Match: Class = "firefox" │
+│ ├─ Action: Layout = "dynamic" │
+│ └─ [Edit] [Delete] │
+│ │
+│ Rule 2: Terminal → Tiling Layout │
+│ ├─ Match: Class = "terminal" │
+│ ├─ Action: Layout = "tiling" │
+│ └─ [Edit] [Delete] │
+│ │
+│ [Add New Rule] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### 6. Performance Tab
+```
+┌─────────────────────────────────────────────────────────┐
+│ Performance │
+├─────────────────────────────────────────────────────────┤
+│ Graphics │
+│ ├─ Enable V-Sync: ☑ │
+│ ├─ Max FPS: [60] [Reset] │
+│ └─ Enable Caching: ☑ │
+│ │
+│ Memory │
+│ ├─ Window Cache Size: [100] [Reset] │
+│ ├─ Event Queue Size: [1000] [Reset] │
+│ └─ Layout Timeout: [16]ms [Reset] │
+│ │
+│ [Optimize for Performance] [Reset to Defaults] │
+└─────────────────────────────────────────────────────────┘
+```
+
+## Key Binding Editor
+
+### Add/Edit Key Binding Dialog
+```
+┌─────────────────────────────────────────────────────────┐
+│ Edit Key Binding │
+├─────────────────────────────────────────────────────────┤
+│ Key Combination: [Press keys here...] │
+│ Current: Mod4+Shift+1 │
+│ │
+│ Action Type: [Window Management ▼] │
+│ Action: [Close Window ▼] │
+│ │
+│ Custom Command: [________________] │
+│ │
+│ [Test Binding] [OK] [Cancel] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### Key Combination Parser
+- **Mod4**: Super/Windows key
+- **Mod1**: Alt key
+- **Mod2**: Num Lock
+- **Mod3**: Scroll Lock
+- **Shift**: Shift key
+- **Ctrl**: Control key
+
+## Theme Editor
+
+### Color Picker Integration
+```
+┌─────────────────────────────────────────────────────────┐
+│ Color Picker │
+├─────────────────────────────────────────────────────────┤
+│ Color: [■] #88c0d0 │
+│ │
+│ RGB: R [136] G [192] B [208] │
+│ HSV: H [199] S [35] V [82] │
+│ │
+│ Preset Colors: │
+│ [■][■][■][■][■][■][■][■] │
+│ │
+│ [Pick from Screen] [OK] [Cancel] │
+└─────────────────────────────────────────────────────────┘
+```
+
+### Font Selector
+```
+┌─────────────────────────────────────────────────────────┐
+│ Font Selection │
+├─────────────────────────────────────────────────────────┤
+│ Font Family: [JetBrains Mono ▼] │
+│ Font Size: [10] [Reset] │
+│ Font Weight: [Normal ▼] │
+│ Font Style: [Normal ▼] │
+│ │
+│ Preview: The quick brown fox jumps over the lazy dog │
+│ │
+│ [OK] [Cancel] │
+└─────────────────────────────────────────────────────────┘
+```
+
+## System Integration
+
+### Windows Integration
+```cpp
+// Windows Settings integration
+class WindowsSettingsIntegration {
+public:
+ void register_with_settings();
+ void create_settings_page();
+ void handle_settings_changes();
+
+private:
+ void add_to_windows_settings();
+ void create_registry_entries();
+ void register_protocol_handler();
+};
+```
+
+### macOS Integration
+```swift
+// macOS System Preferences integration
+class MacOSSettingsIntegration: NSObject {
+ func registerWithSystemPreferences()
+ func createPreferencesPane()
+ func handlePreferencesChanges()
+
+ private func addToSystemPreferences()
+ func createPreferencePaneBundle()
+ func registerURLScheme()
+}
+```
+
+### Linux Integration
+```cpp
+// Linux desktop integration
+class LinuxDesktopIntegration {
+public:
+ void register_with_desktop();
+ void create_settings_app();
+ void handle_settings_changes();
+
+private:
+ void add_to_gnome_settings();
+ void add_to_kde_settings();
+ void create_desktop_file();
+ void register_mime_types();
+};
+```
+
+## Configuration Management
+
+### Auto-Save and Validation
+```cpp
+class ConfigurationManager {
+public:
+ void auto_save_changes();
+ bool validate_configuration();
+ void backup_configuration();
+ void restore_configuration();
+
+private:
+ void save_to_lua_files();
+ void validate_lua_syntax();
+ void create_backup();
+ void notify_user_of_changes();
+};
+```
+
+### Import/Export
+```cpp
+class ConfigurationIO {
+public:
+ bool import_configuration(const std::string& path);
+ bool export_configuration(const std::string& path);
+ bool import_from_other_wm(const std::string& wm_name);
+
+private:
+ void parse_import_format();
+ void convert_to_srdwm_format();
+ void validate_imported_config();
+};
+```
+
+## Advanced Features
+
+### Live Preview
+- **Real-time updates**: Changes apply immediately
+- **Window preview**: See how windows will look
+- **Layout preview**: Visualize layout changes
+- **Theme preview**: Live theme switching
+
+### Configuration Sync
+- **Cloud sync**: Sync settings across devices
+- **Version control**: Track configuration changes
+- **Backup/restore**: Automatic configuration backups
+- **Migration tools**: Import from other window managers
+
+### Accessibility
+- **High contrast**: High contrast mode support
+- **Screen reader**: Full screen reader compatibility
+- **Keyboard navigation**: Complete keyboard navigation
+- **Large text**: Scalable interface elements
+
+## Installation and Distribution
+
+### Package Integration
+```bash
+# Linux (Debian/Ubuntu)
+sudo apt install srdwm-settings
+
+# Linux (Arch)
+sudo pacman -S srdwm-settings
+
+# Windows (Chocolatey)
+choco install srdwm-settings
+
+# macOS (Homebrew)
+brew install srdwm-settings
+```
+
+### System Integration
+```bash
+# Linux desktop files
+~/.local/share/applications/srdwm-settings.desktop
+
+# Windows registry
+HKEY_CURRENT_USER\Software\SRDWM\Settings
+
+# macOS preferences
+~/Library/Preferences/com.srdwm.settings.plist
+```
+
+## Development
+
+### Building the GUI
+```bash
+# Linux (GTK4)
+meson build -Dgui=true
+ninja -C build
+
+# Windows (WinUI 3)
+dotnet build src/gui/SRDWM.Settings.Windows
+
+# macOS (SwiftUI)
+xcodebuild -project src/gui/SRDWM.Settings.macOS.xcodeproj
+```
+
+### Testing
+```bash
+# Unit tests
+ninja -C build test
+
+# Integration tests
+ninja -C build integration-test
+
+# GUI tests
+ninja -C build gui-test
+```
+
+## User Experience
+
+### First Run Experience
+1. **Welcome dialog**: Introduction to SRDWM
+2. **Quick setup**: Essential settings configuration
+3. **Tutorial**: Interactive configuration guide
+4. **Import options**: Import from existing setups
+
+### Contextual Help
+- **Tooltips**: Hover for help text
+- **Help button**: Context-sensitive help
+- **Documentation**: Integrated user manual
+- **Examples**: Sample configurations
+
+### Error Handling
+- **Validation**: Real-time configuration validation
+- **Error messages**: Clear, actionable error messages
+- **Recovery**: Automatic error recovery
+- **Logging**: Detailed error logging
+
+This GUI settings program provides a professional, user-friendly interface that integrates seamlessly with existing system structures while maintaining the power and flexibility of the Lua configuration system.
+
+
diff --git a/docs/IMPLEMENTATION_STATUS.md b/docs/IMPLEMENTATION_STATUS.md
new file mode 100644
index 0000000..23d4e9d
--- /dev/null
+++ b/docs/IMPLEMENTATION_STATUS.md
@@ -0,0 +1,336 @@
+# SRDWM Implementation Status
+
+## Overview
+This document provides a comprehensive overview of the current implementation status of SRDWM, including completed features, in-progress work, and next steps.
+
+## ✅ **Completed Features**
+
+### 1. **Lua Configuration System**
+- **Status**: ✅ **FULLY IMPLEMENTED**
+- **Files**:
+ - `src/config/lua_manager.h/cc` - Complete Lua integration
+ - `config/srd/*.lua` - Example configuration files
+ - `docs/DEFAULTS.md` - Complete default configuration reference
+- **Features**:
+ - Full Lua 5.4+ integration with C++
+ - Complete `srd` module API
+ - Configuration loading from `srd/*.lua` files
+ - Key binding system
+ - Layout configuration
+ - Theme management
+ - Window rules
+ - Configuration validation and reset
+ - Error handling and logging
+
+### 2. **Platform Architecture Design**
+- **Status**: ✅ **FULLY DESIGNED**
+- **Files**:
+ - `docs/PLATFORM_IMPLEMENTATION.md` - Complete platform guide
+ - `src/platform/platform.h` - Platform abstraction interface
+ - `src/platform/platform_factory.h/cc` - Platform factory implementation
+- **Features**:
+ - Proper separation of X11 vs Wayland (no mixing!)
+ - Platform detection and selection
+ - Cross-platform abstraction layer
+ - Automatic platform detection
+
+### 3. **Build System**
+- **Status**: ✅ **FULLY IMPLEMENTED**
+- **Files**:
+ - `CMakeLists.txt` - Complete build configuration
+- **Features**:
+ - Platform-specific dependency management
+ - Lua integration
+ - Conditional compilation for different platforms
+ - Proper include and library paths
+
+### 4. **Documentation**
+- **Status**: ✅ **COMPREHENSIVE**
+- **Files**:
+ - `docs/DEFAULTS.md` - Complete configuration reference
+ - `docs/GUI_SETTINGS.md` - GUI settings program design
+ - `docs/PLATFORM_IMPLEMENTATION.md` - Platform implementation guide
+ - `docs/IMPLEMENTATION_STATUS.md` - This status document
+
+## 🔄 **In Progress**
+
+### 1. **Platform-Specific Implementations**
+- **Status**: 🔄 **HEADERS CREATED, IMPLEMENTATION IN PROGRESS**
+- **Files**:
+ - `src/platform/x11_platform.h` - X11 platform header ✅
+ - `src/platform/wayland_platform.h` - Wayland platform header ✅
+ - `src/platform/windows_platform.h` - Windows platform header ✅
+ - `src/platform/macos_platform.h` - macOS platform header ✅
+- **Progress**: Headers and interfaces defined, implementation needed
+
+### 2. **Core Window Management**
+- **Status**: 🔄 **INTERFACES DEFINED, IMPLEMENTATION NEEDED**
+- **Files**:
+ - `src/core/window.h/cc` - Window class interface ✅
+ - `src/core/window_manager.h/cc` - Window manager interface ✅
+ - `src/layouts/layout_engine.h/cc` - Layout engine interface ✅
+- **Progress**: Basic structure defined, platform integration needed
+
+## ❌ **Not Yet Started**
+
+### 1. **Platform Implementation Files**
+- `src/platform/x11_platform.cc` - X11 implementation
+- `src/platform/wayland_platform.cc` - Wayland implementation
+- `src/platform/windows_platform.cc` - Windows implementation
+- `src/platform/macos_platform.cc` - macOS implementation
+
+### 2. **Smart Placement Algorithms**
+- `src/layouts/smart_placement.cc` - Smart window placement implementation
+
+### 3. **GUI Settings Program**
+- Cross-platform settings interface
+- System integration (Windows Settings, macOS Preferences, Linux Settings)
+
+### 4. **Advanced Features**
+- Window rules engine
+- Advanced theming system
+- Performance optimization
+- Accessibility features
+
+## 🚀 **Next Implementation Steps**
+
+### **Phase 1: Platform Implementation (Priority: HIGH)**
+
+#### **1.1 X11 Platform Implementation**
+```bash
+# Create X11 implementation
+touch src/platform/x11_platform.cc
+# Implement X11 event handling, window management, input handling
+```
+
+**Key Requirements**:
+- X11 event loop and event conversion
+- Window management (create, destroy, move, resize)
+- Input handling (keyboard, mouse)
+- Monitor detection and management
+- EWMH/NETWM compliance
+
+#### **1.2 Wayland Platform Implementation**
+```bash
+# Create Wayland implementation
+touch src/platform/wayland_platform.cc
+# Implement Wayland compositor using wlroots
+```
+
+**Key Requirements**:
+- wlroots backend setup
+- Wayland protocol handling (XDG Shell, Layer Shell)
+- XWayland support
+- Surface management
+- Input device handling
+
+#### **1.3 Windows Platform Implementation**
+```bash
+# Create Windows implementation
+touch src/platform/windows_platform.cc
+# Implement Win32 API integration
+```
+
+**Key Requirements**:
+- Win32 window management
+- Global hooks for input
+- DWM integration
+- Window subclassing
+
+#### **1.4 macOS Platform Implementation**
+```bash
+# Create macOS implementation
+touch src/platform/macos_platform.cc
+# Implement Core Graphics/AppKit integration
+```
+
+**Key Requirements**:
+- Core Graphics window management
+- Accessibility APIs
+- Event taps
+- AppKit integration
+
+### **Phase 2: Core Window Management (Priority: HIGH)**
+
+#### **2.1 Window Class Implementation**
+```cpp
+// Implement platform-specific window operations
+class Window {
+ // Platform-specific window handles
+ #ifdef LINUX_PLATFORM
+ Window x11_handle_;
+ struct wlr_surface* wayland_surface_;
+ #elif defined(WIN32_PLATFORM)
+ HWND win32_handle_;
+ #elif defined(MACOS_PLATFORM)
+ CGWindowID macos_window_id_;
+ #endif
+};
+```
+
+#### **2.2 Window Manager Implementation**
+```cpp
+// Implement core window management logic
+class WindowManager {
+ // Platform integration
+ std::unique_ptr<Platform> platform_;
+
+ // Window management
+ void handle_window_created(Window* window);
+ void handle_window_destroyed(Window* window);
+ void handle_window_focused(Window* window);
+};
+```
+
+### **Phase 3: Layout System (Priority: MEDIUM)**
+
+#### **3.1 Smart Placement Implementation**
+```cpp
+// Implement Windows 11-style smart placement
+class SmartPlacement {
+ PlacementResult place_window(const Window* window, const Monitor& monitor);
+ PlacementResult place_in_grid(const Window* window, const Monitor& monitor);
+ PlacementResult snap_to_edge(const Window* window, const Monitor& monitor);
+};
+```
+
+#### **3.2 Layout Engine Implementation**
+```cpp
+// Implement layout management
+class LayoutEngine {
+ void arrange_windows_on_monitor(const Monitor& monitor);
+ void switch_layout(const std::string& layout_name);
+ void configure_layout(const std::string& layout_name, const LayoutConfig& config);
+};
+```
+
+### **Phase 4: Advanced Features (Priority: LOW)**
+
+#### **4.1 Window Rules Engine**
+```cpp
+// Implement automatic window management
+class WindowRulesEngine {
+ void apply_rules_to_window(Window* window);
+ bool matches_rule(const Window* window, const WindowRule& rule);
+ void execute_rule_action(const Window* window, const WindowRule& rule);
+};
+```
+
+#### **4.2 GUI Settings Program**
+```cpp
+// Cross-platform settings interface
+class SettingsProgram {
+ #ifdef LINUX_PLATFORM
+ void create_gtk_interface();
+ #elif defined(WIN32_PLATFORM)
+ void create_winui_interface();
+ #elif defined(MACOS_PLATFORM)
+ void create_swiftui_interface();
+ #endif
+};
+```
+
+## 🧪 **Testing Strategy**
+
+### **Unit Testing**
+```bash
+# Test each platform independently
+mkdir tests/
+touch tests/test_x11_platform.cc
+touch tests/test_wayland_platform.cc
+touch tests/test_windows_platform.cc
+touch tests/test_macos_platform.cc
+```
+
+### **Integration Testing**
+```bash
+# Test platform integration
+touch tests/test_platform_factory.cc
+touch tests/test_lua_integration.cc
+```
+
+### **Platform-Specific Testing**
+```bash
+# Test on actual platforms
+# Linux: X11 and Wayland environments
+# Windows: Windows 10/11
+# macOS: macOS 12+
+```
+
+## 📊 **Current Progress Metrics**
+
+| Component | Status | Progress | Priority |
+|-----------|--------|----------|----------|
+| Lua Configuration | ✅ Complete | 100% | HIGH |
+| Platform Architecture | ✅ Complete | 100% | HIGH |
+| Build System | ✅ Complete | 100% | HIGH |
+| Documentation | ✅ Complete | 100% | HIGH |
+| Platform Headers | 🔄 In Progress | 80% | HIGH |
+| Platform Implementation | ❌ Not Started | 0% | HIGH |
+| Core Window Management | 🔄 In Progress | 40% | HIGH |
+| Layout System | ❌ Not Started | 0% | MEDIUM |
+| Smart Placement | ❌ Not Started | 0% | MEDIUM |
+| GUI Settings | ❌ Not Started | 0% | LOW |
+
+**Overall Progress: 35%**
+
+## 🎯 **Immediate Next Steps**
+
+### **Week 1-2: Platform Implementation**
+1. **Implement X11 platform** (`src/platform/x11_platform.cc`)
+2. **Implement Wayland platform** (`src/platform/wayland_platform.cc`)
+3. **Test platform detection and initialization**
+
+### **Week 3-4: Core Integration**
+1. **Integrate platforms with window manager**
+2. **Implement basic window operations**
+3. **Test window creation and management**
+
+### **Week 5-6: Layout System**
+1. **Implement smart placement algorithms**
+2. **Create layout engine**
+3. **Test layout switching and configuration**
+
+## 🚨 **Critical Notes**
+
+### **1. Wayland vs X11 Separation**
+- **NEVER mix X11 and Wayland APIs**
+- Use wlroots for Wayland implementation
+- Handle XWayland as special case within Wayland
+- Maintain strict separation in platform implementations
+
+### **2. Platform Abstraction**
+- Keep platform-specific code isolated
+- Use common interfaces for cross-platform functionality
+- Implement platform detection automatically
+- Respect each platform's event model
+
+### **3. Testing Requirements**
+- Test each platform independently
+- Validate platform-specific features
+- Use CI/CD with multiple platform targets
+- Test on actual hardware when possible
+
+## 🔮 **Future Enhancements**
+
+### **Phase 5: Performance Optimization**
+- GPU acceleration
+- Efficient rendering
+- Memory management
+- Event batching
+
+### **Phase 6: Advanced Features**
+- Plugin system
+- Scripting engine
+- Network transparency
+- Virtual desktop support
+
+### **Phase 7: Ecosystem Integration**
+- Package managers
+- Theme repositories
+- Configuration sharing
+- Community tools
+
+This implementation approach ensures that SRDWM works correctly on each platform while respecting the fundamental differences between X11, Wayland, Windows, and macOS. The current focus should be on completing the platform implementations to establish a solid foundation for the window management system.
+
+
diff --git a/docs/PLATFORM_IMPLEMENTATION.md b/docs/PLATFORM_IMPLEMENTATION.md
new file mode 100644
index 0000000..4e70767
--- /dev/null
+++ b/docs/PLATFORM_IMPLEMENTATION.md
@@ -0,0 +1,636 @@
+# SRDWM Platform Implementation Guide
+
+## Overview
+This document outlines the proper implementation approach for each platform, recognizing that **Wayland/XWayland is fundamentally different from X11** and requires completely different technologies and approaches.
+
+## Platform Architecture Differences
+
+### Linux: X11 vs Wayland
+- **X11**: Traditional X11 window management with Xlib/XCB
+- **Wayland**: Modern display protocol requiring wlroots or similar compositor framework
+- **XWayland**: X11 applications running on Wayland (requires special handling)
+
+### Windows vs macOS vs Linux
+- **Windows**: Win32 API with global hooks and window subclassing
+- **macOS**: Core Graphics/AppKit with accessibility APIs and event taps
+- **Linux**: X11 or Wayland with different event systems
+
+## Linux Implementation
+
+### X11 Backend
+```cpp
+// X11-specific implementation using Xlib/XCB
+class X11Platform : public Platform {
+private:
+ Display* display_;
+ Window root_;
+ std::map<Window, Window*> window_map_;
+
+public:
+ bool initialize() override {
+ display_ = XOpenDisplay(nullptr);
+ if (!display_) return false;
+
+ root_ = DefaultRootWindow(display_);
+ setup_event_handling();
+ return true;
+ }
+
+ void setup_event_handling() {
+ // X11 event masks and handlers
+ XSelectInput(display_, root_,
+ SubstructureRedirectMask | SubstructureNotifyMask |
+ KeyPressMask | KeyReleaseMask |
+ ButtonPressMask | ButtonReleaseMask |
+ PointerMotionMask);
+ }
+
+ bool poll_events(std::vector<Event>& events) override {
+ XEvent xevent;
+ while (XPending(display_)) {
+ XNextEvent(display_, &xevent);
+ convert_x11_event(xevent, events);
+ }
+ return true;
+ }
+
+ void convert_x11_event(const XEvent& xevent, std::vector<Event>& events) {
+ switch (xevent.type) {
+ case MapRequest:
+ handle_map_request(xevent.xmaprequest);
+ break;
+ case ConfigureRequest:
+ handle_configure_request(xevent.xconfigurerequest);
+ break;
+ case KeyPress:
+ handle_key_press(xevent.xkey);
+ break;
+ // ... other event types
+ }
+ }
+};
+```
+
+### Wayland Backend (using wlroots)
+```cpp
+// Wayland implementation using wlroots
+class WaylandPlatform : public Platform {
+private:
+ struct wl_display* display_;
+ struct wlroots_backend* backend_;
+ struct wlroots_compositor* compositor_;
+ struct wlroots_output* output_;
+ struct wlroots_input_device* input_device_;
+
+public:
+ bool initialize() override {
+ // Initialize wlroots backend
+ backend_ = wlroots_backend_create();
+ if (!backend_) return false;
+
+ // Create compositor
+ compositor_ = wlroots_compositor_create(backend_);
+ if (!compositor_) return false;
+
+ // Setup output and input
+ setup_output();
+ setup_input();
+
+ return true;
+ }
+
+ void setup_output() {
+ // Create and configure output
+ output_ = wlroots_output_create(compositor_);
+ wlroots_output_set_mode(output_, 1920, 1080, 60);
+ wlroots_output_commit(output_);
+ }
+
+ void setup_input() {
+ // Setup input devices
+ input_device_ = wlroots_input_device_create(compositor_);
+ wlroots_input_device_set_capabilities(input_device_,
+ WLROOTS_INPUT_DEVICE_CAP_KEYBOARD |
+ WLROOTS_INPUT_DEVICE_CAP_POINTER);
+ }
+
+ bool poll_events(std::vector<Event>& events) override {
+ // wlroots event loop
+ wlroots_backend_dispatch(backend_);
+
+ // Process wlroots events
+ struct wlroots_event* event;
+ while ((event = wlroots_backend_get_event(backend_))) {
+ convert_wlroots_event(event, events);
+ wlroots_event_destroy(event);
+ }
+
+ return true;
+ }
+
+ void convert_wlroots_event(struct wlroots_event* event, std::vector<Event>& events) {
+ switch (wlroots_event_get_type(event)) {
+ case WLROOTS_EVENT_NEW_SURFACE:
+ handle_new_surface(event);
+ break;
+ case WLROOTS_EVENT_SURFACE_COMMIT:
+ handle_surface_commit(event);
+ break;
+ case WLROOTS_EVENT_KEYBOARD_KEY:
+ handle_keyboard_key(event);
+ break;
+ // ... other event types
+ }
+ }
+};
+```
+
+### XWayland Support
+```cpp
+// XWayland support for running X11 apps on Wayland
+class XWaylandManager {
+private:
+ struct wlroots_xwayland* xwayland_;
+ struct wlroots_xwayland_server* xwayland_server_;
+
+public:
+ bool initialize(struct wlroots_compositor* compositor) {
+ // Create XWayland server
+ xwayland_server_ = wlroots_xwayland_server_create(compositor);
+ if (!xwayland_server_) return false;
+
+ // Setup XWayland
+ xwayland_ = wlroots_xwayland_create(xwayland_server_);
+ if (!xwayland_) return false;
+
+ return true;
+ }
+
+ void handle_xwayland_surface(struct wlroots_surface* surface) {
+ // Handle X11 windows running on Wayland
+ // These need special treatment for proper integration
+ }
+};
+```
+
+## Windows Implementation
+
+### Win32 API Integration
+```cpp
+// Windows implementation using Win32 API
+class WindowsPlatform : public Platform {
+private:
+ HINSTANCE h_instance_;
+ std::map<HWND, Window*> window_map_;
+ HHOOK keyboard_hook_;
+ HHOOK mouse_hook_;
+
+public:
+ bool initialize() override {
+ h_instance_ = GetModuleHandle(nullptr);
+
+ // Register window class
+ if (!register_window_class()) return false;
+
+ // Setup global hooks
+ setup_global_hooks();
+
+ return true;
+ }
+
+ bool register_window_class() {
+ WNDCLASSEX wc = {};
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.lpfnWndProc = window_proc;
+ wc.hInstance = h_instance_;
+ wc.lpszClassName = L"SRDWM_Window";
+ wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
+
+ return RegisterClassEx(&wc) != 0;
+ }
+
+ void setup_global_hooks() {
+ // Global keyboard hook
+ keyboard_hook_ = SetWindowsHookEx(WH_KEYBOARD_LL,
+ keyboard_proc, h_instance_, 0);
+
+ // Global mouse hook
+ mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL,
+ mouse_proc, h_instance_, 0);
+ }
+
+ static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg,
+ WPARAM wparam, LPARAM lparam) {
+ switch (msg) {
+ case WM_CREATE:
+ // Handle window creation
+ break;
+ case WM_DESTROY:
+ // Handle window destruction
+ break;
+ case WM_SIZE:
+ // Handle window resizing
+ break;
+ // ... other messages
+ }
+ return DefWindowProc(hwnd, msg, wparam, lparam);
+ }
+
+ static LRESULT CALLBACK keyboard_proc(int nCode, WPARAM wparam, LPARAM lparam) {
+ if (nCode >= 0) {
+ KBDLLHOOKSTRUCT* kbhs = (KBDLLHOOKSTRUCT*)lparam;
+ // Handle global keyboard events
+ handle_global_keyboard(wparam, kbhs);
+ }
+ return CallNextHookEx(nullptr, nCode, wparam, lparam);
+ }
+
+ static LRESULT CALLBACK mouse_proc(int nCode, WPARAM wparam, LPARAM lparam) {
+ if (nCode >= 0) {
+ MSLLHOOKSTRUCT* mhs = (MSLLHOOKSTRUCT*)lparam;
+ // Handle global mouse events
+ handle_global_mouse(wparam, mhs);
+ }
+ return CallNextHookEx(nullptr, nCode, wparam, lparam);
+ }
+};
+```
+
+## macOS Implementation
+
+### Core Graphics/AppKit Integration
+```cpp
+// macOS implementation using Core Graphics and AppKit
+class MacOSPlatform : public Platform {
+private:
+ CGEventTap event_tap_;
+ std::map<CGWindowID, Window*> window_map_;
+
+public:
+ bool initialize() override {
+ // Request accessibility permissions
+ if (!request_accessibility_permissions()) return false;
+
+ // Setup event tap
+ setup_event_tap();
+
+ // Setup window monitoring
+ setup_window_monitoring();
+
+ return true;
+ }
+
+ bool request_accessibility_permissions() {
+ // Check if accessibility is enabled
+ const void* keys[] = { kAXTrustedCheckOptionPrompt };
+ const void* values[] = { kCFBooleanTrue };
+
+ CFDictionaryRef options = CFDictionaryCreate(
+ kCFAllocatorDefault, keys, values, 1, nullptr, nullptr);
+
+ bool trusted = AXIsProcessTrustedWithOptions(options);
+ CFRelease(options);
+
+ return trusted;
+ }
+
+ void setup_event_tap() {
+ // Create event tap for global events
+ event_tap_ = CGEventTapCreate(
+ kCGSessionEventTap,
+ kCGHeadInsertEventTap,
+ kCGEventTapOptionDefault,
+ CGEventMaskBit(kCGEventKeyDown) |
+ CGEventMaskBit(kCGEventKeyUp) |
+ CGEventMaskBit(kCGEventLeftMouseDown) |
+ CGEventMaskBit(kCGEventLeftMouseUp) |
+ CGEventMaskBit(kCGEventMouseMoved),
+ event_tap_callback,
+ this);
+
+ if (event_tap_) {
+ CFRunLoopSourceRef run_loop_source =
+ CFMachPortCreateRunLoopSource(kCFAllocatorDefault, event_tap_, 0);
+ CFRunLoopAddSource(CFRunLoopGetCurrent(), run_loop_source, kCFRunLoopCommonModes);
+ CGEventTapEnable(event_tap_, true);
+ }
+ }
+
+ static CGEventRef event_tap_callback(CGEventTapProxy proxy, CGEventType type,
+ CGEventRef event, void* user_info) {
+ MacOSPlatform* platform = static_cast<MacOSPlatform*>(user_info);
+ return platform->handle_event_tap(proxy, type, event);
+ }
+
+ CGEventRef handle_event_tap(CGEventTapProxy proxy, CGEventType type, CGEventRef event) {
+ switch (type) {
+ case kCGEventKeyDown:
+ handle_key_event(event, true);
+ break;
+ case kCGEventKeyUp:
+ handle_key_event(event, false);
+ break;
+ case kCGEventLeftMouseDown:
+ handle_mouse_event(event, true);
+ break;
+ case kCGEventLeftMouseUp:
+ handle_mouse_event(event, false);
+ break;
+ case kCGEventMouseMoved:
+ handle_mouse_motion(event);
+ break;
+ }
+ return event;
+ }
+
+ void setup_window_monitoring() {
+ // Monitor window creation/destruction
+ CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly |
+ kCGWindowListExcludeDesktopElements,
+ kCGNullWindowID);
+ }
+};
+```
+
+## Platform Detection and Selection
+
+### Automatic Platform Detection
+```cpp
+// Platform factory with automatic detection
+class PlatformFactory {
+public:
+ static std::unique_ptr<Platform> create_platform() {
+ #ifdef _WIN32
+ return std::make_unique<WindowsPlatform>();
+ #elif defined(__APPLE__)
+ return std::make_unique<MacOSPlatform>();
+ #else
+ // Linux: detect X11 vs Wayland
+ return detect_linux_platform();
+ #endif
+ }
+
+private:
+ static std::unique_ptr<Platform> detect_linux_platform() {
+ // Check environment variables
+ const char* wayland_display = std::getenv("WAYLAND_DISPLAY");
+ const char* xdg_session_type = std::getenv("XDG_SESSION_TYPE");
+
+ if (wayland_display || (xdg_session_type && strcmp(xdg_session_type, "wayland") == 0)) {
+ // Try Wayland first
+ auto wayland_platform = std::make_unique<WaylandPlatform>();
+ if (wayland_platform->initialize()) {
+ std::cout << "Using Wayland backend" << std::endl;
+ return wayland_platform;
+ }
+ std::cout << "Wayland initialization failed, falling back to X11" << std::endl;
+ }
+
+ // Fall back to X11
+ auto x11_platform = std::make_unique<X11Platform>();
+ if (x11_platform->initialize()) {
+ std::cout << "Using X11 backend" << std::endl;
+ return x11_platform;
+ }
+
+ std::cerr << "Failed to initialize any platform backend" << std::endl;
+ return nullptr;
+ }
+};
+```
+
+## Dependencies and Build System
+
+### CMake Configuration
+```cmake
+# Platform-specific dependencies
+if(WIN32)
+ # Windows dependencies
+ find_package(PkgConfig REQUIRED)
+ set(PLATFORM_LIBS user32 gdi32)
+
+elseif(APPLE)
+ # macOS dependencies
+ find_library(COCOA_LIBRARY Cocoa)
+ find_library(CARBON_LIBRARY Carbon)
+ find_library(IOKIT_LIBRARY IOKit)
+ set(PLATFORM_LIBS ${COCOA_LIBRARY} ${CARBON_LIBRARY} ${IOKIT_LIBRARY})
+
+else()
+ # Linux dependencies
+ find_package(PkgConfig REQUIRED)
+
+ # X11 dependencies
+ pkg_check_modules(X11 REQUIRED x11 xcb xcb-keysyms)
+
+ # Wayland dependencies (optional)
+ pkg_check_modules(WAYLAND wayland-client wayland-cursor)
+ pkg_check_modules(WLROOTS wlroots)
+
+ if(WAYLAND_FOUND AND WLROOTS_FOUND)
+ add_definitions(-DWAYLAND_ENABLED)
+ set(PLATFORM_LIBS ${PLATFORM_LIBS} ${WAYLAND_LIBRARIES} ${WLROOTS_LIBRARIES})
+ endif()
+
+ set(PLATFORM_LIBS ${PLATFORM_LIBS} ${X11_LIBRARIES})
+endif()
+```
+
+### Package Dependencies
+```bash
+# Ubuntu/Debian
+sudo apt install libx11-dev libxcb1-dev libxcb-keysyms1-dev
+sudo apt install libwayland-dev libwlroots-dev
+
+# Arch Linux
+sudo pacman -S xorg-server-devel wayland wlroots
+
+# Fedora
+sudo dnf install libX11-devel libxcb-devel wayland-devel wlroots-devel
+```
+
+## Event Handling Differences
+
+### X11 Event System
+```cpp
+// X11 events are synchronous and direct
+void X11Platform::handle_map_request(const XMapRequestEvent& event) {
+ Window* window = create_window(event.window);
+ if (window) {
+ window_map_[event.window] = window;
+ // X11 window is now managed
+ }
+}
+```
+
+### Wayland Event System
+```cpp
+// Wayland events are asynchronous and callback-based
+void WaylandPlatform::handle_new_surface(struct wlroots_event* event) {
+ struct wlroots_surface* surface = wlroots_event_get_surface(event);
+
+ // Create window for new surface
+ Window* window = create_window_from_surface(surface);
+ if (window) {
+ surface_window_map_[surface] = window;
+ }
+}
+```
+
+### Windows Event System
+```cpp
+// Windows uses message-based event system
+LRESULT WindowsPlatform::window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
+ switch (msg) {
+ case WM_CREATE:
+ // Window creation
+ break;
+ case WM_DESTROY:
+ // Window destruction
+ break;
+ }
+ return DefWindowProc(hwnd, msg, wparam, lparam);
+}
+```
+
+### macOS Event System
+```cpp
+// macOS uses event taps and accessibility APIs
+CGEventRef MacOSPlatform::handle_event_tap(CGEventTapProxy proxy, CGEventType type, CGEventRef event) {
+ switch (type) {
+ case kCGEventKeyDown:
+ // Handle key press
+ break;
+ case kCGEventMouseMoved:
+ // Handle mouse movement
+ break;
+ }
+ return event;
+}
+```
+
+## Window Management Differences
+
+### X11 Window Management
+```cpp
+// X11: Direct window manipulation
+void X11Platform::set_window_position(Window* window, int x, int y) {
+ XMoveWindow(display_, window->get_x11_handle(), x, y);
+}
+
+void X11Platform::set_window_size(Window* window, int width, int height) {
+ XResizeWindow(display_, window->get_x11_handle(), width, height);
+}
+```
+
+### Wayland Window Management
+```cpp
+// Wayland: Surface-based management
+void WaylandPlatform::set_window_position(Window* window, int x, int y) {
+ struct wlroots_surface* surface = window->get_wayland_surface();
+ wlroots_surface_set_position(surface, x, y);
+}
+
+void WaylandPlatform::set_window_size(Window* window, int width, int height) {
+ struct wlroots_surface* surface = window->get_wayland_surface();
+ wlroots_surface_set_size(surface, width, height);
+}
+```
+
+### Windows Window Management
+```cpp
+// Windows: Win32 API calls
+void WindowsPlatform::set_window_position(Window* window, int x, int y) {
+ HWND hwnd = window->get_win32_handle();
+ SetWindowPos(hwnd, nullptr, x, y, 0, 0,
+ SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
+}
+
+void WindowsPlatform::set_window_size(Window* window, int width, int height) {
+ HWND hwnd = window->get_win32_handle();
+ SetWindowPos(hwnd, nullptr, 0, 0, width, height,
+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
+}
+```
+
+### macOS Window Management
+```cpp
+// macOS: Core Graphics API calls
+void MacOSPlatform::set_window_position(Window* window, int x, int y) {
+ CGWindowID window_id = window->get_macos_window_id();
+ CGPoint position = CGPointMake(x, y);
+
+ // Use accessibility APIs to move window
+ AXUIElementRef element = AXUIElementCreateApplication(
+ window->get_macos_pid());
+
+ if (element) {
+ AXUIElementSetAttributeValue(element, kAXPositionAttribute, &position);
+ CFRelease(element);
+ }
+}
+```
+
+## Testing and Validation
+
+### Platform-Specific Testing
+```cpp
+// Test each platform independently
+class PlatformTest {
+public:
+ static void test_x11_platform() {
+ auto platform = std::make_unique<X11Platform>();
+ assert(platform->initialize());
+ // Test X11-specific functionality
+ }
+
+ static void test_wayland_platform() {
+ auto platform = std::make_unique<WaylandPlatform>();
+ assert(platform->initialize());
+ // Test Wayland-specific functionality
+ }
+
+ static void test_windows_platform() {
+ auto platform = std::make_unique<WindowsPlatform>();
+ assert(platform->initialize());
+ // Test Windows-specific functionality
+ }
+
+ static void test_macos_platform() {
+ auto platform = std::make_unique<MacOSPlatform>();
+ assert(platform->initialize());
+ // Test macOS-specific functionality
+ }
+};
+```
+
+## Best Practices
+
+### 1. **Platform Abstraction**
+- Keep platform-specific code isolated
+- Use common interfaces for cross-platform functionality
+- Implement platform detection automatically
+
+### 2. **Wayland vs X11**
+- **Never mix X11 and Wayland APIs**
+- Use wlroots for Wayland (don't implement from scratch)
+- Handle XWayland as a special case within Wayland
+
+### 3. **Event Handling**
+- Respect each platform's event model
+- Don't force synchronous behavior on asynchronous platforms
+- Handle platform-specific quirks gracefully
+
+### 4. **Window Management**
+- Use platform-native APIs for best performance
+- Don't try to emulate one platform's behavior on another
+- Handle platform-specific window states properly
+
+### 5. **Testing**
+- Test each platform independently
+- Use CI/CD with multiple platform targets
+- Validate platform-specific features thoroughly
+
+This implementation approach ensures that SRDWM works correctly on each platform while respecting the fundamental differences between X11, Wayland, Windows, and macOS.
+
+