srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/legacy-cpp/src/config/config_manager.h
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/config/config_manager.h
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/config/config_manager.h')
-rw-r--r--legacy-cpp/src/config/config_manager.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/legacy-cpp/src/config/config_manager.h b/legacy-cpp/src/config/config_manager.h
new file mode 100644
index 0000000..97f751e
--- /dev/null
+++ b/legacy-cpp/src/config/config_manager.h
@@ -0,0 +1,101 @@
+#ifndef SRDWM_CONFIG_MANAGER_H
+#define SRDWM_CONFIG_MANAGER_H
+
+#include <string>
+#include <memory>
+#include <map>
+#include <functional>
+#include <vector> // Added missing include
+
+// Forward declarations
+class WindowManager;
+
+// Configuration manager for srdwm
+class ConfigManager {
+public:
+ struct KeyBinding {
+ std::string key;
+ std::string command;
+ std::string description;
+ };
+
+ struct LayoutConfig {
+ std::string name;
+ std::string type; // "tiling", "dynamic", "floating"
+ std::map<std::string, std::string> properties;
+ };
+
+ struct ThemeConfig {
+ std::string name;
+ std::map<std::string, std::string> colors;
+ std::map<std::string, std::string> fonts;
+ std::map<std::string, int> dimensions;
+ };
+
+ ConfigManager();
+ ~ConfigManager();
+
+ // Configuration loading
+ bool load_config(const std::string& config_path);
+ bool reload_config();
+
+ // Configuration access
+ std::string get_string(const std::string& key, const std::string& default_value = "") const;
+ int get_int(const std::string& key, int default_value = 0) const;
+ bool get_bool(const std::string& key, bool default_value = false) const;
+ double get_float(const std::string& key, double default_value = 0.0) const;
+
+ // Key bindings
+ std::vector<KeyBinding> get_key_bindings() const;
+ bool add_key_binding(const std::string& key, const std::string& command, const std::string& description = "");
+ bool remove_key_binding(const std::string& key);
+
+ // Layout configuration
+ std::vector<LayoutConfig> get_layout_configs() const;
+ LayoutConfig get_layout_config(const std::string& name) const;
+
+ // Theme configuration
+ ThemeConfig get_theme_config() const;
+ bool set_theme(const std::string& theme_name);
+
+ // Window rules
+ struct WindowRule {
+ std::string match_type; // "class", "title", "role"
+ std::string match_value;
+ std::map<std::string, std::string> properties;
+ };
+
+ std::vector<WindowRule> get_window_rules() const;
+ bool add_window_rule(const WindowRule& rule);
+
+ // Configuration validation
+ bool validate_config() const;
+ std::vector<std::string> get_validation_errors() const;
+
+private:
+ std::string config_path_;
+ std::map<std::string, std::string> string_values_;
+ std::map<std::string, int> int_values_;
+ std::map<std::string, bool> bool_values_;
+ std::map<std::string, double> float_values_;
+
+ std::vector<KeyBinding> key_bindings_;
+ std::vector<LayoutConfig> layout_configs_;
+ std::vector<WindowRule> window_rules_;
+ ThemeConfig current_theme_;
+
+ std::vector<std::string> validation_errors_;
+
+ // Private methods
+ void parse_config_file(const std::string& content);
+ void setup_default_config();
+ bool validate_key_binding(const KeyBinding& binding) const;
+ bool validate_layout_config(const LayoutConfig& config) const;
+ bool validate_window_rule(const WindowRule& rule) const;
+
+ // Lua integration (placeholder for future implementation)
+ bool execute_lua_config(const std::string& lua_code);
+};
+
+#endif // SRDWM_CONFIG_MANAGER_H
+