From 8110bb2773b6c841029a51eca7971f42a36f480c Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 2 Apr 2024 00:58:00 +0200 Subject: Rewrite srdwm in Rust: working X11 and Wayland backends, Lua config The C++ prototype (moved to legacy-cpp/) was mostly a design skeleton: X11 and Windows backends were partially real, Wayland created the wlroots object graph but never wired a single event listener, macOS was stub except monitor enumeration, and the Lua engine's srd.bind() stored a key-combo string but never the actual closure. See docs/PRIOR_ART.md for the full audit. This replaces it with a Cargo workspace: - srdwm-core: platform-independent window/workspace/monitor state, a real master-stack tiling layout, and SmartPlacement grid/cascade/ snap-to-edge placement - fixing several bugs in the C++ version (hardcoded 2-column grid, cascade that never cascaded, snap-to-edge that always returned a fixed rect). 35 unit tests. - srdwm-config: the srd Lua API via mlua, implementing the surface docs/DEFAULTS.md always documented but the C++ engine never actually built (srd.window.close()/focus(direction), srd.workspace.next(), real keybinding closures, require("srd") support). 10 unit tests. - srdwm-x11: a real reparenting WM with a drawn title bar (buttons, drag, resize), verified live under Xephyr - frame placement and client offset match srdwm-core's computed geometry exactly, and the decoration renders correctly on screen. - srdwm-wayland: a from-scratch smithay compositor (the C++ version had nothing working to port from) - runs via the winit backend, tracks xdg-shell toplevels through the same WindowManager and hit-testing code X11 uses, verified to start/render/run without crashing. Decorations are solid-color (no text yet); see docs/IMPLEMENTATION_STATUS.md for exact scope. - srdwm-windows / srdwm-macos: structured, cfg-gated designs informed by komorebi/glazewm and yabai/AeroSpace respectively (see docs/PRIOR_ART.md), honestly marked as unbuilt/unverified since this sandbox has no Windows or macOS target. --- src/platform/windows_platform.h | 140 ---------------------------------------- 1 file changed, 140 deletions(-) delete mode 100644 src/platform/windows_platform.h (limited to 'src/platform/windows_platform.h') diff --git a/src/platform/windows_platform.h b/src/platform/windows_platform.h deleted file mode 100644 index 70b7d54..0000000 --- a/src/platform/windows_platform.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef SRDWM_WINDOWS_PLATFORM_H -#define SRDWM_WINDOWS_PLATFORM_H - -#include "platform.h" -#include -#include -#include -#include - -class SRDWindowsPlatform : public Platform { -public: - SRDWindowsPlatform(); - ~SRDWindowsPlatform() override; - - // Platform interface implementation - bool initialize() override; - void shutdown() override; - - bool poll_events(std::vector& events) override; - void process_event(const Event& event) override; - - std::unique_ptr create_window(const std::string& title, int x, int y, int width, int height) override; - void destroy_window(SRDWindow* window) override; - void set_window_position(SRDWindow* window, int x, int y) override; - void set_window_size(SRDWindow* window, int width, int height) override; - void set_window_title(SRDWindow* window, const std::string& title) override; - void focus_window(SRDWindow* window) override; - void minimize_window(SRDWindow* window) override; - void maximize_window(SRDWindow* window) override; - void close_window(SRDWindow* window) override; - - std::vector get_monitors() override; - Monitor get_primary_monitor() override; - - void grab_keyboard() override; - void ungrab_keyboard() override; - void grab_pointer() override; - void ungrab_pointer() override; - - // SRDWindow decorations (SRDWindows implementation) - void set_window_decorations(SRDWindow* window, bool enabled) override; - void set_window_border_color(SRDWindow* window, int r, int g, int b) override; - void set_window_border_width(SRDWindow* window, int width) override; - bool get_window_decorations(SRDWindow* window) const override; - - // Windows-specific features - void enable_dwm_composition(bool enabled); - void set_dwm_window_attribute(HWND hwnd, DWORD attribute, DWORD value); - void set_dwm_window_thumbnail(HWND hwnd, HWND thumbnail_hwnd); - void set_dwm_window_peek(HWND hwnd, bool enabled); - - // Virtual Desktop support (Windows 10+) - void create_virtual_desktop(); - void remove_virtual_desktop(int desktop_id); - void switch_to_virtual_desktop(int desktop_id); - int get_current_virtual_desktop() const; - std::vector get_virtual_desktops() const; - void move_window_to_desktop(SRDWindow* window, int desktop_id); - - // Taskbar integration - void set_taskbar_visible(bool visible); - void set_taskbar_position(int position); // 0=bottom, 1=top, 2=left, 3=right - void set_taskbar_auto_hide(bool enabled); - void update_taskbar_preview(HWND hwnd, const std::string& title); - - // Aero effects - void enable_aero_effects(bool enabled); - void set_window_transparency(HWND hwnd, BYTE alpha); - void set_window_blur(HWND hwnd, bool enabled); - void set_window_shadow(HWND hwnd, bool enabled); - - // System tray integration - void add_system_tray_icon(const std::string& tooltip, HICON icon); - void remove_system_tray_icon(); - void show_system_tray_menu(HMENU menu); - - std::string get_platform_name() const override; - bool is_wayland() const override; - bool is_x11() const override; - bool is_windows() const override; - bool is_macos() const override; - -private: - bool initialized_; - HINSTANCE h_instance_; - std::map window_map_; - std::vector monitors_; - - // Decoration state - bool decorations_enabled_; - int border_width_; - COLORREF border_color_; - COLORREF focused_border_color_; - - // Windows-specific state - bool dwm_enabled_; - bool aero_enabled_; - bool taskbar_visible_; - bool taskbar_auto_hide_; - int taskbar_position_; - int current_virtual_desktop_; - std::vector virtual_desktops_; - NOTIFYICONDATA system_tray_icon_; - - // SRDWindow class registration - bool register_window_class(); - void unregister_window_class(); - - // SRDWindow procedure - static LRESULT CALLBACK window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); - - // Event conversion - void convert_win32_message(UINT msg, WPARAM wparam, LPARAM lparam, std::vector& events); - - // Monitor enumeration - static BOOL CALLBACK enum_monitor_proc(HMONITOR hmonitor, HDC hdc_monitor, LPRECT lprc_monitor, LPARAM dw_data); - - // Utility methods - void update_monitors(); - SRDWindow* find_window_by_hwnd(HWND hwnd); - - // Decoration methods - void apply_dwm_border_color(HWND hwnd, int r, int g, int b); - void remove_dwm_border_color(HWND hwnd); - - // Virtual Desktop methods - void initialize_virtual_desktops(); - void cleanup_virtual_desktops(); - - // DWM methods - bool initialize_dwm(); - void cleanup_dwm(); - - // Taskbar methods - void initialize_taskbar(); - void update_taskbar(); -}; - -#endif // SRDWM_WINDOWS_PLATFORM_H - -- cgit v1.2.3