From 34245515e532017653b5b84132654734b4d977de Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Jul 2014 10:10:11 -0400 Subject: [PATCH] Add a 'touchscreen' debug flag This has the same effect as the GTK_TEST_TOUCHSCREEN environment variable, but can be toggled at runtime. --- docs/reference/gtk/running.sgml | 4 ++++ gtk/gtkdebug.h | 3 ++- gtk/gtkentry.c | 7 ++++++- gtk/gtkgesturesingle.c | 4 +++- gtk/gtkmain.c | 3 ++- gtk/gtktextview.c | 4 ++++ 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml index f7d89d101b..567c72aaa7 100644 --- a/docs/reference/gtk/running.sgml +++ b/docs/reference/gtk/running.sgml @@ -198,6 +198,10 @@ additional environment variables. text Text widget internals + + touchscreen + Pretend the pointer is a touchscreen device + tree Tree widget internals diff --git a/gtk/gtkdebug.h b/gtk/gtkdebug.h index 895520eba6..8b1d2cb269 100644 --- a/gtk/gtkdebug.h +++ b/gtk/gtkdebug.h @@ -52,7 +52,8 @@ typedef enum { GTK_DEBUG_BASELINES = 1 << 14, GTK_DEBUG_PIXEL_CACHE = 1 << 15, GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16, - GTK_DEBUG_INTERACTIVE = 1 << 17 + GTK_DEBUG_INTERACTIVE = 1 << 17, + GTK_DEBUG_TOUCHSCREEN = 1 << 18 } GtkDebugFlag; #ifdef G_ENABLE_DEBUG diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index abaa20b827..5cdb3d9761 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -34,6 +34,7 @@ #include "gtkbindings.h" #include "gtkcelleditable.h" #include "gtkclipboard.h" +#include "gtkdebug.h" #include "gtkdnd.h" #include "gtkentry.h" #include "gtkentrybuffer.h" @@ -4419,6 +4420,7 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture, source = gdk_event_get_source_device (event); is_touchscreen = test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN; if (is_touchscreen) @@ -4701,7 +4703,9 @@ gtk_entry_drag_gesture_update (GtkGestureDrag *gesture, gtk_entry_set_positions (entry, tmp_pos, -1); /* Update touch handles' position */ - if (test_touchscreen || input_source == GDK_SOURCE_TOUCHSCREEN) + if (test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || + input_source == GDK_SOURCE_TOUCHSCREEN) { gtk_entry_ensure_text_handles (entry); gtk_entry_update_handles (entry, @@ -4742,6 +4746,7 @@ gtk_entry_drag_gesture_end (GtkGestureDrag *gesture, event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); source = gdk_event_get_source_device (event); is_touchscreen = (test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN); if (priv->selection_bubble && diff --git a/gtk/gtkgesturesingle.c b/gtk/gtkgesturesingle.c index d33f190292..5d6507e83b 100644 --- a/gtk/gtkgesturesingle.c +++ b/gtk/gtkgesturesingle.c @@ -39,6 +39,7 @@ #include "gtkgesturesingleprivate.h" #include "gtkprivate.h" #include "gtkintl.h" +#include "gtkdebug.h" typedef struct _GtkGestureSinglePrivate GtkGestureSinglePrivate; @@ -301,7 +302,8 @@ gtk_gesture_single_init (GtkGestureSingle *gesture) priv = gtk_gesture_single_get_instance_private (gesture); - if (g_getenv ("GTK_TEST_TOUCHSCREEN")) + if (g_getenv ("GTK_TEST_TOUCHSCREEN") || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0) priv->touch_only = FALSE; else priv->touch_only = TRUE; diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 7e6c4f16d6..16e0fdcb82 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -177,7 +177,8 @@ static const GDebugKey gtk_debug_keys[] = { {"baselines", GTK_DEBUG_BASELINES}, {"pixel-cache", GTK_DEBUG_PIXEL_CACHE}, {"no-pixel-cache", GTK_DEBUG_NO_PIXEL_CACHE}, - {"interactive", GTK_DEBUG_INTERACTIVE} + {"interactive", GTK_DEBUG_INTERACTIVE}, + {"touchscreen", GTK_DEBUG_TOUCHSCREEN} }; #endif /* G_ENABLE_DEBUG */ diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 805cb75012..75c6f9b5c5 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -31,6 +31,7 @@ #include "gtkadjustmentprivate.h" #include "gtkbindings.h" #include "gtkdnd.h" +#include "gtkdebug.h" #include "gtkintl.h" #include "gtkmain.h" #include "gtkmarshalers.h" @@ -5091,6 +5092,7 @@ gtk_text_view_multipress_gesture_pressed (GtkGestureMultiPress *gesture, device = gdk_event_get_source_device ((GdkEvent *) event); is_touchscreen = test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; if (n_press == 1) @@ -6999,6 +7001,7 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture, device = gdk_event_get_source_device (event); is_touchscreen = test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; if (data->granularity == SELECT_CHARACTERS) @@ -7095,6 +7098,7 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture, event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); device = gdk_event_get_source_device (event); is_touchscreen = test_touchscreen || + (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 || gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; if (priv->selection_bubble &&