3 * Copyright (C) 2006-2007 Imendio AB
4 * Contact: Kristian Rietveld <kris@imendio.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #include "gtktooltip.h"
25 #include "gtkwindow.h"
30 #include "gtkalignment.h"
35 #define GTK_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TOOLTIP, GtkTooltip))
36 #define GTK_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TOOLTIP, GtkTooltipClass))
37 #define GTK_IS_TOOLTIP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TOOLTIP))
38 #define GTK_IS_TOOLTIP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TOOLTIP))
39 #define GTK_TOOLTIP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TOOLTIP, GtkTooltipClass))
41 typedef struct _GtkTooltipClass GtkTooltipClass;
45 GObject parent_instance;
52 GtkWidget *custom_widget;
54 GtkWindow *current_window;
55 GtkWidget *keyboard_widget;
57 GtkWidget *tooltip_widget;
58 GdkWindow *toplevel_window;
62 GdkWindow *last_window;
65 guint browse_mode_timeout_id;
67 guint browse_mode_enabled : 1;
68 guint keyboard_mode_enabled : 1;
71 struct _GtkTooltipClass
73 GObjectClass parent_class;
76 #define GTK_TOOLTIP_VISIBLE(tooltip) ((tooltip)->current_window && GTK_WIDGET_VISIBLE ((tooltip)->current_window))
79 static void gtk_tooltip_class_init (GtkTooltipClass *klass);
80 static void gtk_tooltip_init (GtkTooltip *tooltip);
81 static void gtk_tooltip_finalize (GObject *object);
83 static gboolean gtk_tooltip_paint_window (GtkTooltip *tooltip);
84 static void gtk_tooltip_window_hide (GtkWidget *widget,
86 static void gtk_tooltip_display_closed (GdkDisplay *display,
91 G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
94 gtk_tooltip_class_init (GtkTooltipClass *klass)
96 GObjectClass *object_class;
98 object_class = G_OBJECT_CLASS (klass);
100 object_class->finalize = gtk_tooltip_finalize;
104 gtk_tooltip_init (GtkTooltip *tooltip)
106 tooltip->timeout_id = 0;
107 tooltip->browse_mode_timeout_id = 0;
109 tooltip->browse_mode_enabled = FALSE;
110 tooltip->keyboard_mode_enabled = FALSE;
112 tooltip->current_window = NULL;
113 tooltip->keyboard_widget = NULL;
115 tooltip->tooltip_widget = NULL;
116 tooltip->toplevel_window = NULL;
118 tooltip->last_window = NULL;
120 tooltip->window = g_object_ref (gtk_window_new (GTK_WINDOW_POPUP));
121 gtk_window_set_type_hint (GTK_WINDOW (tooltip->window),
122 GDK_WINDOW_TYPE_HINT_TOOLTIP);
123 gtk_widget_set_app_paintable (tooltip->window, TRUE);
124 gtk_window_set_resizable (GTK_WINDOW (tooltip->window), FALSE);
125 gtk_widget_set_name (tooltip->window, "gtk-tooltip");
126 g_signal_connect (tooltip->window, "hide",
127 G_CALLBACK (gtk_tooltip_window_hide), tooltip);
129 tooltip->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
130 gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
131 tooltip->window->style->ythickness,
132 tooltip->window->style->ythickness,
133 tooltip->window->style->xthickness,
134 tooltip->window->style->xthickness);
135 gtk_container_add (GTK_CONTAINER (tooltip->window), tooltip->alignment);
136 gtk_widget_show (tooltip->alignment);
138 g_signal_connect_swapped (tooltip->window, "expose_event",
139 G_CALLBACK (gtk_tooltip_paint_window), tooltip);
141 tooltip->box = gtk_hbox_new (FALSE, tooltip->window->style->xthickness);
142 gtk_container_add (GTK_CONTAINER (tooltip->alignment), tooltip->box);
143 gtk_widget_show (tooltip->box);
145 tooltip->image = gtk_image_new ();
146 gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->image,
149 tooltip->label = gtk_label_new ("");
150 gtk_box_pack_start (GTK_BOX (tooltip->box), tooltip->label,
153 tooltip->custom_widget = NULL;
157 gtk_tooltip_finalize (GObject *object)
159 GtkTooltip *tooltip = GTK_TOOLTIP (object);
161 if (tooltip->timeout_id)
163 g_source_remove (tooltip->timeout_id);
164 tooltip->timeout_id = 0;
167 if (tooltip->browse_mode_timeout_id)
169 g_source_remove (tooltip->browse_mode_timeout_id);
170 tooltip->browse_mode_timeout_id = 0;
177 display = gtk_widget_get_display (tooltip->window);
178 g_signal_handlers_disconnect_by_func (display,
179 gtk_tooltip_display_closed,
181 gtk_widget_destroy (tooltip->window);
184 G_OBJECT_CLASS (gtk_tooltip_parent_class)->finalize (object);
190 * gtk_tooltip_set_markup:
191 * @label: a #GtkTooltip
192 * @markup: a markup string (see <link linkend="PangoMarkupFormat">Pango markup format</link>) or %NULL
194 * Sets the text of the tooltip to be @str, which is marked up
196 * linkend="PangoMarkupFormat">Pango text markup language</link>.
197 * If @markup is %NULL, the label will be hidden.
202 gtk_tooltip_set_markup (GtkTooltip *tooltip,
205 g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
207 gtk_label_set_markup (GTK_LABEL (tooltip->label), markup);
210 gtk_widget_show (tooltip->label);
212 gtk_widget_hide (tooltip->label);
216 * gtk_tooltip_set_icon:
217 * @tooltip: a #GtkTooltip
218 * @pixbuf: a #GdkPixbuf, or %NULL
220 * Sets the icon of the tooltip (which is in front of the text) to be
221 * @pixbuf. If @pixbuf is %NULL, the image will be hidden.
226 gtk_tooltip_set_icon (GtkTooltip *tooltip,
229 g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
231 g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
233 gtk_image_set_from_pixbuf (GTK_IMAGE (tooltip->image), pixbuf);
236 gtk_widget_show (tooltip->image);
238 gtk_widget_hide (tooltip->image);
242 * gtk_tooltip_set_icon_from_stock:
243 * @tooltip: a #GtkTooltip
244 * @stock_id: a stock icon name, or %NULL
245 * @size: a stock icon size
247 * Sets the icon of the tooltip (which is in front of the text) to be
248 * the stock item indicated by @stock_id with the size indicated
249 * by @size. If @stock_id is %NULL, the image will be hidden.
254 gtk_tooltip_set_icon_from_stock (GtkTooltip *tooltip,
255 const gchar *stock_id,
258 g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
260 gtk_image_set_from_stock (GTK_IMAGE (tooltip->image), stock_id, size);
263 gtk_widget_show (tooltip->image);
265 gtk_widget_hide (tooltip->image);
269 * gtk_tooltip_set_custom:
270 * tooltip: a #GtkTooltip
271 * custom_widget: a #GtkWidget
273 * Replaces the widget packed into the tooltip with @custom_widget. By
274 * default a box with a #GtkImage and #GtkLabel is embedded in the tooltip,
275 * which can be configured using gtk_tooltip_set_markup() and
276 * gtk_tooltip_set_icon().
281 gtk_tooltip_set_custom (GtkTooltip *tooltip,
282 GtkWidget *custom_widget)
284 g_return_if_fail (GTK_IS_TOOLTIP (tooltip));
286 g_return_if_fail (GTK_IS_WIDGET (custom_widget));
288 if (tooltip->custom_widget)
290 gtk_container_remove (GTK_CONTAINER (tooltip->box),
291 tooltip->custom_widget);
292 g_object_unref (tooltip->custom_widget);
297 tooltip->custom_widget = g_object_ref (custom_widget);
299 gtk_container_add (GTK_CONTAINER (tooltip->box), custom_widget);
300 gtk_widget_show (custom_widget);
303 tooltip->custom_widget = NULL;
307 * gtk_tooltip_trigger_tooltip_query:
308 * @display: a #GtkDisplay
310 * Triggers a new tooltip query on @display, in order to update the current
311 * visible tooltip, or to show/hide the current tooltip. This function is
312 * useful to call when, for example, the state of the widget changed by a
318 gtk_tooltip_trigger_tooltip_query (GdkDisplay *display)
324 /* Trigger logic as if the mouse moved */
325 window = gdk_display_get_window_at_pointer (display, &x, &y);
329 event.type = GDK_MOTION_NOTIFY;
330 event.motion.window = window;
333 event.motion.is_hint = FALSE;
335 _gtk_tooltip_handle_event (&event);
338 /* private functions */
341 gtk_tooltip_reset (GtkTooltip *tooltip)
343 gtk_tooltip_set_markup (tooltip, NULL);
344 gtk_tooltip_set_icon (tooltip, NULL);
345 gtk_tooltip_set_custom (tooltip, NULL);
349 gtk_tooltip_paint_window (GtkTooltip *tooltip)
353 gtk_widget_size_request (tooltip->window, &req);
354 gtk_paint_flat_box (tooltip->window->style,
355 tooltip->window->window,
362 tooltip->window->allocation.width,
363 tooltip->window->allocation.height);
369 gtk_tooltip_window_hide (GtkWidget *widget,
372 GtkTooltip *tooltip = GTK_TOOLTIP (user_data);
374 if (tooltip->custom_widget)
375 gtk_tooltip_set_custom (tooltip, NULL);
378 /* event handling, etc */
383 GtkWidget *container;
390 child_location_foreach (GtkWidget *child,
394 struct ChildLocation *child_loc = data;
396 if (!child_loc->child &&
397 gtk_widget_translate_coordinates (child_loc->container, child,
398 child_loc->x, child_loc->y,
401 if (x >= 0 && x < child->allocation.width
402 && y >= 0 && y < child->allocation.height)
404 if (GTK_IS_CONTAINER (child))
406 struct ChildLocation tmp = { NULL, NULL, 0, 0 };
410 tmp.container = child;
412 gtk_container_foreach (GTK_CONTAINER (child),
413 child_location_foreach, &tmp);
416 child_loc->child = tmp.child;
418 child_loc->child = child;
421 child_loc->child = child;
427 window_to_alloc (GtkWidget *dest_widget,
433 /* Translate from window relative to allocation relative */
434 if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
437 gdk_window_get_position (dest_widget->window, &wx, &wy);
439 src_x += wx - dest_widget->allocation.x;
440 src_y += wy - dest_widget->allocation.y;
444 src_x -= dest_widget->allocation.x;
445 src_y -= dest_widget->allocation.y;
455 find_widget_under_pointer (GdkWindow *window,
459 GtkWidget *event_widget;
460 struct ChildLocation child_loc = { NULL, NULL, 0, 0 };
465 gdk_window_get_user_data (window, (void **)&event_widget);
466 if (GTK_IS_CONTAINER (event_widget))
468 window_to_alloc (event_widget,
469 child_loc.x, child_loc.y,
470 &child_loc.x, &child_loc.y);
472 child_loc.container = event_widget;
473 child_loc.child = NULL;
475 gtk_container_foreach (GTK_CONTAINER (event_widget),
476 child_location_foreach, &child_loc);
479 event_widget = child_loc.child;
480 else if (child_loc.container)
481 event_widget = child_loc.container;
493 find_topmost_widget_coords_from_event (GdkEvent *event,
501 gdk_event_get_coords (event, &dx, &dy);
505 tmp = find_widget_under_pointer (event->any.window, &tx, &ty);
516 tooltip_browse_mode_expired (gpointer data)
520 tooltip = GTK_TOOLTIP (data);
522 tooltip->browse_mode_enabled = FALSE;
523 tooltip->browse_mode_timeout_id = 0;
525 /* destroy tooltip */
526 g_object_set_data (G_OBJECT (gtk_widget_get_display (tooltip->window)),
527 "gdk-display-current-tooltip", NULL);
533 gtk_tooltip_display_closed (GdkDisplay *display,
537 g_object_set (display, "gdk-display-current-tooltip", NULL);
541 gtk_tooltip_run_requery (GtkWidget **widget,
546 gboolean has_tooltip = FALSE;
547 gboolean return_value = FALSE;
549 gtk_tooltip_reset (tooltip);
553 g_object_get (*widget,
554 "has-tooltip", &has_tooltip,
558 g_signal_emit_by_name (*widget,
561 tooltip->keyboard_mode_enabled,
567 GtkWidget *parent = (*widget)->parent;
570 gtk_widget_translate_coordinates (*widget, parent, *x, *y, x, y);
583 gtk_tooltip_show_tooltip (GdkDisplay *display)
589 GtkWidget *tooltip_widget;
590 GtkWidget *pointer_widget;
592 gboolean has_tooltip;
593 gboolean return_value = FALSE;
595 tooltip = g_object_get_data (G_OBJECT (display),
596 "gdk-display-current-tooltip");
598 if (tooltip->keyboard_mode_enabled)
600 pointer_widget = tooltip_widget = tooltip->keyboard_widget;
604 window = tooltip->last_window;
606 gdk_window_get_origin (window, &x, &y);
607 x = tooltip->last_x - x;
608 y = tooltip->last_y - y;
613 pointer_widget = tooltip_widget = find_widget_under_pointer (window,
620 g_object_get (tooltip_widget, "has-tooltip", &has_tooltip, NULL);
622 g_assert (tooltip != NULL);
624 return_value = gtk_tooltip_run_requery (&tooltip_widget, tooltip, &x, &y);
628 if (!tooltip->current_window)
630 if (gtk_widget_get_tooltip_window (tooltip_widget))
631 tooltip->current_window = gtk_widget_get_tooltip_window (tooltip_widget);
633 tooltip->current_window = GTK_WINDOW (GTK_TOOLTIP (tooltip)->window);
636 /* Position the tooltip */
637 /* FIXME: should we swap this when RTL is enabled? */
638 if (tooltip->keyboard_mode_enabled)
640 gdk_window_get_origin (tooltip_widget->window, &x, &y);
641 if (GTK_WIDGET_NO_WINDOW (tooltip_widget))
643 x += tooltip_widget->allocation.x;
644 y += tooltip_widget->allocation.y;
647 /* For keyboard mode we position the tooltip below the widget,
648 * right of the center of the widget.
650 x += tooltip_widget->allocation.width / 2;
651 y += tooltip_widget->allocation.height + 4;
660 /* For mouse mode, we position the tooltip right of the cursor,
661 * a little below the cursor's center.
663 cursor_size = gdk_display_get_default_cursor_size (display);
664 x += cursor_size / 2;
665 y += cursor_size / 2;
668 screen = gtk_widget_get_screen (tooltip_widget);
670 if (screen != gtk_widget_get_screen (tooltip->window))
672 g_signal_handlers_disconnect_by_func (display,
673 gtk_tooltip_display_closed,
676 gtk_window_set_screen (GTK_WINDOW (tooltip->window), screen);
678 g_signal_connect (display, "closed",
679 G_CALLBACK (gtk_tooltip_display_closed), tooltip);
682 tooltip->tooltip_widget = tooltip_widget;
685 if (tooltip->current_window)
688 GdkRectangle monitor;
689 GtkRequisition requisition;
691 gtk_widget_size_request (GTK_WIDGET (tooltip->current_window),
694 monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
695 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
697 if (x + requisition.width > monitor.x + monitor.width)
698 x -= x - (monitor.x + monitor.width) + requisition.width;
699 else if (x < monitor.x)
702 if (y + requisition.height > monitor.y + monitor.height)
703 y -= y - (monitor.y + monitor.height) + requisition.height;
705 gtk_window_move (GTK_WINDOW (tooltip->current_window), x, y);
706 gtk_widget_show (GTK_WIDGET (tooltip->current_window));
709 /* Now a tooltip is visible again on the display, make sure browse
712 tooltip->browse_mode_enabled = TRUE;
713 if (tooltip->browse_mode_timeout_id)
715 g_source_remove (tooltip->browse_mode_timeout_id);
716 tooltip->browse_mode_timeout_id = 0;
721 gtk_tooltip_hide_tooltip (GtkTooltip *tooltip)
726 if (tooltip->timeout_id)
728 g_source_remove (tooltip->timeout_id);
729 tooltip->timeout_id = 0;
732 if (!GTK_TOOLTIP_VISIBLE (tooltip))
735 tooltip->tooltip_widget = NULL;
737 if (!tooltip->keyboard_mode_enabled)
740 GtkSettings *settings;
742 settings = gtk_widget_get_settings (GTK_WIDGET (tooltip->window));
744 g_object_get (settings,
745 "gtk-tooltip-browse-mode-timeout", &timeout,
748 /* The tooltip is gone, after (by default, should be configurable) 500ms
749 * we want to turn off browse mode
751 if (!tooltip->browse_mode_timeout_id)
752 tooltip->browse_mode_timeout_id =
753 gdk_threads_add_timeout_full (0, timeout,
754 tooltip_browse_mode_expired,
755 g_object_ref (tooltip),
760 if (tooltip->browse_mode_timeout_id)
762 g_source_remove (tooltip->browse_mode_timeout_id);
763 tooltip->browse_mode_timeout_id = 0;
767 if (tooltip->current_window)
769 gtk_widget_hide (GTK_WIDGET (tooltip->current_window));
770 tooltip->current_window = NULL;
775 tooltip_popup_timeout (gpointer data)
780 display = GDK_DISPLAY_OBJECT (data);
782 gtk_tooltip_show_tooltip (display);
784 tooltip = g_object_get_data (G_OBJECT (display),
785 "gdk-display-current-tooltip");
786 tooltip->timeout_id = 0;
792 gtk_tooltip_start_delay (GdkDisplay *display)
796 GtkSettings *settings;
798 tooltip = g_object_get_data (G_OBJECT (display),
799 "gdk-display-current-tooltip");
801 if (tooltip && GTK_TOOLTIP_VISIBLE (tooltip))
804 if (tooltip->timeout_id)
805 g_source_remove (tooltip->timeout_id);
807 settings = gtk_widget_get_settings (GTK_WIDGET (tooltip->window));
809 if (tooltip->browse_mode_enabled)
810 g_object_get (settings, "gtk-tooltip-browse-timeout", &timeout, NULL);
812 g_object_get (settings, "gtk-tooltip-timeout", &timeout, NULL);
814 tooltip->timeout_id = gdk_threads_add_timeout_full (0, timeout,
815 tooltip_popup_timeout,
816 g_object_ref (display),
821 _gtk_tooltip_focus_in (GtkWidget *widget)
824 gboolean return_value = FALSE;
828 /* Get current tooltip for this display */
829 display = gtk_widget_get_display (widget);
830 tooltip = g_object_get_data (G_OBJECT (display),
831 "gdk-display-current-tooltip");
833 /* Check if keyboard mode is enabled at this moment */
834 if (!tooltip || !tooltip->keyboard_mode_enabled)
837 if (tooltip->keyboard_widget)
838 g_object_unref (tooltip->keyboard_widget);
840 tooltip->keyboard_widget = g_object_ref (widget);
842 gdk_window_get_pointer (widget->window, &x, &y, NULL);
844 return_value = gtk_tooltip_run_requery (&widget, tooltip, &x, &y);
847 gtk_tooltip_hide_tooltip (tooltip);
851 if (!tooltip->current_window)
853 if (gtk_widget_get_tooltip_window (widget))
854 tooltip->current_window = gtk_widget_get_tooltip_window (widget);
856 tooltip->current_window = GTK_WINDOW (GTK_TOOLTIP (tooltip)->window);
859 gtk_tooltip_show_tooltip (display);
863 _gtk_tooltip_focus_out (GtkWidget *widget)
868 /* Get current tooltip for this display */
869 display = gtk_widget_get_display (widget);
870 tooltip = g_object_get_data (G_OBJECT (display),
871 "gdk-display-current-tooltip");
873 if (!tooltip || !tooltip->keyboard_mode_enabled)
876 if (tooltip->keyboard_widget)
878 g_object_unref (tooltip->keyboard_widget);
879 tooltip->keyboard_widget = NULL;
882 gtk_tooltip_hide_tooltip (tooltip);
886 _gtk_tooltip_toggle_keyboard_mode (GtkWidget *widget)
891 display = gtk_widget_get_display (widget);
892 tooltip = g_object_get_data (G_OBJECT (display),
893 "gdk-display-current-tooltip");
897 tooltip = g_object_new (GTK_TYPE_TOOLTIP, NULL);
898 g_object_set_data_full (G_OBJECT (display),
899 "gdk-display-current-tooltip",
900 tooltip, g_object_unref);
903 tooltip->keyboard_mode_enabled ^= 1;
905 if (tooltip->keyboard_mode_enabled)
907 tooltip->keyboard_widget = g_object_ref (widget);
908 _gtk_tooltip_focus_in (widget);
912 if (tooltip->keyboard_widget)
914 g_object_unref (tooltip->keyboard_widget);
915 tooltip->keyboard_widget = NULL;
918 gtk_tooltip_hide_tooltip (tooltip);
923 _gtk_tooltip_hide (GtkWidget *widget)
929 display = gtk_widget_get_display (widget);
930 tooltip = g_object_get_data (G_OBJECT (display),
931 "gdk-display-current-tooltip");
933 if (!tooltip || !GTK_TOOLTIP_VISIBLE (tooltip) || !tooltip->tooltip_widget)
936 toplevel = gtk_widget_get_toplevel (widget);
938 if (widget == tooltip->tooltip_widget
939 || toplevel->window == tooltip->toplevel_window)
940 gtk_tooltip_hide_tooltip (tooltip);
944 _gtk_tooltip_handle_event (GdkEvent *event)
947 gboolean return_value = FALSE;
948 GtkWidget *has_tooltip_widget = NULL;
950 GtkTooltip *current_tooltip;
952 has_tooltip_widget = find_topmost_widget_coords_from_event (event, &x, &y);
953 display = gdk_drawable_get_display (event->any.window);
954 current_tooltip = g_object_get_data (G_OBJECT (display),
955 "gdk-display-current-tooltip");
959 current_tooltip->last_window = event->any.window;
960 gdk_event_get_root_coords (event,
961 ¤t_tooltip->last_x,
962 ¤t_tooltip->last_y);
965 if (current_tooltip && current_tooltip->keyboard_mode_enabled)
967 has_tooltip_widget = current_tooltip->keyboard_widget;
968 if (!has_tooltip_widget)
971 return_value = gtk_tooltip_run_requery (&has_tooltip_widget,
976 gtk_tooltip_hide_tooltip (current_tooltip);
978 gtk_tooltip_start_delay (display);
983 /* Always poll for a next motion event */
984 gdk_event_request_motions (&event->motion);
986 /* Hide the tooltip when there's no new tooltip widget */
987 if (!has_tooltip_widget)
989 if (current_tooltip && GTK_TOOLTIP_VISIBLE (current_tooltip))
990 gtk_tooltip_hide_tooltip (current_tooltip);
997 case GDK_BUTTON_PRESS:
998 case GDK_2BUTTON_PRESS:
999 case GDK_3BUTTON_PRESS:
1001 case GDK_DRAG_ENTER:
1002 case GDK_GRAB_BROKEN:
1003 gtk_tooltip_hide_tooltip (current_tooltip);
1006 case GDK_MOTION_NOTIFY:
1007 case GDK_ENTER_NOTIFY:
1008 case GDK_LEAVE_NOTIFY:
1010 if (current_tooltip)
1012 return_value = gtk_tooltip_run_requery (&has_tooltip_widget,
1017 gtk_tooltip_hide_tooltip (current_tooltip);
1019 gtk_tooltip_start_delay (display);
1023 /* Need a new tooltip for this display */
1024 current_tooltip = g_object_new (GTK_TYPE_TOOLTIP, NULL);
1025 g_object_set_data_full (G_OBJECT (display),
1026 "gdk-display-current-tooltip",
1027 current_tooltip, g_object_unref);
1029 current_tooltip->last_window = event->any.window;
1030 gdk_event_get_root_coords (event,
1031 ¤t_tooltip->last_x,
1032 ¤t_tooltip->last_y);
1034 gtk_tooltip_start_delay (display);