srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/legacy-cpp/src/platform/wayland_platform_stub.cc
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-04-02 00:58:00 +0200
committersrdusr <[email protected]>2024-04-02 00:58:00 +0200
commit8110bb2773b6c841029a51eca7971f42a36f480c (patch)
treeb3b364a6c0231fe408229e94dc9e25ce4562ad02 /legacy-cpp/src/platform/wayland_platform_stub.cc
parentd1f856edc516047575cf46f12fad2b59006363c8 (diff)
downloadsrdwm-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 'legacy-cpp/src/platform/wayland_platform_stub.cc')
-rw-r--r--legacy-cpp/src/platform/wayland_platform_stub.cc114
1 files changed, 114 insertions, 0 deletions
diff --git a/legacy-cpp/src/platform/wayland_platform_stub.cc b/legacy-cpp/src/platform/wayland_platform_stub.cc
new file mode 100644
index 0000000..bdf6ee9
--- /dev/null
+++ b/legacy-cpp/src/platform/wayland_platform_stub.cc
@@ -0,0 +1,114 @@
+#include "wayland_platform.h"
+#include <iostream>
+#include <cstdint>
+
+WaylandPlatform* WaylandPlatform::instance_ = nullptr;
+
+WaylandPlatform::WaylandPlatform()
+ : display_(nullptr)
+ , registry_(nullptr)
+ , compositor_(nullptr)
+ , shm_(nullptr)
+ , seat_(nullptr)
+ , output_(nullptr)
+ , shell_(nullptr)
+ , backend_(nullptr)
+ , renderer_(nullptr)
+ , wlr_compositor_(nullptr)
+ , output_layout_(nullptr)
+ , cursor_(nullptr)
+ , xcursor_manager_(nullptr)
+ , wlr_seat_(nullptr)
+ , xdg_shell_(nullptr)
+ , event_loop_running_(false)
+ , decorations_enabled_(true)
+ , decoration_manager_(nullptr) {
+ instance_ = this;
+}
+
+WaylandPlatform::~WaylandPlatform() {
+ shutdown();
+ if (instance_ == this) instance_ = nullptr;
+}
+
+bool WaylandPlatform::initialize() {
+ std::cout << "Wayland (stub): initialize" << std::endl;
+ decorations_enabled_ = true;
+ return true;
+}
+
+void WaylandPlatform::shutdown() {
+ std::cout << "Wayland (stub): shutdown" << std::endl;
+}
+
+bool WaylandPlatform::poll_events(std::vector<Event>& events) {
+ events.clear();
+ return true;
+}
+
+void WaylandPlatform::process_event(const Event& /*event*/) {}
+
+std::unique_ptr<SRDWindow> WaylandPlatform::create_window(const std::string& title, int, int, int, int) {
+ std::cout << "Wayland (stub): create_window '" << title << "'" << std::endl;
+ return nullptr;
+}
+
+void WaylandPlatform::destroy_window(SRDWindow*) {}
+void WaylandPlatform::set_window_position(SRDWindow*, int, int) {}
+void WaylandPlatform::set_window_size(SRDWindow*, int, int) {}
+void WaylandPlatform::set_window_title(SRDWindow*, const std::string&) {}
+void WaylandPlatform::focus_window(SRDWindow*) {}
+void WaylandPlatform::minimize_window(SRDWindow*) {}
+void WaylandPlatform::maximize_window(SRDWindow*) {}
+void WaylandPlatform::close_window(SRDWindow*) {}
+std::vector<Monitor> WaylandPlatform::get_monitors() { return {}; }
+Monitor WaylandPlatform::get_primary_monitor() { return Monitor{}; }
+void WaylandPlatform::grab_keyboard() {}
+void WaylandPlatform::ungrab_keyboard() {}
+void WaylandPlatform::grab_pointer() {}
+void WaylandPlatform::ungrab_pointer() {}
+void WaylandPlatform::set_window_decorations(SRDWindow*, bool enabled) { decorations_enabled_ = enabled; }
+void WaylandPlatform::set_window_border_color(SRDWindow*, int, int, int) {}
+void WaylandPlatform::set_window_border_width(SRDWindow*, int) {}
+bool WaylandPlatform::get_window_decorations(SRDWindow*) const { return decorations_enabled_; }
+
+// Private helpers (stubs)
+bool WaylandPlatform::setup_wlroots_backend() { return true; }
+bool WaylandPlatform::setup_compositor() { return true; }
+bool WaylandPlatform::setup_shell_protocols() { return true; }
+void WaylandPlatform::handle_registry_global(struct wl_registry*, uint32_t, const char*, uint32_t) {}
+void WaylandPlatform::handle_registry_global_remove(struct wl_registry*, uint32_t) {}
+void WaylandPlatform::handle_xdg_surface_new(struct wlr_xdg_surface*) {}
+void WaylandPlatform::handle_xdg_surface_destroy(struct wlr_xdg_surface*) {}
+void WaylandPlatform::handle_xdg_toplevel_new(struct wlr_xdg_toplevel*) {}
+void WaylandPlatform::handle_xdg_toplevel_destroy(struct wlr_xdg_toplevel*) {}
+void WaylandPlatform::handle_output_new(struct wlr_output*) {}
+void WaylandPlatform::handle_output_destroy(struct wlr_output*) {}
+void WaylandPlatform::handle_output_frame(struct wlr_output*) {}
+void WaylandPlatform::handle_pointer_motion(struct wlr_pointer_motion_event*) {}
+void WaylandPlatform::handle_pointer_button(struct wlr_pointer_button_event*) {}
+void WaylandPlatform::handle_pointer_axis(struct wlr_pointer_axis_event*) {}
+void WaylandPlatform::keyboard_key_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::pointer_motion_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::pointer_button_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::pointer_axis_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::output_new_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::output_destroy_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::output_frame_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::xdg_surface_new_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::xdg_surface_destroy_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::xdg_toplevel_new_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::xdg_toplevel_destroy_handler(struct wl_listener*, void*) {}
+void WaylandPlatform::manage_xdg_window(struct wlr_xdg_surface*) {}
+void WaylandPlatform::unmanage_window(SRDWindow*) {}
+void WaylandPlatform::handle_output_mode(struct wlr_output*) {}
+void WaylandPlatform::handle_output_scale(struct wlr_output*) {}
+void WaylandPlatform::handle_key_event(uint32_t, bool) {}
+void WaylandPlatform::handle_button_event(uint32_t, bool) {}
+void WaylandPlatform::create_surface_window(struct wlr_surface*) {}
+void WaylandPlatform::destroy_surface_window(struct wlr_surface*) {}
+void WaylandPlatform::update_surface_window(struct wlr_surface*) {}
+void WaylandPlatform::convert_wlroots_event_to_srdwm_event(void*, EventType) {}
+void WaylandPlatform::handle_wlroots_error(const std::string&) {}
+void WaylandPlatform::setup_decoration_manager() {}
+void WaylandPlatform::handle_decoration_request(struct wlr_xdg_surface*, uint32_t) {}