no compile errors, fully functional workspace indicators
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
|
||||
#include "bar/bar.hpp"
|
||||
#include "services/hyprland.hpp"
|
||||
#include "services/notifications.hpp"
|
||||
#include "services/tray.hpp"
|
||||
|
||||
#include "glibmm/refptr.h"
|
||||
#include "gtkmm/application.h"
|
||||
@@ -18,9 +16,8 @@ class App {
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Application> app;
|
||||
std::vector<Bar *> bars;
|
||||
std::vector<std::shared_ptr<Bar>> bars;
|
||||
HyprlandService *hyprlandService = nullptr;
|
||||
NotificationService notificationService;
|
||||
TrayService *trayService = TrayService::getInstance();
|
||||
|
||||
void setupServices();
|
||||
|
||||
@@ -1,14 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "gtkmm/box.h"
|
||||
#include "gtkmm/button.h"
|
||||
#include "gtkmm/overlay.h"
|
||||
|
||||
class WorkspaceIndicator : public Gtk::Box {
|
||||
public:
|
||||
WorkspaceIndicator(std::string label, sigc::slot<void()> onClick = {});
|
||||
public:
|
||||
|
||||
private:
|
||||
Gtk::Button button;
|
||||
enum InidicatorState {
|
||||
EMPTY,
|
||||
ALIVE,
|
||||
FOCUSED,
|
||||
PRESENTING,
|
||||
URGENT,
|
||||
};
|
||||
|
||||
// meh, Maybe try WorkspaceState struct later
|
||||
WorkspaceIndicator(int id, std::string label, sigc::slot<void(int)> onClick);
|
||||
void setIndicatorState(InidicatorState state);
|
||||
|
||||
private:
|
||||
void clearCssClass();
|
||||
InidicatorState currentState = EMPTY;
|
||||
std::shared_ptr<Gtk::Overlay> overlay;
|
||||
std::map<InidicatorState, std::string> stateToCssClass = {
|
||||
{FOCUSED, "workspace-pill-focused"},
|
||||
{URGENT, "workspace-pill-urgent"},
|
||||
{ALIVE, "workspace-pill-alive"},
|
||||
{PRESENTING, "workspace-pill-presenting"},
|
||||
{EMPTY, "workspace-pill-empty"}, // Default class
|
||||
};
|
||||
};
|
||||
@@ -9,12 +9,13 @@
|
||||
#include "helpers/string.hpp"
|
||||
|
||||
class SocketHelper {
|
||||
|
||||
public:
|
||||
typedef struct SocketMessage {
|
||||
std::string eventType;
|
||||
std::string eventData;
|
||||
} SocketMessage;
|
||||
|
||||
public:
|
||||
static std::vector<SocketMessage> parseSocketMessage(int socketFd, const std::string &delimiter) {
|
||||
char buffer[4096];
|
||||
std::string data;
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
class NotificationService {
|
||||
public:
|
||||
void intialize();
|
||||
|
||||
NotificationService() = default;
|
||||
~NotificationService();
|
||||
|
||||
guint32 allocateNotificationId(guint32 replacesId);
|
||||
GDBusConnection *getConnection() const { return connection; }
|
||||
|
||||
private:
|
||||
GDBusConnection *connection = nullptr;
|
||||
guint registrationId = 0;
|
||||
GDBusNodeInfo *nodeInfo = nullptr;
|
||||
guint32 nextNotificationId = 1;
|
||||
};
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "components/popover.hpp"
|
||||
#include "services/bluetooth.hpp"
|
||||
#include "widgets/bluetooth.hpp"
|
||||
#include "gtkmm/box.h"
|
||||
|
||||
class ControlCenter : public Popover {
|
||||
@@ -11,7 +9,4 @@ class ControlCenter : public Popover {
|
||||
|
||||
private:
|
||||
Gtk::Box container;
|
||||
|
||||
BluetoothWidget *bluetoothWidget = nullptr;
|
||||
BluetoothService *bluetoothService = BluetoothService::getInstance();
|
||||
};
|
||||
Reference in New Issue
Block a user