diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-02-02 13:43:46 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-03-16 09:14:55 +0000 |
commit | 23fd4f7171ce0d509f59f42a9881de53f85644e7 (patch) | |
tree | b42a8185e9d66460e6936eb7bae0ec6e31fb3fdd /src/plugins/platformthemes | |
parent | f371b1cc8d0683e4e42194c8049f9523e58129f9 (diff) |
QGtk3Menu::showPopup(): fix target item selection
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 <mitya57@gmail.com>
Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/plugins/platformthemes')
-rw-r--r-- | src/plugins/platformthemes/gtk3/qgtk3menu.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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<QGtk3MenuItem *>(const_cast<QPlatformMenuItem *>(item))); - if (index != -1) - gtk_menu_set_active(GTK_MENU(m_menu), index); + const QGtk3MenuItem *menuItem = static_cast<const QGtk3MenuItem *>(item); + if (menuItem) + gtk_menu_shell_select_item(GTK_MENU_SHELL(m_menu), menuItem->handle()); m_targetPos = QPoint(targetRect.x(), targetRect.y() + targetRect.height()); |