From 23fd4f7171ce0d509f59f42a9881de53f85644e7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 2 Feb 2018 13:43:46 +0100 Subject: QGtk3Menu::showPopup(): fix target item selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a target item was passed, QGtk3Menu tried using gtk_menu_set_active() to select the target item. However, the function does not do what you'd imagine. Even the documentation states: This is used by the GtkComboBox and should not be used by anyone else. The correct function, gtk_menu_shell_select_item(), is in the GtkMenuShell "base class". Change-Id: Ia2c03f87bb97f618c041c03011af8c676108aea5 Reviewed-by: Dmitry Shachnev Reviewed-by: Lisandro Damián Nicanor Pérez Meyer Reviewed-by: Mitch Curtis --- src/plugins/platformthemes/gtk3/qgtk3menu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/plugins/platformthemes/gtk3') diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp index 1bbd463119..4f0bd9d9a0 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp @@ -426,9 +426,9 @@ QPoint QGtk3Menu::targetPos() const void QGtk3Menu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) { - int index = m_items.indexOf(static_cast(const_cast(item))); - if (index != -1) - gtk_menu_set_active(GTK_MENU(m_menu), index); + const QGtk3MenuItem *menuItem = static_cast(item); + if (menuItem) + gtk_menu_shell_select_item(GTK_MENU_SHELL(m_menu), menuItem->handle()); m_targetPos = QPoint(targetRect.x(), targetRect.y() + targetRect.height()); -- cgit v1.2.3