70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <glibmm.h>
|
|
#include <map>
|
|
#include <sigc++/sigc++.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class HyprlandService {
|
|
public:
|
|
static constexpr int kWorkspaceSlotCount = 7;
|
|
|
|
struct WindowState {
|
|
int hyprId = -1;
|
|
};
|
|
|
|
struct WorkspaceState {
|
|
int hyprId = -1;
|
|
int monitorId = -1;
|
|
bool active = false;
|
|
bool focused = false;
|
|
std::vector<int> urgentWindows;
|
|
std::string label;
|
|
};
|
|
|
|
struct Monitor {
|
|
std::map<int, WorkspaceState*> workspaceStates;
|
|
std::string name;
|
|
int x = 0;
|
|
int y = 0;
|
|
int id = -1;
|
|
int focusedWorkspaceId = -1;
|
|
};
|
|
|
|
HyprlandService();
|
|
~HyprlandService();
|
|
|
|
void start();
|
|
void on_hyprland_event(std::string event, std::string data);
|
|
|
|
void printMonitor(const Monitor &mon) const;
|
|
|
|
sigc::signal<void(std::string, std::string)> socketEventSignal;
|
|
sigc::signal<void()> workspaceStateChanged;
|
|
sigc::signal<void()> monitorStateChanged;
|
|
|
|
Monitor *getMonitorById(int id);
|
|
const Monitor *getMonitorById(int id) const;
|
|
Monitor *getMonitorByIndex(std::size_t index);
|
|
const Monitor *getMonitorByIndex(std::size_t index) const;
|
|
void switchToWorkspace(int workspaceId);
|
|
|
|
std::map<int, WorkspaceState*> getAllWorkspaces() const {
|
|
return this->workspaces;
|
|
}
|
|
|
|
private:
|
|
int fd = -1;
|
|
std::map<int, Monitor> monitors;
|
|
std::map<int, WorkspaceState*> workspaces;
|
|
|
|
std::string get_socket_path();
|
|
bool on_socket_read(Glib::IOCondition condition);
|
|
void parse_message(const std::string &line);
|
|
void refresh_monitors();
|
|
void refresh_workspaces();
|
|
void handle_urgent_window(std::string windowAddress);
|
|
};
|