[gtk+/touchscreens: 43/49] gtk, tooltips: Use the source device instead of gtk-touchscreen-mode
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touchscreens: 43/49] gtk, tooltips: Use the source device instead of gtk-touchscreen-mode
- Date: Mon, 5 Dec 2011 01:18:35 +0000 (UTC)
commit d7b5cce63550ffdbfd79f9a56bcdff454673851a
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Nov 26 20:28:53 2011 +0100
gtk,tooltips: Use the source device instead of gtk-touchscreen-mode
This makes tooltips behavior dynamic based on the interacting device.
gtk/gtktooltip.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index df4fc50..6c376dd 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -1537,22 +1537,34 @@ _gtk_tooltip_hide (GtkWidget *widget)
}
static gboolean
-tooltips_enabled (GdkWindow *window)
+tooltips_enabled (GdkEvent *event)
{
+ GdkDevice *source_device;
+ GdkInputSource source;
+ GdkWindow *window;
gboolean enabled;
- gboolean touchscreen;
GdkScreen *screen;
GtkSettings *settings;
+ window = event->any.window;
+ source_device = gdk_event_get_source_device (event);
+
+ if (!source_device)
+ return FALSE;
+
+ source = gdk_device_get_source (source_device);
screen = gdk_window_get_screen (window);
settings = gtk_settings_get_for_screen (screen);
g_object_get (settings,
- "gtk-touchscreen-mode", &touchscreen,
"gtk-enable-tooltips", &enabled,
NULL);
- return (!touchscreen && enabled);
+ if (enabled &&
+ source != GDK_SOURCE_TOUCH)
+ return TRUE;
+
+ return FALSE;
}
void
@@ -1564,7 +1576,7 @@ _gtk_tooltip_handle_event (GdkEvent *event)
GdkDisplay *display;
GtkTooltip *current_tooltip;
- if (!tooltips_enabled (event->any.window))
+ if (!tooltips_enabled (event))
return;
/* Returns coordinates relative to has_tooltip_widget's allocation. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]