#pragma once #include #include #include #include #include #include #include #include "bar/bar.hpp" #include "components/workspaceIndicator.hpp" #include "helpers/socket.hpp" #include "gtkmm/box.h" #define NUM_WORKSPACES 7 class HyprlandService { inline static HyprlandService *instance = nullptr; public: struct Client { std::string address; int workspaceId; std::string title; }; struct WorkspaceData { int id; std::string monitorName; std::string label; std::map> clients; std::set urgentClients; }; struct Workspace { std::shared_ptr state; std::shared_ptr view; }; struct Monitor { int id; int activeWorkspaceId; bool focused; std::string name; std::map> monitorWorkspaces; std::shared_ptr bar; }; static HyprlandService *getInstance() { if (!instance) { instance = new HyprlandService(); } return instance; } std::shared_ptr getWorkspaceIndicatorsForMonitor(std::string monitorName); void addBar(std::shared_ptr bar, std::string monitorName); private: enum SocketEventType { WORKSPACE_CHANGED, ACTIVE_WINDOW, OPEN_WINDOW, CLOSE_WINDOW, MOVE_WINDOW, URGENT, FOCUSED_MONITOR, MONITOR_REMOVED, }; std::map socketEventTypeMap = { {"workspace", WORKSPACE_CHANGED}, {"activewindowv2", ACTIVE_WINDOW}, {"openwindow", OPEN_WINDOW}, {"closewindow", CLOSE_WINDOW}, {"movewindowv2", MOVE_WINDOW}, {"urgent", URGENT}, {"focusedmon", FOCUSED_MONITOR}, {"monitorremoved", MONITOR_REMOVED}, }; void onWorkspaceChanged(int workspaceId); void onFocusedMonitorChanged(std::string monitorData); void onOpenWindow(std::string windowData); void onCloseWindow(std::string windowData); void onMoveWindow(std::string windowData); void onUrgent(std::string windowAddress); void onActiveWindowChanged(std::string windowAddress); void onMonitorRemoved(std::string monitorName); // void onMonitorAdded(std::string monitorName); HyprlandService(); std::map> monitors; std::map> workspaces; std::map> clients; /// maybe refactor into reusable class std::string socketBuffer; int socketFd; /// void bindHyprlandSocket(); void init(); void switchToWorkspace(int workspaceId); void refreshIndicator(std::shared_ptr workspace); void handleSocketMessage(SocketHelper::SocketMessage message); };