fix(tray): pre-create dbusmenu for tray items
It seems that dbusmenu is not ready to display menu immediately and needs some time to sync data via DBus. Fixes LIBDBUSMENU-GLIB-CRITICAL: dbusmenu_menuitem_send_about_to_show: assertion 'DBUSMENU_IS_MENUITEM(mi)' failed. Also fixes initial render of the menu with layer shell popups support patch.pull/438/head
parent
642fd48af1
commit
01ad3d96d8
|
@ -65,7 +65,7 @@ class Item : public sigc::trackable {
|
||||||
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
|
||||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
|
||||||
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
static void onMenuDestroyed(Item* self, GObject* old_menu_pointer);
|
||||||
void makeMenu(GdkEventButton* const& ev);
|
void makeMenu();
|
||||||
bool handleClick(GdkEventButton* const& /*ev*/);
|
bool handleClick(GdkEventButton* const& /*ev*/);
|
||||||
|
|
||||||
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
|
||||||
|
|
|
@ -128,6 +128,7 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
||||||
}
|
}
|
||||||
} else if (name == "Menu") {
|
} else if (name == "Menu") {
|
||||||
menu = get_variant<std::string>(value);
|
menu = get_variant<std::string>(value);
|
||||||
|
makeMenu();
|
||||||
} else if (name == "ItemIsMenu") {
|
} else if (name == "ItemIsMenu") {
|
||||||
item_is_menu = get_variant<bool>(value);
|
item_is_menu = get_variant<bool>(value);
|
||||||
}
|
}
|
||||||
|
@ -319,7 +320,7 @@ void Item::onMenuDestroyed(Item* self, GObject* old_menu_pointer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::makeMenu(GdkEventButton* const& ev) {
|
void Item::makeMenu() {
|
||||||
if (gtk_menu == nullptr && !menu.empty()) {
|
if (gtk_menu == nullptr && !menu.empty()) {
|
||||||
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
||||||
if (dbus_menu != nullptr) {
|
if (dbus_menu != nullptr) {
|
||||||
|
@ -335,7 +336,7 @@ bool Item::handleClick(GdkEventButton* const& ev) {
|
||||||
auto parameters = Glib::VariantContainerBase::create_tuple(
|
auto parameters = Glib::VariantContainerBase::create_tuple(
|
||||||
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
||||||
if ((ev->button == 1 && item_is_menu) || ev->button == 3) {
|
if ((ev->button == 1 && item_is_menu) || ev->button == 3) {
|
||||||
makeMenu(ev);
|
makeMenu();
|
||||||
if (gtk_menu != nullptr) {
|
if (gtk_menu != nullptr) {
|
||||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||||
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
||||||
|
|
Loading…
Reference in New Issue