2007-02-06 10:25:21 +00:00
|
|
|
|
/* gtktooltip.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006-2007 Imendio AB
|
|
|
|
|
* Contact: Kristian Rietveld <kris@imendio.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2010-04-15 11:03:43 +00:00
|
|
|
|
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtktooltip.h"
|
2014-10-20 02:51:21 +00:00
|
|
|
|
#include "gtktooltipprivate.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
2010-04-15 11:03:43 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
#include "gtkwindow.h"
|
|
|
|
|
#include "gtkmain.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtksettings.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2015-11-08 15:46:23 +00:00
|
|
|
|
#include "gtktooltipwindowprivate.h"
|
2011-04-26 22:25:48 +00:00
|
|
|
|
#include "gtkwindowprivate.h"
|
2016-05-08 13:52:56 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2020-06-07 12:48:14 +00:00
|
|
|
|
#include "gtknative.h"
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2010-10-02 22:58:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtktooltip
|
|
|
|
|
* @Short_description: Add tips to your widgets
|
|
|
|
|
* @Title: GtkTooltip
|
|
|
|
|
*
|
|
|
|
|
* Basic tooltips can be realized simply by using gtk_widget_set_tooltip_text()
|
|
|
|
|
* or gtk_widget_set_tooltip_markup() without any explicit tooltip object.
|
|
|
|
|
*
|
|
|
|
|
* When you need a tooltip with a little more fancy contents, like adding an
|
|
|
|
|
* image, or you want the tooltip to have different contents per #GtkTreeView
|
|
|
|
|
* row or cell, you will have to do a little more work:
|
2015-10-28 15:49:00 +00:00
|
|
|
|
*
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* - Set the #GtkWidget:has-tooltip property to %TRUE, this will make GTK
|
2014-02-02 06:07:39 +00:00
|
|
|
|
* monitor the widget for motion and related events which are needed to
|
|
|
|
|
* determine when and where to show a tooltip.
|
|
|
|
|
*
|
|
|
|
|
* - Connect to the #GtkWidget::query-tooltip signal. This signal will be
|
|
|
|
|
* emitted when a tooltip is supposed to be shown. One of the arguments passed
|
|
|
|
|
* to the signal handler is a GtkTooltip object. This is the object that we
|
|
|
|
|
* are about to display as a tooltip, and can be manipulated in your callback
|
|
|
|
|
* using functions like gtk_tooltip_set_icon(). There are functions for setting
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* the tooltip’s markup, setting an image from a named icon, or even putting in
|
2014-02-02 06:07:39 +00:00
|
|
|
|
* a custom widget.
|
|
|
|
|
*
|
|
|
|
|
* Return %TRUE from your query-tooltip handler. This causes the tooltip to be
|
|
|
|
|
* show. If you return %FALSE, it will not be shown.
|
2010-10-02 22:58:38 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2013-07-08 17:13:23 +00:00
|
|
|
|
#define HOVER_TIMEOUT 500
|
|
|
|
|
#define BROWSE_TIMEOUT 60
|
|
|
|
|
#define BROWSE_DISABLE_TIMEOUT 500
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
#define GTK_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOOLTIP, GtkTooltipClass))
|
|
|
|
|
#define GTK_IS_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOOLTIP))
|
|
|
|
|
#define GTK_TOOLTIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOOLTIP, GtkTooltipClass))
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
/* We keep a single GtkTooltip object per display. The tooltip object
|
|
|
|
|
* owns a GtkTooltipWindow widget, which is using a popup surface, similar
|
|
|
|
|
* to what a GtkPopover does. It gets reparented to the right native widget
|
|
|
|
|
* whenever a tooltip is to be shown. The tooltip object keeps a weak
|
|
|
|
|
* ref on the native in order to remove the tooltip window when the
|
|
|
|
|
* native goes away.
|
|
|
|
|
*/
|
2007-02-06 10:25:21 +00:00
|
|
|
|
typedef struct _GtkTooltipClass GtkTooltipClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkTooltip
|
|
|
|
|
{
|
|
|
|
|
GObject parent_instance;
|
|
|
|
|
|
|
|
|
|
GtkWidget *window;
|
|
|
|
|
|
|
|
|
|
GtkWidget *tooltip_widget;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
GtkWidget *native;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
guint timeout_id;
|
|
|
|
|
guint browse_mode_timeout_id;
|
|
|
|
|
|
2007-07-13 14:25:21 +00:00
|
|
|
|
GdkRectangle tip_area;
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
guint browse_mode_enabled : 1;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
guint tip_area_set : 1;
|
2008-05-28 14:00:31 +00:00
|
|
|
|
guint custom_was_reset : 1;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkTooltipClass
|
|
|
|
|
{
|
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
#define GTK_TOOLTIP_VISIBLE(tooltip) ((tooltip)->window && gtk_widget_get_visible (GTK_WIDGET((tooltip)->window)))
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2009-08-03 19:39:34 +00:00
|
|
|
|
static void gtk_tooltip_dispose (GObject *object);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
static void gtk_tooltip_window_hide (GtkWidget *widget,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_tooltip_display_closed (GdkDisplay *display,
|
|
|
|
|
gboolean was_error,
|
|
|
|
|
GtkTooltip *tooltip);
|
2019-12-29 02:04:19 +00:00
|
|
|
|
static void gtk_tooltip_set_surface (GtkTooltip *tooltip,
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-01-18 07:48:07 +00:00
|
|
|
|
static void gtk_tooltip_handle_event_internal (GdkEventType event_type,
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface,
|
2019-01-18 07:48:07 +00:00
|
|
|
|
GtkWidget *target_widget,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy);
|
2016-06-06 01:47:16 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
static GQuark quark_current_tooltip;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_class_init (GtkTooltipClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
quark_current_tooltip = g_quark_from_static_string ("gdk-display-current-tooltip");
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
2009-08-03 19:39:34 +00:00
|
|
|
|
object_class->dispose = gtk_tooltip_dispose;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_init (GtkTooltip *tooltip)
|
|
|
|
|
{
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
tooltip->browse_mode_timeout_id = 0;
|
|
|
|
|
|
|
|
|
|
tooltip->browse_mode_enabled = FALSE;
|
|
|
|
|
|
|
|
|
|
tooltip->tooltip_widget = NULL;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
tooltip->native = NULL;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
tooltip->window = gtk_tooltip_window_new ();
|
2019-12-29 02:04:19 +00:00
|
|
|
|
g_object_ref_sink (tooltip->window);
|
2015-11-08 15:46:23 +00:00
|
|
|
|
g_signal_connect (tooltip->window, "hide",
|
|
|
|
|
G_CALLBACK (gtk_tooltip_window_hide),
|
|
|
|
|
tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2009-08-03 19:39:34 +00:00
|
|
|
|
gtk_tooltip_dispose (GObject *object)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
GtkTooltip *tooltip = GTK_TOOLTIP (object);
|
|
|
|
|
|
|
|
|
|
if (tooltip->timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->timeout_id);
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tooltip->browse_mode_timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->browse_mode_timeout_id);
|
|
|
|
|
tooltip->browse_mode_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-25 02:01:04 +00:00
|
|
|
|
gtk_tooltip_set_custom (tooltip, NULL);
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_set_surface (tooltip, NULL);
|
2007-12-17 15:33:45 +00:00
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
if (tooltip->window)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (tooltip->window);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (display,
|
|
|
|
|
gtk_tooltip_display_closed,
|
|
|
|
|
tooltip);
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_window_set_relative_to (GTK_TOOLTIP_WINDOW (tooltip->window), NULL);
|
|
|
|
|
g_clear_object (&tooltip->window);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
2007-02-06 12:11:33 +00:00
|
|
|
|
|
2009-08-03 19:39:34 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_tooltip_parent_class)->dispose (object);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* public API */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_markup:
|
2007-05-26 20:29:26 +00:00
|
|
|
|
* @tooltip: a #GtkTooltip
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* @markup: (allow-none): a markup string (see [Pango markup format][PangoMarkupFormat]) or %NULL
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*
|
2007-05-26 20:29:26 +00:00
|
|
|
|
* Sets the text of the tooltip to be @markup, which is marked up
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* with the [Pango text markup language][PangoMarkupFormat].
|
2007-02-06 10:25:21 +00:00
|
|
|
|
* If @markup is %NULL, the label will be hidden.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_set_markup (GtkTooltip *tooltip,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *markup)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
gtk_tooltip_window_set_label_markup (GTK_TOOLTIP_WINDOW (tooltip->window), markup);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-15 18:24:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_text:
|
|
|
|
|
* @tooltip: a #GtkTooltip
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @text: (allow-none): a text string or %NULL
|
2007-06-15 18:24:55 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the text of the tooltip to be @text. If @text is %NULL, the label
|
|
|
|
|
* will be hidden. See also gtk_tooltip_set_markup().
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_set_text (GtkTooltip *tooltip,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text)
|
2007-06-15 18:24:55 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
gtk_tooltip_window_set_label_text (GTK_TOOLTIP_WINDOW (tooltip->window), text);
|
2007-06-15 18:24:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_icon:
|
|
|
|
|
* @tooltip: a #GtkTooltip
|
2018-03-16 02:38:50 +00:00
|
|
|
|
* @paintable: (allow-none): a #GdkPaintable, or %NULL
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the icon of the tooltip (which is in front of the text) to be
|
2018-03-16 02:38:50 +00:00
|
|
|
|
* @paintable. If @paintable is %NULL, the image will be hidden.
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
2018-03-16 02:38:50 +00:00
|
|
|
|
gtk_tooltip_set_icon (GtkTooltip *tooltip,
|
|
|
|
|
GdkPaintable *paintable)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
2018-03-16 02:38:50 +00:00
|
|
|
|
g_return_if_fail (paintable == NULL || GDK_IS_PAINTABLE (paintable));
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2018-03-16 02:38:50 +00:00
|
|
|
|
gtk_tooltip_window_set_image_icon (GTK_TOOLTIP_WINDOW (tooltip->window), paintable);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-14 05:00:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_icon_from_icon_name:
|
|
|
|
|
* @tooltip: a #GtkTooltip
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @icon_name: (allow-none): an icon name, or %NULL
|
2007-12-14 05:00:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the icon of the tooltip (which is in front of the text) to be
|
|
|
|
|
* the icon indicated by @icon_name with the size indicated
|
|
|
|
|
* by @size. If @icon_name is %NULL, the image will be hidden.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2009-10-13 12:53:09 +00:00
|
|
|
|
gtk_tooltip_set_icon_from_icon_name (GtkTooltip *tooltip,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *icon_name)
|
2007-12-14 05:00:51 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
gtk_tooltip_window_set_image_icon_from_name (GTK_TOOLTIP_WINDOW (tooltip->window),
|
2017-01-20 01:02:44 +00:00
|
|
|
|
icon_name);
|
2009-10-13 12:53:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-01 21:12:43 +00:00
|
|
|
|
* gtk_tooltip_set_icon_from_gicon:
|
2009-10-13 12:53:09 +00:00
|
|
|
|
* @tooltip: a #GtkTooltip
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @gicon: (allow-none): a #GIcon representing the icon, or %NULL
|
2009-11-01 21:12:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the icon of the tooltip (which is in front of the text)
|
|
|
|
|
* to be the icon indicated by @gicon with the size indicated
|
|
|
|
|
* by @size. If @gicon is %NULL, the image will be hidden.
|
2009-10-13 12:53:09 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_set_icon_from_gicon (GtkTooltip *tooltip,
|
2017-01-20 01:02:44 +00:00
|
|
|
|
GIcon *gicon)
|
2009-10-13 12:53:09 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
gtk_tooltip_window_set_image_icon_from_gicon (GTK_TOOLTIP_WINDOW (tooltip->window),
|
2017-01-20 01:02:44 +00:00
|
|
|
|
gicon);
|
2007-12-14 05:00:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_custom:
|
2007-05-26 20:29:26 +00:00
|
|
|
|
* @tooltip: a #GtkTooltip
|
2010-02-19 16:53:17 +00:00
|
|
|
|
* @custom_widget: (allow-none): a #GtkWidget, or %NULL to unset the old custom widget.
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*
|
2009-05-25 02:01:04 +00:00
|
|
|
|
* Replaces the widget packed into the tooltip with
|
|
|
|
|
* @custom_widget. @custom_widget does not get destroyed when the tooltip goes
|
|
|
|
|
* away.
|
2007-05-26 20:29:26 +00:00
|
|
|
|
* By default a box with a #GtkImage and #GtkLabel is embedded in
|
|
|
|
|
* the tooltip, which can be configured using gtk_tooltip_set_markup()
|
|
|
|
|
* and gtk_tooltip_set_icon().
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_set_custom (GtkTooltip *tooltip,
|
|
|
|
|
GtkWidget *custom_widget)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
2015-11-08 15:46:23 +00:00
|
|
|
|
g_return_if_fail (custom_widget == NULL || GTK_IS_WIDGET (custom_widget));
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2008-05-28 14:00:31 +00:00
|
|
|
|
/* The custom widget has been updated from the query-tooltip
|
|
|
|
|
* callback, so we do not want to reset the custom widget later on.
|
|
|
|
|
*/
|
|
|
|
|
tooltip->custom_was_reset = TRUE;
|
|
|
|
|
|
2015-11-08 15:46:23 +00:00
|
|
|
|
gtk_tooltip_window_set_custom_widget (GTK_TOOLTIP_WINDOW (tooltip->window), custom_widget);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-07-13 14:25:21 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_tooltip_set_tip_area:
|
|
|
|
|
* @tooltip: a #GtkTooltip
|
|
|
|
|
* @rect: a #GdkRectangle
|
|
|
|
|
*
|
|
|
|
|
* Sets the area of the widget, where the contents of this tooltip apply,
|
|
|
|
|
* to be @rect (in widget coordinates). This is especially useful for
|
|
|
|
|
* properly setting tooltips on #GtkTreeView rows and cells, #GtkIconViews,
|
|
|
|
|
* etc.
|
|
|
|
|
*
|
|
|
|
|
* For setting tooltips on #GtkTreeView, please refer to the convenience
|
|
|
|
|
* functions for this: gtk_tree_view_set_tooltip_row() and
|
|
|
|
|
* gtk_tree_view_set_tooltip_cell().
|
|
|
|
|
*/
|
|
|
|
|
void
|
2008-01-25 09:30:40 +00:00
|
|
|
|
gtk_tooltip_set_tip_area (GtkTooltip *tooltip,
|
|
|
|
|
const GdkRectangle *rect)
|
2007-07-13 14:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
|
|
|
|
|
|
|
|
|
|
if (!rect)
|
|
|
|
|
tooltip->tip_area_set = FALSE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tooltip->tip_area_set = TRUE;
|
|
|
|
|
tooltip->tip_area = *rect;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 01:17:49 +00:00
|
|
|
|
/*
|
2007-02-06 10:25:21 +00:00
|
|
|
|
* gtk_tooltip_trigger_tooltip_query:
|
2007-07-09 19:29:51 +00:00
|
|
|
|
* @display: a #GdkDisplay
|
2007-02-06 10:25:21 +00:00
|
|
|
|
*
|
|
|
|
|
* Triggers a new tooltip query on @display, in order to update the current
|
|
|
|
|
* visible tooltip, or to show/hide the current tooltip. This function is
|
|
|
|
|
* useful to call when, for example, the state of the widget changed by a
|
|
|
|
|
* key press.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2019-01-18 07:34:59 +00:00
|
|
|
|
gtk_tooltip_trigger_tooltip_query (GtkWidget *widget)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
2019-01-18 07:34:59 +00:00
|
|
|
|
GdkDisplay *display;
|
2020-05-15 01:27:45 +00:00
|
|
|
|
GdkSeat *seat;
|
2010-12-27 00:05:40 +00:00
|
|
|
|
GdkDevice *device;
|
2020-05-15 01:27:45 +00:00
|
|
|
|
GdkSurface *surface;
|
|
|
|
|
double x, y;
|
2019-01-18 07:48:07 +00:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-01-18 07:34:59 +00:00
|
|
|
|
display = gtk_widget_get_display (widget);
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
/* Trigger logic as if the mouse moved */
|
2020-05-15 01:27:45 +00:00
|
|
|
|
seat = gdk_display_get_default_seat (display);
|
|
|
|
|
if (seat)
|
|
|
|
|
device = gdk_seat_get_pointer (seat);
|
|
|
|
|
else
|
|
|
|
|
device = NULL;
|
|
|
|
|
if (device)
|
|
|
|
|
surface = gdk_device_get_surface_at_position (device, &x, &y);
|
|
|
|
|
else
|
|
|
|
|
surface = NULL;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
if (!surface)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2019-05-20 04:47:50 +00:00
|
|
|
|
toplevel = GTK_WIDGET (gtk_widget_get_root (widget));
|
2019-01-18 07:48:07 +00:00
|
|
|
|
|
2019-05-20 12:17:12 +00:00
|
|
|
|
if (toplevel == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-05-20 00:38:08 +00:00
|
|
|
|
if (gtk_native_get_surface (GTK_NATIVE (toplevel)) != surface)
|
2019-01-18 07:48:07 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-05-17 21:08:01 +00:00
|
|
|
|
gtk_widget_translate_coordinates (toplevel, widget, x, y, &x, &y);
|
2019-01-18 07:48:07 +00:00
|
|
|
|
|
2020-05-17 21:08:01 +00:00
|
|
|
|
gtk_tooltip_handle_event_internal (GDK_MOTION_NOTIFY, surface, widget, x, y);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_window_hide (GtkWidget *widget,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkTooltip *tooltip = GTK_TOOLTIP (user_data);
|
|
|
|
|
|
2007-07-24 03:54:16 +00:00
|
|
|
|
gtk_tooltip_set_custom (tooltip, NULL);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-26 15:09:11 +00:00
|
|
|
|
GtkWidget *
|
2018-03-21 10:49:14 +00:00
|
|
|
|
_gtk_widget_find_at_coords (GdkSurface *surface,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int surface_x,
|
|
|
|
|
int surface_y,
|
|
|
|
|
int *widget_x,
|
|
|
|
|
int *widget_y)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *event_widget;
|
2018-01-13 07:35:39 +00:00
|
|
|
|
GtkWidget *picked_widget;
|
2020-05-17 21:08:01 +00:00
|
|
|
|
double x, y;
|
|
|
|
|
double native_x, native_y;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
|
2010-05-26 15:09:11 +00:00
|
|
|
|
|
2020-08-13 23:21:05 +00:00
|
|
|
|
event_widget = GTK_WIDGET (gtk_native_get_for_surface (surface));
|
2007-05-24 15:54:23 +00:00
|
|
|
|
|
|
|
|
|
if (!event_widget)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2020-05-17 05:22:02 +00:00
|
|
|
|
gtk_native_get_surface_transform (GTK_NATIVE (event_widget), &native_x, &native_y);
|
2020-05-17 21:08:01 +00:00
|
|
|
|
x = surface_x - native_x;
|
|
|
|
|
y = surface_y - native_y;
|
2020-05-17 05:22:02 +00:00
|
|
|
|
|
2020-05-17 21:08:01 +00:00
|
|
|
|
picked_widget = gtk_widget_pick (event_widget, x, y, GTK_PICK_INSENSITIVE);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2018-01-13 07:35:39 +00:00
|
|
|
|
if (picked_widget != NULL)
|
2020-05-17 21:08:01 +00:00
|
|
|
|
gtk_widget_translate_coordinates (event_widget, picked_widget, x, y, &x, &y);
|
|
|
|
|
|
|
|
|
|
*widget_x = x;
|
|
|
|
|
*widget_y = y;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2018-01-13 07:35:39 +00:00
|
|
|
|
return picked_widget;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2007-02-06 10:25:21 +00:00
|
|
|
|
tooltip_browse_mode_expired (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkTooltip *tooltip;
|
2015-09-12 13:14:47 +00:00
|
|
|
|
GdkDisplay *display;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
tooltip = GTK_TOOLTIP (data);
|
|
|
|
|
|
|
|
|
|
tooltip->browse_mode_enabled = FALSE;
|
|
|
|
|
tooltip->browse_mode_timeout_id = 0;
|
|
|
|
|
|
2017-02-05 18:08:56 +00:00
|
|
|
|
if (tooltip->timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->timeout_id);
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
/* destroy tooltip */
|
2015-09-12 13:14:47 +00:00
|
|
|
|
display = gtk_widget_get_display (tooltip->window);
|
|
|
|
|
g_object_set_qdata (G_OBJECT (display), quark_current_tooltip, NULL);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_display_closed (GdkDisplay *display,
|
|
|
|
|
gboolean was_error,
|
|
|
|
|
GtkTooltip *tooltip)
|
|
|
|
|
{
|
2017-02-05 18:08:56 +00:00
|
|
|
|
if (tooltip->timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->timeout_id);
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-12 13:14:47 +00:00
|
|
|
|
g_object_set_qdata (G_OBJECT (display), quark_current_tooltip, NULL);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-17 15:33:45 +00:00
|
|
|
|
static void
|
2019-12-29 02:04:19 +00:00
|
|
|
|
native_weak_notify (gpointer data, GObject *former_object)
|
2007-12-17 15:33:45 +00:00
|
|
|
|
{
|
2019-12-29 02:04:19 +00:00
|
|
|
|
GtkTooltip *tooltip = data;
|
2014-08-22 11:13:50 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_window_set_relative_to (GTK_TOOLTIP_WINDOW (tooltip->window), NULL);
|
|
|
|
|
tooltip->native = NULL;
|
|
|
|
|
}
|
2009-09-30 03:45:03 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_set_surface (GtkTooltip *tooltip,
|
|
|
|
|
GdkSurface *surface)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *native;
|
2007-12-17 15:33:45 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (surface)
|
2020-08-13 23:21:05 +00:00
|
|
|
|
native = GTK_WIDGET (gtk_native_get_for_surface (surface));
|
2019-12-29 02:04:19 +00:00
|
|
|
|
else
|
|
|
|
|
native = NULL;
|
2007-12-17 15:33:45 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip->native == native)
|
|
|
|
|
return;
|
2014-08-22 11:13:50 +00:00
|
|
|
|
|
2019-12-30 14:52:13 +00:00
|
|
|
|
if (GTK_IS_TOOLTIP_WINDOW (native))
|
|
|
|
|
return;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip->native)
|
|
|
|
|
g_object_weak_unref (G_OBJECT (tooltip->native), native_weak_notify, tooltip);
|
|
|
|
|
|
|
|
|
|
tooltip->native = native;
|
2014-08-22 11:13:50 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip->native)
|
|
|
|
|
g_object_weak_ref (G_OBJECT (tooltip->native), native_weak_notify, tooltip);
|
2014-08-22 11:13:50 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (native)
|
|
|
|
|
gtk_tooltip_window_set_relative_to (GTK_TOOLTIP_WINDOW (tooltip->window), native);
|
2014-08-22 11:13:50 +00:00
|
|
|
|
else
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_window_set_relative_to (GTK_TOOLTIP_WINDOW (tooltip->window), NULL);
|
2007-12-17 15:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gtk_tooltip_run_requery (GtkWidget **widget,
|
|
|
|
|
GtkTooltip *tooltip,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean has_tooltip = FALSE;
|
|
|
|
|
gboolean return_value = FALSE;
|
|
|
|
|
|
2018-01-12 19:30:32 +00:00
|
|
|
|
/* Reset tooltip */
|
|
|
|
|
gtk_tooltip_set_markup (tooltip, NULL);
|
|
|
|
|
gtk_tooltip_set_icon (tooltip, NULL);
|
|
|
|
|
gtk_tooltip_set_tip_area (tooltip, NULL);
|
|
|
|
|
|
|
|
|
|
/* See if the custom widget is again set from the query-tooltip
|
|
|
|
|
* callback.
|
|
|
|
|
*/
|
|
|
|
|
tooltip->custom_was_reset = FALSE;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
2016-05-06 13:38:18 +00:00
|
|
|
|
has_tooltip = gtk_widget_get_has_tooltip (*widget);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
if (has_tooltip)
|
2019-01-18 07:27:28 +00:00
|
|
|
|
return_value = gtk_widget_query_tooltip (*widget, *x, *y, FALSE, tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
if (!return_value)
|
|
|
|
|
{
|
2020-05-17 21:08:01 +00:00
|
|
|
|
GtkWidget *parent = gtk_widget_get_parent (*widget);
|
|
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
|
{
|
|
|
|
|
double xx = *x;
|
|
|
|
|
double yy = *y;
|
|
|
|
|
|
|
|
|
|
gtk_widget_translate_coordinates (*widget, parent, xx, yy, &xx, &yy);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2020-05-17 21:08:01 +00:00
|
|
|
|
*x = xx;
|
|
|
|
|
*y = yy;
|
|
|
|
|
}
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2020-05-17 21:08:01 +00:00
|
|
|
|
*widget = parent;
|
|
|
|
|
}
|
2007-02-06 10:25:21 +00:00
|
|
|
|
else
|
2020-05-17 21:08:01 +00:00
|
|
|
|
break;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
while (*widget);
|
|
|
|
|
|
2008-05-28 14:00:31 +00:00
|
|
|
|
/* If the custom widget was not reset in the query-tooltip
|
|
|
|
|
* callback, we clear it here.
|
|
|
|
|
*/
|
|
|
|
|
if (!tooltip->custom_was_reset)
|
|
|
|
|
gtk_tooltip_set_custom (tooltip, NULL);
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
return return_value;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-13 14:25:21 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_position (GtkTooltip *tooltip,
|
|
|
|
|
GdkDisplay *display,
|
2018-08-10 15:11:46 +00:00
|
|
|
|
GtkWidget *new_tooltip_widget,
|
|
|
|
|
GdkDevice *device)
|
2007-07-13 14:25:21 +00:00
|
|
|
|
{
|
2018-08-10 15:11:46 +00:00
|
|
|
|
GtkSettings *settings;
|
2019-02-03 05:47:57 +00:00
|
|
|
|
graphene_rect_t anchor_bounds;
|
2018-08-10 15:11:46 +00:00
|
|
|
|
GdkRectangle anchor_rect;
|
|
|
|
|
GdkSurface *effective_toplevel;
|
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
int rect_anchor_dx = 0;
|
|
|
|
|
int cursor_size;
|
|
|
|
|
int anchor_rect_padding;
|
2020-05-17 21:08:01 +00:00
|
|
|
|
double native_x, native_y;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_widget_realize (GTK_WIDGET (tooltip->window));
|
2011-04-26 22:25:48 +00:00
|
|
|
|
|
2007-07-13 14:25:21 +00:00
|
|
|
|
tooltip->tooltip_widget = new_tooltip_widget;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
toplevel = GTK_WIDGET (gtk_widget_get_native (new_tooltip_widget));
|
2020-05-17 05:22:02 +00:00
|
|
|
|
gtk_native_get_surface_transform (GTK_NATIVE (toplevel), &native_x, &native_y);
|
|
|
|
|
|
2019-02-20 03:53:47 +00:00
|
|
|
|
if (gtk_widget_compute_bounds (new_tooltip_widget, toplevel, &anchor_bounds))
|
|
|
|
|
{
|
|
|
|
|
anchor_rect = (GdkRectangle) {
|
2020-05-17 05:22:02 +00:00
|
|
|
|
floorf (anchor_bounds.origin.x + native_x),
|
|
|
|
|
floorf (anchor_bounds.origin.y + native_y),
|
|
|
|
|
ceilf (anchor_bounds.size.width),
|
|
|
|
|
ceilf (anchor_bounds.size.height)
|
2019-02-20 03:53:47 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
anchor_rect = (GdkRectangle) { 0, 0, 0, 0 };
|
|
|
|
|
}
|
2010-05-08 02:19:56 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
settings = gtk_settings_get_for_display (display);
|
|
|
|
|
g_object_get (settings,
|
2018-01-17 04:20:12 +00:00
|
|
|
|
"gtk-cursor-theme-size", &cursor_size,
|
|
|
|
|
NULL);
|
2010-05-08 02:19:56 +00:00
|
|
|
|
|
2019-03-31 20:16:01 +00:00
|
|
|
|
if (cursor_size == 0)
|
|
|
|
|
cursor_size = 16;
|
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
if (device)
|
|
|
|
|
anchor_rect_padding = MAX (4, cursor_size - 32);
|
|
|
|
|
else
|
|
|
|
|
anchor_rect_padding = 4;
|
2010-05-08 02:19:56 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
anchor_rect.x -= anchor_rect_padding;
|
|
|
|
|
anchor_rect.y -= anchor_rect_padding;
|
|
|
|
|
anchor_rect.width += anchor_rect_padding * 2;
|
|
|
|
|
anchor_rect.height += anchor_rect_padding * 2;
|
2010-05-08 02:19:56 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
if (device)
|
2010-05-08 02:19:56 +00:00
|
|
|
|
{
|
2018-08-10 15:11:46 +00:00
|
|
|
|
const int max_x_distance = 32;
|
|
|
|
|
/* Max 48x48 icon + default padding */
|
|
|
|
|
const int max_anchor_rect_height = 48 + 8;
|
2019-03-25 12:32:50 +00:00
|
|
|
|
double px, py;
|
2018-08-10 15:11:46 +00:00
|
|
|
|
int pointer_x, pointer_y;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* For pointer position triggered tooltips, implement the following
|
|
|
|
|
* semantics:
|
|
|
|
|
*
|
|
|
|
|
* If the anchor rectangle is too tall (meaning if we'd be constrained
|
|
|
|
|
* and flip, it'd flip too far away), rely only on the pointer position
|
|
|
|
|
* to position the tooltip. The approximate pointer cursorrectangle is
|
2020-06-18 07:47:16 +00:00
|
|
|
|
* used as an anchor rectangle.
|
2018-08-10 15:11:46 +00:00
|
|
|
|
*
|
|
|
|
|
* If the anchor rectangle isn't to tall, make sure the tooltip isn't too
|
|
|
|
|
* far away from the pointer position.
|
|
|
|
|
*/
|
2019-05-20 00:38:08 +00:00
|
|
|
|
effective_toplevel = gtk_native_get_surface (GTK_NATIVE (toplevel));
|
2019-03-25 14:12:01 +00:00
|
|
|
|
gdk_surface_get_device_position (effective_toplevel, device, &px, &py, NULL);
|
2019-03-25 12:32:50 +00:00
|
|
|
|
pointer_x = round (px);
|
|
|
|
|
pointer_y = round (py);
|
2010-05-08 02:19:56 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
if (anchor_rect.height > max_anchor_rect_height)
|
2010-05-08 02:19:56 +00:00
|
|
|
|
{
|
2018-08-10 15:11:46 +00:00
|
|
|
|
anchor_rect.x = pointer_x - 4;
|
|
|
|
|
anchor_rect.y = pointer_y - 4;
|
|
|
|
|
anchor_rect.width = cursor_size;
|
|
|
|
|
anchor_rect.height = cursor_size;
|
2010-05-08 02:19:56 +00:00
|
|
|
|
}
|
2018-08-10 15:11:46 +00:00
|
|
|
|
else
|
2010-05-08 02:19:56 +00:00
|
|
|
|
{
|
2018-08-10 15:11:46 +00:00
|
|
|
|
int anchor_point_x;
|
|
|
|
|
int x_distance;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
anchor_point_x = anchor_rect.x + anchor_rect.width / 2;
|
|
|
|
|
x_distance = pointer_x - anchor_point_x;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
if (x_distance > max_x_distance)
|
|
|
|
|
rect_anchor_dx = x_distance - max_x_distance;
|
|
|
|
|
else if (x_distance < -max_x_distance)
|
|
|
|
|
rect_anchor_dx = x_distance + max_x_distance;
|
2010-05-08 02:19:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_window_position (GTK_TOOLTIP_WINDOW (tooltip->window),
|
|
|
|
|
&anchor_rect,
|
|
|
|
|
GDK_GRAVITY_SOUTH,
|
|
|
|
|
GDK_GRAVITY_NORTH,
|
|
|
|
|
GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE_X,
|
|
|
|
|
rect_anchor_dx, 0);
|
2007-07-13 14:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_show_tooltip (GdkDisplay *display)
|
|
|
|
|
{
|
2019-03-25 12:32:50 +00:00
|
|
|
|
double px, py;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int x, y;
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
GtkWidget *tooltip_widget;
|
2020-05-15 01:27:45 +00:00
|
|
|
|
GdkSeat *seat;
|
2018-08-10 15:11:46 +00:00
|
|
|
|
GdkDevice *device;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
gboolean return_value = FALSE;
|
|
|
|
|
|
2015-09-12 13:14:47 +00:00
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (!tooltip->native)
|
|
|
|
|
return;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
surface = gtk_native_get_surface (GTK_NATIVE (tooltip->native));
|
2007-06-06 12:28:50 +00:00
|
|
|
|
|
2020-05-15 01:27:45 +00:00
|
|
|
|
seat = gdk_display_get_default_seat (display);
|
|
|
|
|
if (seat)
|
|
|
|
|
device = gdk_seat_get_pointer (seat);
|
|
|
|
|
else
|
|
|
|
|
device = NULL;
|
|
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
|
gdk_surface_get_device_position (surface, device, &px, &py, NULL);
|
|
|
|
|
else
|
|
|
|
|
px = py = 0;
|
2011-10-28 20:12:02 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
x = round (px);
|
|
|
|
|
y = round (py);
|
2010-04-15 11:03:43 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
tooltip_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
if (!tooltip_widget)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
return_value = gtk_tooltip_run_requery (&tooltip_widget, tooltip, &x, &y);
|
|
|
|
|
if (!return_value)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
/* FIXME: should use tooltip->window iso tooltip->window */
|
2017-10-31 06:41:15 +00:00
|
|
|
|
if (display != gtk_widget_get_display (tooltip->window))
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_handlers_disconnect_by_func (display,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
gtk_tooltip_display_closed,
|
|
|
|
|
tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2017-10-31 06:41:15 +00:00
|
|
|
|
gtk_window_set_display (GTK_WINDOW (tooltip->window), display);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
g_signal_connect (display, "closed",
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_CALLBACK (gtk_tooltip_display_closed), tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-10 15:11:46 +00:00
|
|
|
|
gtk_tooltip_position (tooltip, display, tooltip_widget, device);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_widget_show (GTK_WIDGET (tooltip->window));
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
/* Now a tooltip is visible again on the display, make sure browse
|
|
|
|
|
* mode is enabled.
|
|
|
|
|
*/
|
|
|
|
|
tooltip->browse_mode_enabled = TRUE;
|
|
|
|
|
if (tooltip->browse_mode_timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->browse_mode_timeout_id);
|
|
|
|
|
tooltip->browse_mode_timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
|
|
|
|
|
{
|
2019-01-18 07:27:28 +00:00
|
|
|
|
guint timeout = BROWSE_DISABLE_TIMEOUT;
|
|
|
|
|
|
2007-02-13 12:41:36 +00:00
|
|
|
|
if (!tooltip)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (tooltip->timeout_id)
|
|
|
|
|
{
|
|
|
|
|
g_source_remove (tooltip->timeout_id);
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-13 12:41:36 +00:00
|
|
|
|
if (!GTK_TOOLTIP_VISIBLE (tooltip))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
tooltip->tooltip_widget = NULL;
|
|
|
|
|
|
2019-01-18 07:27:28 +00:00
|
|
|
|
/* The tooltip is gone, after (by default, should be configurable) 500ms
|
|
|
|
|
* we want to turn off browse mode
|
|
|
|
|
*/
|
|
|
|
|
if (!tooltip->browse_mode_timeout_id)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
2019-01-18 07:27:28 +00:00
|
|
|
|
tooltip->browse_mode_timeout_id =
|
|
|
|
|
g_timeout_add_full (0, timeout,
|
|
|
|
|
tooltip_browse_mode_expired,
|
|
|
|
|
g_object_ref (tooltip),
|
|
|
|
|
g_object_unref);
|
2019-02-05 10:26:20 +00:00
|
|
|
|
g_source_set_name_by_id (tooltip->browse_mode_timeout_id, "[gtk] tooltip_browse_mode_expired");
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip->window)
|
|
|
|
|
gtk_widget_hide (tooltip->window);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2007-02-06 10:25:21 +00:00
|
|
|
|
tooltip_popup_timeout (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
|
2010-12-20 16:11:00 +00:00
|
|
|
|
display = GDK_DISPLAY (data);
|
2015-09-12 13:14:47 +00:00
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
2009-08-22 21:21:44 +00:00
|
|
|
|
|
|
|
|
|
/* This usually does not happen. However, it does occur in language
|
|
|
|
|
* bindings were reference counting of objects behaves differently.
|
|
|
|
|
*/
|
|
|
|
|
if (!tooltip)
|
|
|
|
|
return FALSE;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
gtk_tooltip_show_tooltip (display);
|
|
|
|
|
|
|
|
|
|
tooltip->timeout_id = 0;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_tooltip_start_delay (GdkDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
guint timeout;
|
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
|
2015-09-12 13:14:47 +00:00
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2009-08-22 21:21:44 +00:00
|
|
|
|
if (!tooltip || GTK_TOOLTIP_VISIBLE (tooltip))
|
2007-02-06 10:25:21 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (tooltip->timeout_id)
|
|
|
|
|
g_source_remove (tooltip->timeout_id);
|
|
|
|
|
|
|
|
|
|
if (tooltip->browse_mode_enabled)
|
2013-07-08 17:13:23 +00:00
|
|
|
|
timeout = BROWSE_TIMEOUT;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
else
|
2013-07-08 17:13:23 +00:00
|
|
|
|
timeout = HOVER_TIMEOUT;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2018-02-02 14:51:47 +00:00
|
|
|
|
tooltip->timeout_id = g_timeout_add_full (0, timeout,
|
|
|
|
|
tooltip_popup_timeout,
|
|
|
|
|
g_object_ref (display),
|
|
|
|
|
g_object_unref);
|
2019-02-05 10:26:20 +00:00
|
|
|
|
g_source_set_name_by_id (tooltip->timeout_id, "[gtk] tooltip_popup_timeout");
|
2007-02-06 10:25:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_gtk_tooltip_hide (GtkWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display;
|
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
|
|
|
|
|
display = gtk_widget_get_display (widget);
|
2015-09-12 13:14:47 +00:00
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (!tooltip || !tooltip->window || !tooltip->tooltip_widget)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2014-07-21 16:39:10 +00:00
|
|
|
|
if (widget == tooltip->tooltip_widget)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
gtk_tooltip_hide_tooltip (tooltip);
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-02 09:32:14 +00:00
|
|
|
|
static gboolean
|
2011-11-26 19:28:53 +00:00
|
|
|
|
tooltips_enabled (GdkEvent *event)
|
2008-07-02 09:32:14 +00:00
|
|
|
|
{
|
2011-11-26 19:28:53 +00:00
|
|
|
|
GdkDevice *source_device;
|
|
|
|
|
GdkInputSource source;
|
2019-01-18 08:16:44 +00:00
|
|
|
|
GdkModifierType event_state = 0;
|
|
|
|
|
|
|
|
|
|
switch ((guint)gdk_event_get_event_type (event))
|
|
|
|
|
{
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_GRAB_BROKEN:
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
case GDK_TOUCH_UPDATE:
|
|
|
|
|
case GDK_SCROLL:
|
|
|
|
|
break; /* OK */
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
|
event_state = gdk_event_get_modifier_state (event);
|
2019-01-18 08:16:44 +00:00
|
|
|
|
if ((event_state &
|
|
|
|
|
(GDK_BUTTON1_MASK |
|
|
|
|
|
GDK_BUTTON2_MASK |
|
|
|
|
|
GDK_BUTTON3_MASK |
|
|
|
|
|
GDK_BUTTON4_MASK |
|
|
|
|
|
GDK_BUTTON5_MASK)) != 0)
|
|
|
|
|
return FALSE;
|
2008-07-02 09:32:14 +00:00
|
|
|
|
|
2020-07-28 22:03:48 +00:00
|
|
|
|
source_device = gdk_event_get_device (event);
|
2011-11-26 19:28:53 +00:00
|
|
|
|
|
|
|
|
|
if (!source_device)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
source = gdk_device_get_source (source_device);
|
2008-07-02 09:32:14 +00:00
|
|
|
|
|
2013-06-30 18:28:02 +00:00
|
|
|
|
if (source != GDK_SOURCE_TOUCHSCREEN)
|
2011-11-26 19:28:53 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2008-07-02 09:32:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-06 10:25:21 +00:00
|
|
|
|
void
|
2020-02-16 01:47:23 +00:00
|
|
|
|
_gtk_tooltip_handle_event (GtkWidget *target,
|
|
|
|
|
GdkEvent *event)
|
2016-06-06 01:47:16 +00:00
|
|
|
|
{
|
2017-08-26 16:23:02 +00:00
|
|
|
|
GdkEventType event_type;
|
2018-03-20 14:14:10 +00:00
|
|
|
|
GdkSurface *surface;
|
2020-05-17 05:22:02 +00:00
|
|
|
|
double x, y;
|
2020-05-17 21:08:01 +00:00
|
|
|
|
double nx, ny;
|
2020-05-21 22:59:58 +00:00
|
|
|
|
GtkNative *native;
|
2017-08-26 16:23:02 +00:00
|
|
|
|
|
2016-06-06 01:47:16 +00:00
|
|
|
|
if (!tooltips_enabled (event))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-05-21 22:59:58 +00:00
|
|
|
|
native = gtk_widget_get_native (target);
|
|
|
|
|
if (!native)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-08-26 16:23:02 +00:00
|
|
|
|
event_type = gdk_event_get_event_type (event);
|
2018-03-20 14:14:10 +00:00
|
|
|
|
surface = gdk_event_get_surface (event);
|
2020-05-17 05:22:02 +00:00
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
|
|
|
|
|
2020-11-15 14:34:25 +00:00
|
|
|
|
/* ignore synthetic motion events */
|
|
|
|
|
if (event_type == GDK_MOTION_NOTIFY &&
|
|
|
|
|
gdk_event_get_time (event) == GDK_CURRENT_TIME)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-05-21 22:59:58 +00:00
|
|
|
|
gtk_native_get_surface_transform (native, &nx, &ny);
|
|
|
|
|
gtk_widget_translate_coordinates (GTK_WIDGET (native), target, x - nx, y - ny, &x, &y);
|
2020-05-17 21:08:01 +00:00
|
|
|
|
gtk_tooltip_handle_event_internal (event_type, surface, target, x, y);
|
2016-06-06 01:47:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-18 07:48:07 +00:00
|
|
|
|
/* dx/dy must be in @target_widget's coordinates */
|
2016-06-06 01:47:16 +00:00
|
|
|
|
static void
|
2019-01-18 07:48:07 +00:00
|
|
|
|
gtk_tooltip_handle_event_internal (GdkEventType event_type,
|
2018-03-21 10:49:14 +00:00
|
|
|
|
GdkSurface *surface,
|
2019-01-18 07:48:07 +00:00
|
|
|
|
GtkWidget *target_widget,
|
2020-05-17 21:08:01 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
2019-04-26 05:34:18 +00:00
|
|
|
|
int x = dx, y = dy;
|
2007-02-06 10:25:21 +00:00
|
|
|
|
GdkDisplay *display;
|
2019-12-29 02:04:19 +00:00
|
|
|
|
GtkTooltip *tooltip;
|
2007-08-07 11:28:01 +00:00
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
|
display = gdk_surface_get_display (surface);
|
2019-12-29 02:04:19 +00:00
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip)
|
|
|
|
|
gtk_tooltip_set_surface (tooltip, surface);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
/* Hide the tooltip when there's no new tooltip widget */
|
2019-01-18 07:48:07 +00:00
|
|
|
|
if (!target_widget)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip)
|
|
|
|
|
gtk_tooltip_hide_tooltip (tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
|
switch ((guint) event_type)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
|
case GDK_DRAG_ENTER:
|
|
|
|
|
case GDK_GRAB_BROKEN:
|
2011-05-01 14:38:56 +00:00
|
|
|
|
case GDK_SCROLL:
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_hide_tooltip (tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (tooltip)
|
2007-02-06 10:25:21 +00:00
|
|
|
|
{
|
2007-07-13 14:25:21 +00:00
|
|
|
|
gboolean tip_area_set;
|
2019-01-18 08:28:03 +00:00
|
|
|
|
GdkRectangle tip_area;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
gboolean hide_tooltip;
|
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
tip_area_set = tooltip->tip_area_set;
|
|
|
|
|
tip_area = tooltip->tip_area;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_run_requery (&target_widget, tooltip, &x, &y);
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
2007-08-21 11:09:42 +00:00
|
|
|
|
/* Leave notify should override the query function */
|
2017-08-26 16:23:02 +00:00
|
|
|
|
hide_tooltip = (event_type == GDK_LEAVE_NOTIFY);
|
2007-08-21 11:09:42 +00:00
|
|
|
|
|
2007-07-13 14:25:21 +00:00
|
|
|
|
/* Is the pointer above another widget now? */
|
2019-12-29 02:04:19 +00:00
|
|
|
|
if (GTK_TOOLTIP_VISIBLE (tooltip))
|
|
|
|
|
hide_tooltip |= target_widget != tooltip->tooltip_widget;
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
|
|
|
|
/* Did the pointer move out of the previous "context area"? */
|
|
|
|
|
if (tip_area_set)
|
2019-01-18 08:28:03 +00:00
|
|
|
|
hide_tooltip |= !gdk_rectangle_contains_point (&tip_area, x, y);
|
2007-07-13 14:25:21 +00:00
|
|
|
|
|
|
|
|
|
if (hide_tooltip)
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_hide_tooltip (tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
else
|
|
|
|
|
gtk_tooltip_start_delay (display);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Need a new tooltip for this display */
|
2019-12-29 02:04:19 +00:00
|
|
|
|
tooltip = g_object_new (GTK_TYPE_TOOLTIP, NULL);
|
|
|
|
|
g_object_set_qdata_full (G_OBJECT (display), quark_current_tooltip,
|
|
|
|
|
tooltip, g_object_unref);
|
2007-10-08 12:39:02 +00:00
|
|
|
|
g_signal_connect (display, "closed",
|
2019-12-29 02:04:19 +00:00
|
|
|
|
G_CALLBACK (gtk_tooltip_display_closed), tooltip);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
2019-12-29 02:04:19 +00:00
|
|
|
|
gtk_tooltip_set_surface (tooltip, surface);
|
2007-02-06 10:25:21 +00:00
|
|
|
|
|
|
|
|
|
gtk_tooltip_start_delay (display);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-06 17:56:27 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_maybe_allocate (GtkNative *native)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (native));
|
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
|
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
|
|
|
|
if (!tooltip || GTK_NATIVE (tooltip->native) != native)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-12-04 10:06:25 +00:00
|
|
|
|
gtk_tooltip_window_present (GTK_TOOLTIP_WINDOW (tooltip->window));
|
2020-05-06 17:56:27 +00:00
|
|
|
|
}
|
2020-05-09 20:46:40 +00:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gtk_tooltip_unset_surface (GtkNative *native)
|
|
|
|
|
{
|
|
|
|
|
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (native));
|
|
|
|
|
GtkTooltip *tooltip;
|
|
|
|
|
|
|
|
|
|
tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
|
|
|
|
|
if (!tooltip || GTK_NATIVE (tooltip->native) != native)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gtk_tooltip_set_surface (tooltip, NULL);
|
|
|
|
|
}
|
|
|
|
|
|