Commit 51189ae2 authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Matthias Clasen

tooltips: Use the source device instead of gtk-touchscreen-mode

This makes tooltips behavior dynamic based on the interacting device.
parent 1a26b9a9
...@@ -1535,22 +1535,33 @@ _gtk_tooltip_hide (GtkWidget *widget) ...@@ -1535,22 +1535,33 @@ _gtk_tooltip_hide (GtkWidget *widget)
} }
static gboolean static gboolean
tooltips_enabled (GdkWindow *window) tooltips_enabled (GdkEvent *event)
{ {
GdkDevice *source_device;
GdkInputSource source;
GdkWindow *window;
gboolean enabled; gboolean enabled;
gboolean touchscreen;
GdkScreen *screen; GdkScreen *screen;
GtkSettings *settings; 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); screen = gdk_window_get_screen (window);
settings = gtk_settings_get_for_screen (screen); settings = gtk_settings_get_for_screen (screen);
g_object_get (settings, g_object_get (settings,
"gtk-touchscreen-mode", &touchscreen,
"gtk-enable-tooltips", &enabled, "gtk-enable-tooltips", &enabled,
return (!touchscreen && enabled); if (enabled && source != GDK_SOURCE_TOUCHSCREEN)
return TRUE;
return FALSE;
} }
void void
...@@ -1562,7 +1573,7 @@ _gtk_tooltip_handle_event (GdkEvent *event) ...@@ -1562,7 +1573,7 @@ _gtk_tooltip_handle_event (GdkEvent *event)
GdkDisplay *display; GdkDisplay *display;
GtkTooltip *current_tooltip; GtkTooltip *current_tooltip;
if (!tooltips_enabled (event->any.window)) if (!tooltips_enabled (event))
return; return;
/* Returns coordinates relative to has_tooltip_widget's allocation. */ /* Returns coordinates relative to has_tooltip_widget's allocation. */
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment