diff options
| author | srdusr <[email protected]> | 2024-04-02 00:58:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2024-04-02 00:58:00 +0200 |
| commit | 8110bb2773b6c841029a51eca7971f42a36f480c (patch) | |
| tree | b3b364a6c0231fe408229e94dc9e25ce4562ad02 /src/platform/linux_platform.h | |
| parent | d1f856edc516047575cf46f12fad2b59006363c8 (diff) | |
| download | srdwm-8110bb2773b6c841029a51eca7971f42a36f480c.tar.gz srdwm-8110bb2773b6c841029a51eca7971f42a36f480c.zip | |
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.
Diffstat (limited to 'src/platform/linux_platform.h')
| -rw-r--r-- | src/platform/linux_platform.h | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/platform/linux_platform.h b/src/platform/linux_platform.h deleted file mode 100644 index 1237c85..0000000 --- a/src/platform/linux_platform.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef SRDWM_LINUX_PLATFORM_H -#define SRDWM_LINUX_PLATFORM_H - -#include "platform.h" -#include <memory> -#include <string> - -// Forward declarations for X11 -#ifdef __linux__ -struct _XDisplay; -typedef struct _XDisplay Display; -typedef unsigned long SRDWindow; -typedef unsigned long Atom; - -// Forward declarations for Wayland -struct wl_display; -struct wl_registry; -struct wl_compositor; -struct wl_shell; -struct wl_seat; -struct wl_keyboard; -struct wl_pointer; -#endif - -class LinuxPlatform : public Platform { -public: - enum class Backend { - Auto, - X11, - Wayland - }; - - explicit LinuxPlatform(Backend backend = Backend::Auto); - ~LinuxPlatform() override; - - // Platform interface implementation - bool initialize() override; - void shutdown() override; - - bool poll_events(std::vector<Event>& events) override; - void process_event(const Event& event) override; - - std::unique_ptr<SRDWindow> 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<Monitor> get_monitors() override; - Monitor get_primary_monitor() override; - - void grab_keyboard() override; - void ungrab_keyboard() override; - void grab_pointer() override; - void ungrab_pointer() override; - - 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: - Backend backend_; - bool initialized_; - - // X11 specific members - Display* x11_display_; - SRDWindow x11_root_; - Atom x11_wm_delete_window_; - Atom x11_wm_protocols_; - - // Wayland specific members - wl_display* wayland_display_; - wl_registry* wayland_registry_; - wl_compositor* wayland_compositor_; - wl_shell* wayland_shell_; - wl_seat* wayland_seat_; - wl_keyboard* wayland_keyboard_; - wl_pointer* wayland_pointer_; - - // Common members - std::vector<Monitor> monitors_; - - // Private methods - bool initialize_x11(); - bool initialize_wayland(); - void shutdown_x11(); - void shutdown_wayland(); - - bool detect_backend(); - void setup_x11_atoms(); - void setup_wayland_registry(); - - // Event processing - void process_x11_event(XEvent& event, std::vector<Event>& events); - void process_wayland_event(wl_display* display, std::vector<Event>& events); -}; - -#endif // SRDWM_LINUX_PLATFORM_H - |