fix urgent window icons

This commit is contained in:
2025-12-17 23:34:12 +01:00
parent 11ccd55a52
commit 9b0a036925
11 changed files with 172 additions and 194 deletions

View File

@@ -1,2 +1,3 @@
IndentWidth: 4
ColumnLimit: 0
AlignConsecutiveAssignments: true

View File

@@ -10,26 +10,29 @@
class HyprlandService {
public:
static constexpr int kWorkspaceSlotCount = 7;
const char *kMonitorCommand = "hyprctl monitors -j";
const char *kWorkspaceCommand = "hyprctl workspaces -j";
const char *kClientsCommand = "hyprctl clients -j";
struct WindowState {
int hyprId = -1;
};
struct WorkspaceState {
int hyprId = -1;
int hyprId = -1;
int monitorId = -1;
bool active = false;
bool focused = false;
std::vector<int> urgentWindows;
bool active = false;
bool focused = false;
std::vector<std::string> urgentWindows;
std::string label;
};
struct Monitor {
std::map<int, WorkspaceState*> workspaceStates;
std::map<int, WorkspaceState *> workspaceStates;
std::string name;
int x = 0;
int y = 0;
int id = -1;
int x = 0;
int y = 0;
int id = -1;
int focusedWorkspaceId = -1;
};
@@ -38,7 +41,6 @@ class HyprlandService {
void start();
void on_hyprland_event(std::string event, std::string data);
void printMonitor(const Monitor &mon) const;
sigc::signal<void(std::string, std::string)> socketEventSignal;
@@ -46,24 +48,23 @@ class HyprlandService {
sigc::signal<void()> monitorStateChanged;
Monitor *getMonitorById(int id);
const Monitor *getMonitorById(int id) const;
Monitor *getMonitorByIndex(std::size_t index);
const Monitor *getMonitorByIndex(std::size_t index) const;
void switchToWorkspace(int workspaceId);
std::map<int, WorkspaceState*> getAllWorkspaces() const {
return this->workspaces;
std::map<int, WorkspaceState *> getAllWorkspaces() const {
return this->workspaces;
}
private:
int fd = -1;
std::map<int, Monitor> monitors;
std::map<int, WorkspaceState*> workspaces;
std::map<int, WorkspaceState *> workspaces;
std::string get_socket_path();
bool on_socket_read(Glib::IOCondition condition);
void parse_message(const std::string &line);
void refresh_monitors();
void refresh_workspaces();
void handle_urgent_window(std::string windowAddress);
void onUrgentEvent(std::string windowAddress);
void onActiveWindowEvent(std::string windowAddress);
};

View File

@@ -22,6 +22,10 @@ window {
border-radius: 5px;
}
.workspace-pill:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.workspace-pill-focused {
background-color: #ffffff;
color: #1e1e1e;
@@ -42,10 +46,6 @@ window {
margin-right: 0;
}
.workspace-pill:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.minimized {
background-color: rgba(50, 50, 50, 0.5);
}

View File

@@ -10,7 +10,7 @@ App::App() {
this->app = Gtk::Application::create("org.example.mybar");
app->signal_activate().connect([&]() {
auto display = Gdk::Display::get_default();
auto display = Gdk::Display::get_default();
auto monitors = display->get_monitors();
for (guint i = 0; i < monitors->get_n_items(); ++i) {

View File

@@ -89,7 +89,7 @@ void Bar::load_css() {
auto css_provider = Gtk::CssProvider::create();
std::string css_path = "resources/bar.css";
const char *home = std::getenv("HOME");
const char *home = std::getenv("HOME");
if (home) {
std::filesystem::path config_path =
std::filesystem::path(home) / ".config/bar/bar.css";

View File

@@ -14,16 +14,6 @@
#include "helpers/systemHelper.hpp"
namespace {
const char *kMonitorCommand = "hyprctl monitors -j";
const char *kWorkspaceCommand = "hyprctl workspaces -j";
const char *kClientsCommand = "hyprctl clients -j";
bool is_workspace_event(const std::string &event) {
return event.find("workspace") != std::string::npos;
}
} // namespace
HyprlandService::HyprlandService() = default;
HyprlandService::~HyprlandService() {
@@ -39,13 +29,19 @@ void HyprlandService::on_hyprland_event(std::string event, std::string data) {
}
if (event == "urgent") {
handle_urgent_window(data);
onUrgentEvent(data);
}
if (event == "workspace" || event == "focusedmon" || event == "monitoradded" ||
event == "monitorremoved" || event == "movewindow" || event == "activewindow") {
if (event == "workspace" || event == "movewindow") {
refresh_workspaces();
}
// use for
// event == "focusedmon"
if (event == "activewindowv2") {
onActiveWindowEvent(data);
}
}
void HyprlandService::start() {
@@ -126,7 +122,7 @@ void HyprlandService::parse_message(const std::string &line) {
}
std::string HyprlandService::get_socket_path() {
const char *sig = std::getenv("HYPRLAND_INSTANCE_SIGNATURE");
const char *sig = std::getenv("HYPRLAND_INSTANCE_SIGNATURE");
const char *runtime = std::getenv("XDG_RUNTIME_DIR");
if (!sig || !runtime) {
@@ -142,16 +138,14 @@ void HyprlandService::refresh_monitors() {
this->workspaces.clear();
std::string output = SystemHelper::get_command_output(kMonitorCommand);
auto monitorsJson = nlohmann::json::parse(output, nullptr, false);
auto monitorsJson = nlohmann::json::parse(output, nullptr, false);
for (const auto &monitorJson : monitorsJson) {
assert(monitorJson.is_object());
Monitor monitor;
monitor.id = monitorJson.value("id", -1);
monitor.id = monitorJson.value("id", -1);
monitor.name = monitorJson.value("name", "");
monitor.x = monitorJson.value("x", 0);
monitor.y = monitorJson.value("y", 0);
monitor.x = monitorJson.value("x", 0);
monitor.y = monitorJson.value("y", 0);
monitor.focusedWorkspaceId = monitorJson["activeWorkspace"].value("id", -1);
@@ -161,14 +155,14 @@ void HyprlandService::refresh_monitors() {
for (int slot = 1; slot <= HyprlandService::kWorkspaceSlotCount; ++slot) {
WorkspaceState wsState;
wsState.focused = false;
wsState.active = false;
wsState.label = std::to_string(slot);
wsState.focused = false;
wsState.active = false;
wsState.label = std::to_string(slot);
wsState.monitorId = monitor.id;
int id = slot + monitor.id * HyprlandService::kWorkspaceSlotCount;
wsState.hyprId = id;
this->workspaces[id] = new WorkspaceState(wsState);
int id = slot + monitor.id * HyprlandService::kWorkspaceSlotCount;
wsState.hyprId = id;
this->workspaces[id] = new WorkspaceState(wsState);
this->monitors[monitor.id].workspaceStates[slot] = this->workspaces[id];
}
}
@@ -182,77 +176,37 @@ void HyprlandService::refresh_monitors() {
* Used to Update the internal state for the Workspaces,
*/
void HyprlandService::refresh_workspaces() {
std::string output = SystemHelper::get_command_output(kWorkspaceCommand);
std::string output = SystemHelper::get_command_output(kWorkspaceCommand);
auto workspacesJson = nlohmann::json::parse(output, nullptr, false);
for (auto &[id, ws] : this->workspaces) {
ws->focused = false;
ws->active = false;
ws->active = false;
}
output = SystemHelper::get_command_output(kMonitorCommand);
output = SystemHelper::get_command_output(kMonitorCommand);
auto monitorsJson = nlohmann::json::parse(output, nullptr, false);
for (const auto &monitorJson : monitorsJson) {
const int monitorId = monitorJson.value("id", -1);
const int monitorId = monitorJson.value("id", -1);
const int focusedWorkspaceId = monitorJson["activeWorkspace"].value("id", -1);
auto monitorIt = this->monitors.find(monitorId);
monitorIt->second.focusedWorkspaceId = focusedWorkspaceId;
auto monitor = this->monitors[monitorId];
monitor.focusedWorkspaceId = focusedWorkspaceId;
}
for (const auto &workspaceJson : workspacesJson) {
const int workspaceId = workspaceJson.value("id", -1);
const int workspaceId = workspaceJson.value("id", -1);
std::map<int, WorkspaceState *>::iterator workspaceStateIt = this->workspaces.find(workspaceId);
WorkspaceState *workspaceState = workspaceStateIt->second;
WorkspaceState *workspaceState = workspaceStateIt->second;
workspaceState->focused = monitors
.at(workspaceState->monitorId)
.focusedWorkspaceId ==
workspaceId;
workspaceState->active = true;
this->workspaces[workspaceId] = workspaceState;
workspaceState->focused = monitors[workspaceState->monitorId].focusedWorkspaceId == workspaceId;
workspaceState->active = true;
}
workspaceStateChanged.emit();
}
HyprlandService::Monitor *HyprlandService::getMonitorById(int id) {
auto it = monitors.find(id);
if (it == monitors.end()) {
throw std::runtime_error("Monitor with ID " + std::to_string(id) +
" not found.");
}
return &it->second;
}
const HyprlandService::Monitor *HyprlandService::getMonitorById(int id) const {
auto it = monitors.find(id);
if (it == monitors.end()) {
throw std::runtime_error("Monitor with ID " + std::to_string(id) +
" not found.");
}
return &it->second;
}
HyprlandService::Monitor *HyprlandService::getMonitorByIndex(std::size_t index) {
if (index >= monitors.size()) {
throw std::runtime_error("Monitor index out of bounds: " + std::to_string(index));
}
auto it = monitors.begin();
std::advance(it, static_cast<long>(index));
return &it->second;
}
void HyprlandService::switchToWorkspace(int workspaceId) {
std::string cmd =
"hyprctl dispatch workspace " + std::to_string(workspaceId);
@@ -265,36 +219,51 @@ void HyprlandService::switchToWorkspace(int workspaceId) {
}
}
void HyprlandService::handle_urgent_window(std::string windowAddress) {
void HyprlandService::onUrgentEvent(std::string windowAddress) {
std::string output = SystemHelper::get_command_output(kClientsCommand);
auto clientsJson = nlohmann::json::parse(output, nullptr, false);
auto clientsJson = nlohmann::json::parse(output, nullptr, false);
for (const auto &clientJson : clientsJson) {
if (!clientJson.is_object()) {
continue;
}
const std::string addr = clientJson.value("address", "");
if (addr != windowAddress) {
continue;
if (addr == "0x" + windowAddress) {
int workspaceId = clientJson["workspace"].value("id", -1);
WorkspaceState *ws = this->workspaces[workspaceId];
// todo: maybee better method of access
if (ws) {
ws->urgentWindows.push_back(windowAddress);
workspaceStateChanged.emit();
}
break;
}
}
}
void HyprlandService::onActiveWindowEvent(std::string windowAddress) {
std::string output = SystemHelper::get_command_output(kClientsCommand);
auto clientsJson = nlohmann::json::parse(output, nullptr, false);
for (const auto &clientJson : clientsJson) {
const std::string addr = clientJson.value("address", "");
if (addr == "0x" + windowAddress) {
int workspaceId = clientJson["workspace"]["id"];
WorkspaceState *ws = this->workspaces[workspaceId];
if (ws) {
auto it = std::find(ws->urgentWindows.begin(), ws->urgentWindows.end(), windowAddress);
if (it != ws->urgentWindows.end()) {
ws->urgentWindows.erase(it);
workspaceStateChanged.emit();
}
break;
}
}
const int workspaceId = clientJson.value("workspace", -1);
if (workspaceId < 0) {
continue;
}
auto workspaceIt = this->workspaces.find(workspaceId);
if (workspaceIt == this->workspaces.end()) {
continue;
}
WorkspaceState *wsState = workspaceIt->second;
wsState->urgentWindows.push_back(1);
break;
}
workspaceStateChanged.emit();
}
void HyprlandService::printMonitor(const Monitor &mon) const {
@@ -335,3 +304,24 @@ void HyprlandService::printMonitor(const Monitor &mon) const {
std::cout << "====================\n";
}
HyprlandService::Monitor *HyprlandService::getMonitorById(int id) {
auto it = monitors.find(id);
if (it == monitors.end()) {
throw std::runtime_error("Monitor with ID " + std::to_string(id) +
" not found.");
}
return &it->second;
}
HyprlandService::Monitor *HyprlandService::getMonitorByIndex(std::size_t index) {
if (index >= monitors.size()) {
throw std::runtime_error("Monitor index out of bounds: " + std::to_string(index));
}
auto it = monitors.begin();
std::advance(it, static_cast<long>(index));
return &it->second;
}

View File

@@ -15,12 +15,12 @@
#include <vector>
namespace {
constexpr const char *kWatcherBusName = "org.kde.StatusNotifierWatcher";
constexpr const char *kWatcherObjectPath = "/StatusNotifierWatcher";
constexpr const char *kWatcherInterface = "org.kde.StatusNotifierWatcher";
constexpr const char *kItemInterface = "org.kde.StatusNotifierItem";
constexpr const char *kWatcherBusName = "org.kde.StatusNotifierWatcher";
constexpr const char *kWatcherObjectPath = "/StatusNotifierWatcher";
constexpr const char *kWatcherInterface = "org.kde.StatusNotifierWatcher";
constexpr const char *kItemInterface = "org.kde.StatusNotifierItem";
constexpr const char *kDBusPropertiesIface = "org.freedesktop.DBus.Properties";
constexpr const char *kDBusMenuInterface = "com.canonical.dbusmenu";
constexpr const char *kDBusMenuInterface = "com.canonical.dbusmenu";
const char *kWatcherIntrospection =
R"(<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
@@ -55,25 +55,25 @@ ParsedService parse_service_identifier(const Glib::ustring &sender,
ParsedService parsed;
if (service.empty()) {
parsed.busName = sender;
parsed.busName = sender;
parsed.objectPath = "/StatusNotifierItem";
return parsed;
}
if (service.front() == '/') {
parsed.busName = sender;
parsed.busName = sender;
parsed.objectPath = service;
return parsed;
}
const auto slash = service.find('/');
if (slash == std::string::npos) {
parsed.busName = service;
parsed.busName = service;
parsed.objectPath = "/StatusNotifierItem";
return parsed;
}
parsed.busName = service.substr(0, slash);
parsed.busName = service.substr(0, slash);
parsed.objectPath = service.substr(slash);
if (parsed.busName.empty()) {
@@ -90,8 +90,8 @@ ParsedService parse_service_identifier(const Glib::ustring &sender,
GVariant *create_property_list_variant() {
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
const char *properties[] = {"label", "label-markup", "enabled",
"visible", "children-display", "type",
const char *properties[] = {"label", "label-markup", "enabled",
"visible", "children-display", "type",
"toggle-type", "toggle-state"};
for (const char *prop : properties) {
g_variant_builder_add(&builder, "s", prop);
@@ -106,7 +106,7 @@ void call_about_to_show(const Glib::RefPtr<Gio::DBus::Connection> &connection,
return;
}
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), busName.c_str(), menuPath.c_str(),
kDBusMenuInterface, "AboutToShow", g_variant_new("(i)", id), nullptr,
@@ -137,7 +137,7 @@ GVariant *call_get_layout(const Glib::RefPtr<Gio::DBus::Connection> &connection,
GVariant *params = g_variant_new("(ii@as)", 0, -1, properties);
g_variant_ref_sink(properties);
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), busName.c_str(), menuPath.c_str(),
kDBusMenuInterface, "GetLayout", params, nullptr,
@@ -174,15 +174,15 @@ void parse_menu_node(GVariant *tuple, TrayService::MenuNode &outNode) {
return;
}
int id = 0;
GVariant *propsVariant = nullptr;
int id = 0;
GVariant *propsVariant = nullptr;
GVariant *childrenVariant = nullptr;
g_variant_get(tuple, "(i@a{sv}@av)", &id, &propsVariant, &childrenVariant);
outNode.id = id;
outNode.enabled = true;
outNode.visible = true;
outNode.id = id;
outNode.enabled = true;
outNode.visible = true;
outNode.separator = false;
outNode.label.clear();
@@ -190,7 +190,7 @@ void parse_menu_node(GVariant *tuple, TrayService::MenuNode &outNode) {
GVariantIter iter;
g_variant_iter_init(&iter, propsVariant);
const gchar *key = nullptr;
GVariant *value = nullptr;
GVariant *value = nullptr;
while (g_variant_iter_next(&iter, "{sv}", &key, &value)) {
if (!key || !value) {
@@ -214,13 +214,13 @@ void parse_menu_node(GVariant *tuple, TrayService::MenuNode &outNode) {
if (std::strcmp(key, "label") == 0) {
if (g_variant_is_of_type(unboxed, G_VARIANT_TYPE_STRING)) {
const gchar *str = g_variant_get_string(unboxed, nullptr);
outNode.label = str ? str : "";
outNode.label = str ? str : "";
}
} else if (std::strcmp(key, "label-markup") == 0 &&
outNode.label.empty()) {
if (g_variant_is_of_type(unboxed, G_VARIANT_TYPE_STRING)) {
const gchar *str = g_variant_get_string(unboxed, nullptr);
outNode.label = str ? str : "";
outNode.label = str ? str : "";
}
} else if (std::strcmp(key, "enabled") == 0) {
if (g_variant_is_of_type(unboxed, G_VARIANT_TYPE_BOOLEAN)) {
@@ -362,7 +362,7 @@ void TrayService::activate(const std::string &id, int32_t x, int32_t y) {
return;
}
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), it->second->publicData.busName.c_str(),
it->second->publicData.objectPath.c_str(), kItemInterface, "Activate",
@@ -387,7 +387,7 @@ void TrayService::secondaryActivate(const std::string &id, int32_t x,
return;
}
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), it->second->publicData.busName.c_str(),
it->second->publicData.objectPath.c_str(), kItemInterface,
@@ -411,7 +411,7 @@ void TrayService::contextMenu(const std::string &id, int32_t x, int32_t y) {
return;
}
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), it->second->publicData.busName.c_str(),
it->second->publicData.objectPath.c_str(), kItemInterface,
@@ -566,7 +566,7 @@ bool TrayService::activate_menu_item(const std::string &id, int itemId) {
"(isvu)", itemId, "clicked", g_variant_new_variant(emptyData),
static_cast<guint32>(g_get_monotonic_time() / 1000));
GError *error = nullptr;
GError *error = nullptr;
GVariant *result = g_dbus_connection_call_sync(
connection->gobj(), item.publicData.busName.c_str(),
item.publicData.menuPath.c_str(), kDBusMenuInterface, "Event", params,
@@ -723,16 +723,16 @@ void TrayService::register_item(const Glib::ustring &sender,
}
const std::string id = parsed.busName + parsed.objectPath;
auto existing = items.find(id);
auto existing = items.find(id);
if (existing != items.end()) {
refresh_item(*existing->second);
itemUpdatedSignal.emit(existing->second->publicData);
return;
}
auto item = std::make_unique<TrackedItem>();
item->publicData.id = id;
item->publicData.busName = parsed.busName;
auto item = std::make_unique<TrackedItem>();
item->publicData.id = id;
item->publicData.busName = parsed.busName;
item->publicData.objectPath = parsed.objectPath;
refresh_item(*item);
@@ -789,7 +789,7 @@ void TrayService::refresh_item(TrackedItem &item) {
return;
}
GError *error = nullptr;
GError *error = nullptr;
GVariant *reply = g_dbus_connection_call_sync(
connection->gobj(), item.publicData.busName.c_str(),
item.publicData.objectPath.c_str(), kDBusPropertiesIface, "GetAll",
@@ -816,7 +816,7 @@ void TrayService::refresh_item(TrackedItem &item) {
g_variant_iter_init(&iter, dictVariant);
const gchar *key = nullptr;
GVariant *value = nullptr;
GVariant *value = nullptr;
Glib::RefPtr<Gdk::Paintable> iconTexture;
Glib::RefPtr<Gdk::Paintable> attentionTexture;
@@ -836,23 +836,23 @@ void TrayService::refresh_item(TrackedItem &item) {
if (std::strcmp(key, "Title") == 0) {
const gchar *str = g_variant_get_string(value, nullptr);
title = str ? str : "";
title = str ? str : "";
} else if (std::strcmp(key, "Status") == 0) {
const gchar *str = g_variant_get_string(value, nullptr);
status = str ? str : "";
status = str ? str : "";
} else if (std::strcmp(key, "Menu") == 0) {
if (g_variant_is_of_type(value, G_VARIANT_TYPE_OBJECT_PATH)) {
const gchar *str = g_variant_get_string(value, nullptr);
menuPath = str ? str : "";
menuPath = str ? str : "";
} else {
const gchar *str = g_variant_get_string(value, nullptr);
menuPath = str ? str : "";
menuPath = str ? str : "";
}
} else if (std::strcmp(key, "IconName") == 0) {
const gchar *str = g_variant_get_string(value, nullptr);
iconName = str ? str : "";
iconName = str ? str : "";
} else if (std::strcmp(key, "AttentionIconName") == 0) {
const gchar *str = g_variant_get_string(value, nullptr);
const gchar *str = g_variant_get_string(value, nullptr);
attentionIconName = str ? str : "";
} else if (std::strcmp(key, "IconPixmap") == 0) {
iconTexture = parse_icon_pixmap(value);
@@ -864,10 +864,10 @@ void TrayService::refresh_item(TrackedItem &item) {
}
g_variant_unref(dictVariant);
const bool menuPathChanged = (item.publicData.menuPath != menuPath);
item.publicData.title = title;
item.publicData.status = status;
item.publicData.menuPath = menuPath;
const bool menuPathChanged = (item.publicData.menuPath != menuPath);
item.publicData.title = title;
item.publicData.status = status;
item.publicData.menuPath = menuPath;
item.publicData.menuAvailable = !menuPath.empty();
if (menuPathChanged || !item.publicData.menuAvailable) {
@@ -1029,7 +1029,7 @@ Glib::RefPtr<Gdk::Paintable> TrayService::parse_icon_pixmap(GVariant *variant) {
return {};
}
int32_t width = 0;
int32_t width = 0;
int32_t height = 0;
g_variant_get_child(entry, 0, "i", &width);
g_variant_get_child(entry, 1, "i", &height);
@@ -1045,7 +1045,7 @@ Glib::RefPtr<Gdk::Paintable> TrayService::parse_icon_pixmap(GVariant *variant) {
return {};
}
gsize rawLength = 0;
gsize rawLength = 0;
const guint8 *rawBytes = static_cast<const guint8 *>(
g_variant_get_fixed_array(bytesVariant, &rawLength, sizeof(guint8)));
if (!rawBytes || rawLength < static_cast<gsize>(width * height * 4)) {
@@ -1062,16 +1062,16 @@ Glib::RefPtr<Gdk::Paintable> TrayService::parse_icon_pixmap(GVariant *variant) {
const guint32 *pixels = reinterpret_cast<const guint32 *>(rawBytes);
for (std::size_t idx = 0; idx < pixelCount; ++idx) {
const guint32 pixel = pixels[idx];
const guint8 a = static_cast<guint8>((pixel >> 24) & 0xFF);
const guint8 r = static_cast<guint8>((pixel >> 16) & 0xFF);
const guint8 g = static_cast<guint8>((pixel >> 8) & 0xFF);
const guint8 b = static_cast<guint8>(pixel & 0xFF);
const guint8 a = static_cast<guint8>((pixel >> 24) & 0xFF);
const guint8 r = static_cast<guint8>((pixel >> 16) & 0xFF);
const guint8 g = static_cast<guint8>((pixel >> 8) & 0xFF);
const guint8 b = static_cast<guint8>(pixel & 0xFF);
const std::size_t base = idx * 4;
rgba[base + 0] = r;
rgba[base + 1] = g;
rgba[base + 2] = b;
rgba[base + 3] = a;
rgba[base + 0] = r;
rgba[base + 1] = g;
rgba[base + 2] = b;
rgba[base + 3] = a;
}
auto pixbuf =
@@ -1082,9 +1082,9 @@ Glib::RefPtr<Gdk::Paintable> TrayService::parse_icon_pixmap(GVariant *variant) {
return {};
}
auto *dest = pixbuf->get_pixels();
auto *dest = pixbuf->get_pixels();
const int destRowstride = pixbuf->get_rowstride();
const int srcRowstride = width * 4;
const int srcRowstride = width * 4;
for (int y = 0; y < height; ++y) {
std::memcpy(dest + y * destRowstride,

View File

@@ -99,8 +99,8 @@ void TrayIconWidget::on_secondary_released(int /*n_press*/, double x,
return;
}
pendingX = x;
pendingY = y;
pendingX = x;
pendingY = y;
menuPopupPending = true;
try_popup();
}
@@ -125,7 +125,7 @@ bool TrayIconWidget::ensure_menu() {
const auto &layout = *layoutOpt;
auto menu = Gio::Menu::create();
auto menu = Gio::Menu::create();
auto actions = Gio::SimpleActionGroup::create();
populate_menu_items(layout.children, menu, actions);
@@ -138,7 +138,7 @@ bool TrayIconWidget::ensure_menu() {
return false;
}
menuModel = menu;
menuModel = menu;
menuActions = actions;
if (!menuPopover) {

View File

@@ -52,7 +52,7 @@ void VolumeWidget::update() {
std::regex r_number(R"((\d+(?:\.\d+)?))");
std::string text = out;
int percent = -1;
int percent = -1;
if (std::regex_search(text, m, r_percent)) {
percent = static_cast<int>(std::round(std::stod(m[1].str())));

View File

@@ -54,7 +54,7 @@ void WorkspaceIndicator::on_workspace_update() {
void WorkspaceIndicator::on_monitor_update() { rebuild(); }
void WorkspaceIndicator::refreshLabel(Gtk::Label *label, HyprlandService::WorkspaceState state) {
void WorkspaceIndicator::refreshLabel(Gtk::Label *label, HyprlandService::WorkspaceState state) {
label->remove_css_class("workspace-pill-active");
label->remove_css_class("workspace-pill-focused");
label->remove_css_class("workspace-pill-urgent");
@@ -82,7 +82,6 @@ void WorkspaceIndicator::rebuild() {
HyprlandService::Monitor *mon = service.getMonitorById(this->monitorId);
for (auto [id, workspaceState] : mon->workspaceStates) {
assert(id > 0);
Gtk::Label *label = workspaceLabels[id];
this->refreshLabel(label, *workspaceState);
}

View File

@@ -1,13 +0,0 @@
#include <gio/gdbusmenumodel.h>
#include <gio/gio.h>
#include <giomm/menumodel.h>
int main() {
GDBusMenuModel *dbusModel = g_dbus_menu_model_get_for_bus_sync(
G_BUS_TYPE_SESSION, G_DBUS_MENU_MODEL_FLAGS_NONE,
"org.freedesktop.Notifications", "/Menu", nullptr, nullptr);
if (!dbusModel)
return 0;
Glib::RefPtr<Gio::MenuModel> model = Glib::wrap(G_MENU_MODEL(dbusModel));
return model ? 0 : 1;
}