fix code style

This commit is contained in:
2025-12-10 17:58:01 +01:00
parent 4d61a80a7c
commit 0b3a6c4696
19 changed files with 1016 additions and 1366 deletions

View File

@@ -7,13 +7,11 @@
#include <sigc++/sigc++.h>
#include <string>
class HyprlandService
{
class HyprlandService {
public:
static constexpr int kWorkspaceSlotCount = 5;
static constexpr int kWorkspaceSlotCount = 5;
struct WorkspaceState
{
struct WorkspaceState {
int id = -1;
int hyprId = -1;
bool active = false;
@@ -22,8 +20,7 @@ class HyprlandService
std::string label;
};
struct Monitor
{
struct Monitor {
std::map<int, WorkspaceState> workspaceStates;
std::string name;
int x = 0;
@@ -52,12 +49,12 @@ class HyprlandService
// associated Hyprland workspace id (hyprId >= 0) that id will be used.
// Otherwise the slot and monitor name will be used to request creation
// / activation via `hyprctl`.
void switchToWorkspace(int monitorId, int slot);
void switchToWorkspace(int workspaceId);
private:
int m_fd = -1;
std::string m_buffer;
std::map<int, Monitor> m_monitors;
int fd = -1;
std::string buffer;
std::map<int, Monitor> monitors;
bool on_socket_read(Glib::IOCondition condition);
void parse_message(const std::string &line);
@@ -66,8 +63,7 @@ class HyprlandService
void refresh_workspaces();
};
inline void HyprlandService::printMonitor(const Monitor &mon) const
{
inline void HyprlandService::printMonitor(const Monitor &mon) const {
std::cout << "=== Monitor Info ===\n";
std::cout << "Name: " << mon.name << " (ID: " << mon.id << ")\n";
std::cout << "Position: (" << mon.x << ", " << mon.y << ")\n";
@@ -75,26 +71,26 @@ inline void HyprlandService::printMonitor(const Monitor &mon) const
std::cout << "Workspaces:\n";
if (mon.workspaceStates.empty())
{
if (mon.workspaceStates.empty()) {
std::cout << " (None)\n";
}
else
{
for (int slot = 1; slot <= HyprlandService::kWorkspaceSlotCount; ++slot)
{
} else {
for (int slot = 1; slot <= HyprlandService::kWorkspaceSlotCount;
++slot) {
const auto it = mon.workspaceStates.find(slot);
if (it == mon.workspaceStates.end())
{
if (it == mon.workspaceStates.end()) {
std::cout << " - [Slot: " << slot << " | HyprID: n/a]"
<< " Label: <none> | Active: No | Focused: No | Urgent: No\n";
<< " Label: <none> | Active: No | Focused: No | "
"Urgent: No\n";
continue;
}
const WorkspaceState &ws = it->second;
std::cout << " - [Slot: " << ws.id << " | HyprID: "
<< (ws.hyprId >= 0 ? std::to_string(ws.hyprId) : std::string("n/a")) << "] "
<< "Label: " << (ws.label.empty() ? "<none>" : ws.label) << " | "
<< (ws.hyprId >= 0 ? std::to_string(ws.hyprId)
: std::string("n/a"))
<< "] "
<< "Label: " << (ws.label.empty() ? "<none>" : ws.label)
<< " | "
<< "Active: " << (ws.active ? "Yes" : "No") << " | "
<< "Focused: " << (ws.focused ? "Yes" : "No") << " | "
<< "Urgent: " << (ws.urgent ? "Yes" : "No") << "\n";