fix code style
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <gdkmm/memorytexture.h>
|
||||
#include <giomm/actiongroup.h>
|
||||
#include <giomm/dbusconnection.h>
|
||||
#include <giomm/menumodel.h>
|
||||
#include <giomm/init.h>
|
||||
#include <giomm/menumodel.h>
|
||||
#include <glibmm/bytes.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <sigc++/sigc++.h>
|
||||
@@ -16,11 +16,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class TrayService
|
||||
{
|
||||
class TrayService {
|
||||
public:
|
||||
struct Item
|
||||
{
|
||||
struct Item {
|
||||
std::string id;
|
||||
std::string busName;
|
||||
std::string objectPath;
|
||||
@@ -48,14 +46,13 @@ 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;
|
||||
bool enabled = true;
|
||||
bool visible = true;
|
||||
bool separator = false;
|
||||
std::vector<MenuNode> children;
|
||||
struct MenuNode {
|
||||
int id = 0;
|
||||
std::string label;
|
||||
bool enabled = true;
|
||||
bool visible = true;
|
||||
bool separator = false;
|
||||
std::vector<MenuNode> children;
|
||||
};
|
||||
std::optional<MenuNode> get_menu_layout(const std::string &id);
|
||||
bool activate_menu_item(const std::string &id, int itemId);
|
||||
@@ -65,56 +62,57 @@ class TrayService
|
||||
sigc::signal<void(const Item &)> &signal_item_updated();
|
||||
|
||||
private:
|
||||
struct TrackedItem
|
||||
{
|
||||
struct TrackedItem {
|
||||
Item publicData;
|
||||
guint signalSubscriptionId = 0;
|
||||
guint ownerWatchId = 0;
|
||||
Glib::RefPtr<Gio::MenuModel> menuModel;
|
||||
Glib::RefPtr<Gio::ActionGroup> menuActions;
|
||||
Glib::RefPtr<Gio::MenuModel> menuModel;
|
||||
Glib::RefPtr<Gio::ActionGroup> menuActions;
|
||||
};
|
||||
|
||||
Glib::RefPtr<Gio::DBus::Connection> m_connection;
|
||||
Glib::RefPtr<Gio::DBus::NodeInfo> m_nodeInfo;
|
||||
Gio::DBus::InterfaceVTable m_vtable;
|
||||
Glib::RefPtr<Gio::DBus::Connection> connection;
|
||||
Glib::RefPtr<Gio::DBus::NodeInfo> nodeInfo;
|
||||
Gio::DBus::InterfaceVTable vtable;
|
||||
|
||||
guint m_nameOwnerId = 0;
|
||||
guint m_registrationId = 0;
|
||||
bool m_hostRegistered = false;
|
||||
guint nameOwnerId = 0;
|
||||
guint registrationId = 0;
|
||||
bool hostRegistered = false;
|
||||
|
||||
std::map<std::string, std::unique_ptr<TrackedItem>> m_items;
|
||||
std::map<std::string, std::unique_ptr<TrackedItem>> items;
|
||||
|
||||
sigc::signal<void(const Item &)> m_itemAddedSignal;
|
||||
sigc::signal<void(const std::string &)> m_itemRemovedSignal;
|
||||
sigc::signal<void(const Item &)> m_itemUpdatedSignal;
|
||||
sigc::signal<void(const Item &)> itemAddedSignal;
|
||||
sigc::signal<void(const std::string &)> itemRemovedSignal;
|
||||
sigc::signal<void(const Item &)> itemUpdatedSignal;
|
||||
|
||||
void on_bus_acquired(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name);
|
||||
void on_name_acquired(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name);
|
||||
void on_name_lost(const Glib::RefPtr<Gio::DBus::Connection> &connection, const Glib::ustring &name);
|
||||
void on_bus_acquired(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &name);
|
||||
void on_name_acquired(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &name);
|
||||
void on_name_lost(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &name);
|
||||
|
||||
void handle_method_call(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender,
|
||||
const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name,
|
||||
const Glib::ustring &method_name,
|
||||
const Glib::VariantContainerBase ¶meters,
|
||||
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation);
|
||||
void handle_method_call(
|
||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender, const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name, const Glib::ustring &method_name,
|
||||
const Glib::VariantContainerBase ¶meters,
|
||||
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation);
|
||||
|
||||
void handle_get_property_slot(Glib::VariantBase &result,
|
||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender,
|
||||
const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name,
|
||||
const Glib::ustring &property_name);
|
||||
bool handle_set_property_slot(const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender,
|
||||
const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name,
|
||||
const Glib::ustring &property_name,
|
||||
const Glib::VariantBase &value);
|
||||
void handle_get_property_slot(
|
||||
Glib::VariantBase &result,
|
||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender, const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name,
|
||||
const Glib::ustring &property_name);
|
||||
bool handle_set_property_slot(
|
||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||
const Glib::ustring &sender, const Glib::ustring &object_path,
|
||||
const Glib::ustring &interface_name, const Glib::ustring &property_name,
|
||||
const Glib::VariantBase &value);
|
||||
|
||||
Glib::VariantBase handle_get_property(const Glib::ustring &property_name);
|
||||
bool handle_set_property(const Glib::ustring &property_name, const Glib::VariantBase &value);
|
||||
bool handle_set_property(const Glib::ustring &property_name,
|
||||
const Glib::VariantBase &value);
|
||||
|
||||
void register_item(const Glib::ustring &sender, const std::string &service);
|
||||
void unregister_item(const std::string &id);
|
||||
@@ -122,25 +120,23 @@ class TrayService
|
||||
void refresh_item(TrackedItem &item);
|
||||
void emit_registered_items_changed();
|
||||
|
||||
Glib::Variant<std::vector<Glib::ustring>> create_registered_items_variant() const;
|
||||
Glib::Variant<std::vector<Glib::ustring>>
|
||||
create_registered_items_variant() const;
|
||||
|
||||
void emit_watcher_signal(const Glib::ustring &signal_name, const Glib::VariantContainerBase ¶meters);
|
||||
void emit_watcher_signal(const Glib::ustring &signal_name,
|
||||
const Glib::VariantContainerBase ¶meters);
|
||||
|
||||
static void on_dbus_signal_static(GDBusConnection *connection,
|
||||
const gchar *sender_name,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *signal_name,
|
||||
GVariant *parameters,
|
||||
gpointer user_data);
|
||||
void on_dbus_signal(const gchar *sender_name,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *signal_name,
|
||||
GVariant *parameters);
|
||||
const gchar *sender_name,
|
||||
const gchar *object_path,
|
||||
const gchar *interface_name,
|
||||
const gchar *signal_name,
|
||||
GVariant *parameters, gpointer user_data);
|
||||
void on_dbus_signal(const gchar *sender_name, const gchar *object_path,
|
||||
const gchar *interface_name, const gchar *signal_name,
|
||||
GVariant *parameters);
|
||||
static void on_name_vanished_static(GDBusConnection *connection,
|
||||
const gchar *name,
|
||||
gpointer user_data);
|
||||
const gchar *name, gpointer user_data);
|
||||
void on_name_vanished(const gchar *bus_name);
|
||||
|
||||
static Glib::RefPtr<Gdk::Paintable> parse_icon_pixmap(GVariant *variant);
|
||||
|
||||
Reference in New Issue
Block a user