[gtk/BUG_tooltip_blocks_combo_GTK3] tooltips: hide tooltips before showing popups
- From: Nelson Benítez León <nbenitez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/BUG_tooltip_blocks_combo_GTK3] tooltips: hide tooltips before showing popups
- Date: Wed, 4 Sep 2019 00:04:16 +0000 (UTC)
commit ce7e99ca5e9930a37bb3dd2e642ce41b2fa61fc3
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Tue Sep 3 18:37:31 2019 -0400
tooltips: hide tooltips before showing popups
because if there's a tooltip visible then popups fail to show
with the following warning:
"Gdk-WARNING **: Tried to map a popup with a non-top most parent"
This bug affect popups of the form:
1) popups from gtk_menu_popup_{at_widget|at_rect|for_device}()
This can be reproduce with a normal GtkComboBox that has a
tooltip attached (eg. via GtkBuilder 'tooltip_text' attribute).
Also see GtkLabel reproducer from gtk3-demo mentioned in #1785
2) custom popups created with gtk_window_new (GTK_WINDOW_POPUP)
A reproducer that shows this case is a GtkComboBox with
the property 'appears-as-list'[1] set to TRUE (default is FALSE).
Fixes issue #1785
[1] https://developer.gnome.org/gtk3/stable/GtkComboBox.html#GtkComboBox--s-appears-as-list
gtk/gtkcombobox.c | 2 ++
gtk/gtkmenu.c | 2 ++
gtk/gtktooltip.c | 16 ++++++++++++++++
gtk/gtktooltipprivate.h | 1 +
4 files changed, 21 insertions(+)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 93f912b969..ef4996c027 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -44,6 +44,7 @@
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
+#include "gtktooltipprivate.h"
#include "gtkcomboboxprivate.h"
#include <gobject/gvaluecollector.h>
@@ -2315,6 +2316,7 @@ gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
return;
}
+ _gtk_tooltip_hide (GTK_WIDGET (combo_box));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
if (GTK_IS_WINDOW (toplevel))
{
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index e8928ec843..1be93d2b5e 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -133,6 +133,7 @@
#include "gtkcssnodeprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
+#include "gtktooltipprivate.h"
#include "deprecated/gtktearoffmenuitem.h"
@@ -1824,6 +1825,7 @@ gtk_menu_popup_internal (GtkMenu *menu,
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (device == NULL || GDK_IS_DEVICE (device));
+ _gtk_tooltip_hide_in_display (gtk_widget_get_display (GTK_WIDGET (menu)));
display = gtk_widget_get_display (GTK_WIDGET (menu));
if (device == NULL)
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index e5fc5dbdaa..f0f4e8b547 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -1280,6 +1280,22 @@ _gtk_tooltip_hide (GtkWidget *widget)
gtk_tooltip_hide_tooltip (tooltip);
}
+void
+_gtk_tooltip_hide_in_display (GdkDisplay *display)
+{
+ GtkTooltip *tooltip;
+
+ if (!display)
+ return;
+
+ tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
+
+ if (!tooltip || !GTK_TOOLTIP_VISIBLE (tooltip))
+ return;
+
+ gtk_tooltip_hide_tooltip (tooltip);
+}
+
static gboolean
tooltips_enabled (GdkEvent *event)
{
diff --git a/gtk/gtktooltipprivate.h b/gtk/gtktooltipprivate.h
index 427015e007..41e2bc1aef 100644
--- a/gtk/gtktooltipprivate.h
+++ b/gtk/gtktooltipprivate.h
@@ -36,6 +36,7 @@ void _gtk_tooltip_focus_out (GtkWidget *widget);
void _gtk_tooltip_toggle_keyboard_mode (GtkWidget *widget);
void _gtk_tooltip_handle_event (GdkEvent *event);
void _gtk_tooltip_hide (GtkWidget *widget);
+void _gtk_tooltip_hide_in_display (GdkDisplay *display);
GtkWidget * _gtk_widget_find_at_coords (GdkWindow *window,
gint window_x,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]