no compile errors, fully functional workspace indicators
This commit is contained in:
@@ -3,43 +3,50 @@
|
||||
#include <glibmm.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
#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;
|
||||
inline static HyprlandService *instance = nullptr;
|
||||
|
||||
public:
|
||||
struct WorkspaceState {
|
||||
int id;
|
||||
int monitorId;
|
||||
bool alive = false; // window count above 0 (exists in hyprctl workspaces array)
|
||||
bool presenting = false; // $(hyprctl monitors).activeWorkspace == id
|
||||
bool focused = false; // $(hyprctl monitors).activeWorkspace == id && (hyprctl monitors).focused
|
||||
bool urgent = false; // check ctl clients, and find ws with urgent window
|
||||
struct Client {
|
||||
std::string address;
|
||||
int workspaceId;
|
||||
std::string title;
|
||||
};
|
||||
|
||||
struct WorkspaceData {
|
||||
int id;
|
||||
std::string monitorName;
|
||||
std::string label;
|
||||
|
||||
std::map<std::string, std::shared_ptr<Client>> clients;
|
||||
std::set<std::string> urgentClients;
|
||||
};
|
||||
|
||||
struct Workspace {
|
||||
WorkspaceState state;
|
||||
std::shared_ptr<WorkspaceData> state;
|
||||
std::shared_ptr<WorkspaceIndicator> view;
|
||||
};
|
||||
|
||||
struct Monitor {
|
||||
int id;
|
||||
int activeWorkspaceId;
|
||||
bool focused = false;
|
||||
bool focused;
|
||||
std::string name;
|
||||
std::map<int, std::shared_ptr<Workspace>> monitorWorkspaces;
|
||||
std::shared_ptr<Bar> bar;
|
||||
};
|
||||
|
||||
static HyprlandService *getInstance() {
|
||||
@@ -49,22 +56,57 @@ inline static HyprlandService *instance = nullptr;
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::shared_ptr<Gtk::Box> getWorkspaceIndicatorsForMonitor(int monitorId);
|
||||
std::shared_ptr<Gtk::Box> getWorkspaceIndicatorsForMonitor(std::string monitorName);
|
||||
|
||||
void addBar(std::shared_ptr<Bar> bar, std::string monitorName);
|
||||
|
||||
private:
|
||||
enum SocketEventType {
|
||||
WORKSPACE_CHANGED,
|
||||
|
||||
ACTIVE_WINDOW,
|
||||
OPEN_WINDOW,
|
||||
CLOSE_WINDOW,
|
||||
URGENT,
|
||||
|
||||
FOCUSED_MONITOR,
|
||||
MONITOR_REMOVED,
|
||||
};
|
||||
|
||||
std::map<std::string, SocketEventType> socketEventTypeMap = {
|
||||
{"workspace", WORKSPACE_CHANGED},
|
||||
{"activewindowv2", ACTIVE_WINDOW},
|
||||
{"openwindow", OPEN_WINDOW},
|
||||
{"closewindow", CLOSE_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 onUrgent(std::string windowAddress);
|
||||
void onActiveWindowChanged(std::string windowAddress);
|
||||
void onMonitorRemoved(std::string monitorName);
|
||||
// void onMonitorAdded(std::string monitorName);
|
||||
|
||||
HyprlandService();
|
||||
std::map<int, std::shared_ptr<Monitor>> monitors;
|
||||
std::map<std::string, std::shared_ptr<Monitor>> monitors;
|
||||
std::map<int, std::shared_ptr<Workspace>> workspaces;
|
||||
std::map<std::string, std::shared_ptr<Client>> clients;
|
||||
|
||||
/// maybe refactor into reusable class
|
||||
std::string socketBuffer;
|
||||
int socketFd;
|
||||
///
|
||||
|
||||
std::string getSocketPath();
|
||||
void bindSocket();
|
||||
|
||||
void init();
|
||||
|
||||
void updateIndicator(Workspace &workspace, const WorkspaceState newState);
|
||||
void switchToWorkspace(int workspaceId);
|
||||
void refreshIndicator(std::shared_ptr<Workspace> workspace);
|
||||
|
||||
void handleSocketMessage(SocketHelper::SocketMessage message);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user