refactor and shizz

This commit is contained in:
2025-12-25 21:13:00 +01:00
parent a06c96f648
commit 9b5db719cb
27 changed files with 286 additions and 312 deletions

View File

@@ -8,15 +8,13 @@
#include "sigc++/signal.h"
class BluetoothService {
static BluetoothService *instance;
inline static BluetoothService *instance = nullptr;
public:
sigc::signal<void(bool)> powerStateChangedSignal;
sigc::signal<void(bool)> isDiscoveringChangedSignal;
bool getPowerState();
bool getIsDiscovering();
void togglePowerState();

View File

@@ -5,9 +5,12 @@
#include <map>
#include <sigc++/sigc++.h>
#include <string>
#include <sys/stat.h>
#include <vector>
class HyprlandService {
inline static HyprlandService *instance = nullptr;
public:
static constexpr int kWorkspaceSlotCount = 7;
const char *kMonitorCommand = "hyprctl monitors -j";
@@ -36,9 +39,6 @@ class HyprlandService {
int focusedWorkspaceId = -1;
};
HyprlandService();
~HyprlandService();
void start();
void on_hyprland_event(std::string event, std::string data);
void printMonitor(const Monitor &mon) const;
@@ -55,11 +55,21 @@ class HyprlandService {
return this->workspaces;
}
static HyprlandService *getInstance() {
if (HyprlandService::instance == nullptr) {
HyprlandService::instance = new HyprlandService();
}
return HyprlandService::instance;
}
private:
HyprlandService();
~HyprlandService();
int fd = -1;
std::map<int, Monitor> monitors;
std::map<int, WorkspaceState *> workspaces;
// persistent buffer for socket reads to handle partial messages
std::string socket_buffer;
std::string get_socket_path();

View File

@@ -16,6 +16,7 @@
#include <vector>
class TrayService {
inline static TrayService *instance = nullptr;
public:
struct Item {
std::string id;
@@ -29,9 +30,6 @@ class TrayService {
Glib::RefPtr<Gdk::Paintable> iconPaintable;
};
TrayService();
~TrayService();
void start();
void stop();
@@ -44,7 +42,6 @@ class TrayService {
Glib::RefPtr<Gio::MenuModel> get_menu_model(const std::string &id);
Glib::RefPtr<Gio::ActionGroup> get_menu_action_group(const std::string &id);
void debug_dump_menu_layout(const std::string &id);
struct MenuNode {
int id = 0;
std::string label;
@@ -60,7 +57,18 @@ class TrayService {
sigc::signal<void(const std::string &)> &signal_item_removed();
sigc::signal<void(const Item &)> &signal_item_updated();
static TrayService *getInstance() {
if (TrayService::instance == nullptr) {
TrayService::instance = new TrayService();
}
return TrayService::instance;
}
private:
TrayService();
~TrayService();
struct TrackedItem {
Item publicData;
guint signalSubscriptionId = 0;