fix spotify tray icon
This commit is contained in:
@@ -31,6 +31,7 @@ class TrayIconWidget : public Gtk::Button
|
||||
Gtk::Box m_container;
|
||||
Gtk::Picture m_picture;
|
||||
Gtk::Image m_image;
|
||||
Glib::RefPtr<Gtk::GestureClick> m_primaryGesture;
|
||||
Glib::RefPtr<Gtk::GestureClick> m_secondaryGesture;
|
||||
Glib::RefPtr<Gtk::PopoverMenu> m_menuPopover;
|
||||
Glib::RefPtr<Gio::SimpleActionGroup> m_menuActions;
|
||||
@@ -40,7 +41,7 @@ class TrayIconWidget : public Gtk::Button
|
||||
double m_pendingX = 0.0;
|
||||
double m_pendingY = 0.0;
|
||||
|
||||
void on_primary_clicked();
|
||||
void on_primary_released(int n_press, double x, double y);
|
||||
void on_secondary_released(int n_press, double x, double y);
|
||||
bool ensure_menu();
|
||||
void on_menu_items_changed(guint position, guint removed, guint added);
|
||||
|
||||
@@ -83,7 +83,7 @@ void Bar::load_css()
|
||||
#clock-label { font-weight: bold; font-family: monospace; }
|
||||
.workspace-pill { background-color: rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 2px 8px; margin-right: 6px; }
|
||||
.workspace-pill:last-child { margin-right: 0; }
|
||||
.workspace-pill-focused { background-color: #82e9de; color: #111; }
|
||||
.workspace-pill-focused { background-color: rgba(255, 255, 255, 0.18); }
|
||||
.workspace-pill-active { background-color: rgba(255, 255, 255, 0.25); }
|
||||
.workspace-pill-urgent { background-color: #ff5555; color: #111; }
|
||||
.tray-icon { padding: 0; margin: 0; border: none; background: transparent; min-width: 0; min-height: 0; }
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <gdkmm/pixbuf.h>
|
||||
#include <gdkmm/texture.h>
|
||||
#include <gio/gdbusmenumodel.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -533,7 +534,10 @@ void TrayService::contextMenu(const std::string &id, int32_t x, int32_t y)
|
||||
|
||||
if (error)
|
||||
{
|
||||
std::cerr << "[TrayService] ContextMenu failed for " << id << ": " << error->message << std::endl;
|
||||
if (!(error->domain == G_DBUS_ERROR && error->code == G_DBUS_ERROR_UNKNOWN_METHOD))
|
||||
{
|
||||
std::cerr << "[TrayService] ContextMenu failed for " << id << ": " << error->message << std::endl;
|
||||
}
|
||||
g_error_free(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "widgets/tray.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdkmm/rectangle.h>
|
||||
#include <gio/gmenu.h>
|
||||
@@ -36,7 +35,10 @@ TrayIconWidget::TrayIconWidget(TrayService &service, std::string id)
|
||||
m_image.set_visible(true);
|
||||
set_child(m_container);
|
||||
|
||||
signal_clicked().connect(sigc::mem_fun(*this, &TrayIconWidget::on_primary_clicked));
|
||||
m_primaryGesture = Gtk::GestureClick::create();
|
||||
m_primaryGesture->set_button(GDK_BUTTON_PRIMARY);
|
||||
m_primaryGesture->signal_released().connect(sigc::mem_fun(*this, &TrayIconWidget::on_primary_released));
|
||||
add_controller(m_primaryGesture);
|
||||
|
||||
m_secondaryGesture = Gtk::GestureClick::create();
|
||||
m_secondaryGesture->set_button(GDK_BUTTON_SECONDARY);
|
||||
@@ -96,14 +98,14 @@ void TrayIconWidget::update(const TrayService::Item &item)
|
||||
set_sensitive(item.status != "Passive");
|
||||
}
|
||||
|
||||
void TrayIconWidget::on_primary_clicked()
|
||||
void TrayIconWidget::on_primary_released(int /*n_press*/, double x, double y)
|
||||
{
|
||||
m_service.activate(m_id, 0, 0);
|
||||
m_service.activate(m_id, -1, -1);
|
||||
}
|
||||
|
||||
void TrayIconWidget::on_secondary_released(int /*n_press*/, double x, double y)
|
||||
{
|
||||
m_service.contextMenu(m_id, static_cast<int32_t>(x), static_cast<int32_t>(y));
|
||||
m_service.contextMenu(m_id, -1, -1);
|
||||
|
||||
if (!ensure_menu())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user