1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#ifndef SRDWM_LAYOUT_ENGINE_H
#define SRDWM_LAYOUT_ENGINE_H
#include "layout.h"
#include "tiling_layout.h"
#include "dynamic_layout.h"
#include <vector>
#include <map>
#include <string>
#include <functional>
class SRDWindow; // Forward declaration to avoid circular dependency
enum class LayoutType {
TILING,
DYNAMIC,
FLOATING
// Add other layout types here later
};
class LayoutEngine {
public:
LayoutEngine();
~LayoutEngine();
// Layout management
bool set_layout(int monitor_id, LayoutType layout_type);
bool set_layout(int monitor_id, const std::string& layout_name);
LayoutType get_layout(int monitor_id) const;
std::string get_layout_name(int monitor_id) const;
// Layout configuration
bool configure_layout(const std::string& layout_name, const std::map<std::string, std::string>& config);
bool register_custom_layout(const std::string& name, std::function<void(const std::vector<SRDWindow*>&, const Monitor&)> layout_func);
// SRDWindow management
void add_window(SRDWindow* window);
void remove_window(SRDWindow* window);
void update_window(SRDWindow* window);
// Monitor management
void add_monitor(const Monitor& monitor);
void remove_monitor(int monitor_id);
void update_monitor(const Monitor& monitor);
// Arrangement
void arrange_on_monitor(const Monitor& monitor);
void arrange_all_monitors();
// Utility
std::vector<std::string> get_available_layouts() const;
std::vector<SRDWindow*> get_windows_on_monitor(int monitor_id) const;
private:
// Member variables for layout state
std::vector<Monitor> monitors_;
std::vector<SRDWindow*> windows_;
TilingLayout tiling_layout_;
DynamicLayout dynamic_layout_;
std::map<int, LayoutType> active_layouts_; // Map monitor ID to active layout type
std::map<std::string, std::function<void(const std::vector<SRDWindow*>&, const Monitor&)>> custom_layouts_;
std::map<std::string, std::map<std::string, std::string>> layout_configs_;
// Helper methods
LayoutType string_to_layout_type(const std::string& name) const;
std::string layout_type_to_string(LayoutType type) const;
bool is_window_on_monitor(const SRDWindow* window, const Monitor& monitor) const;
};
#endif // SRDWM_LAYOUT_ENGINE_H
|