Add a 'touchscreen' debug flag

This has the same effect as the GTK_TEST_TOUCHSCREEN environment
variable, but can be toggled at runtime.
This commit is contained in:
Matthias Clasen 2014-07-10 10:10:11 -04:00
parent 562a942f99
commit 34245515e5
6 changed files with 21 additions and 4 deletions

View File

@ -198,6 +198,10 @@ additional environment variables.
<term>text</term> <term>text</term>
<listitem><para>Text widget internals</para></listitem> <listitem><para>Text widget internals</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>touchscreen</term>
<listitem><para>Pretend the pointer is a touchscreen device</para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>tree</term> <term>tree</term>
<listitem><para>Tree widget internals</para></listitem> <listitem><para>Tree widget internals</para></listitem>

View File

@ -52,7 +52,8 @@ typedef enum {
GTK_DEBUG_BASELINES = 1 << 14, GTK_DEBUG_BASELINES = 1 << 14,
GTK_DEBUG_PIXEL_CACHE = 1 << 15, GTK_DEBUG_PIXEL_CACHE = 1 << 15,
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16, GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16,
GTK_DEBUG_INTERACTIVE = 1 << 17 GTK_DEBUG_INTERACTIVE = 1 << 17,
GTK_DEBUG_TOUCHSCREEN = 1 << 18
} GtkDebugFlag; } GtkDebugFlag;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG

View File

@ -34,6 +34,7 @@
#include "gtkbindings.h" #include "gtkbindings.h"
#include "gtkcelleditable.h" #include "gtkcelleditable.h"
#include "gtkclipboard.h" #include "gtkclipboard.h"
#include "gtkdebug.h"
#include "gtkdnd.h" #include "gtkdnd.h"
#include "gtkentry.h" #include "gtkentry.h"
#include "gtkentrybuffer.h" #include "gtkentrybuffer.h"
@ -4419,6 +4420,7 @@ gtk_entry_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
source = gdk_event_get_source_device (event); source = gdk_event_get_source_device (event);
is_touchscreen = test_touchscreen || is_touchscreen = test_touchscreen ||
(gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN; gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
if (is_touchscreen) if (is_touchscreen)
@ -4701,7 +4703,9 @@ gtk_entry_drag_gesture_update (GtkGestureDrag *gesture,
gtk_entry_set_positions (entry, tmp_pos, -1); gtk_entry_set_positions (entry, tmp_pos, -1);
/* Update touch handles' position */ /* 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_ensure_text_handles (entry);
gtk_entry_update_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); event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
source = gdk_event_get_source_device (event); source = gdk_event_get_source_device (event);
is_touchscreen = (test_touchscreen || is_touchscreen = (test_touchscreen ||
(gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN); gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN);
if (priv->selection_bubble && if (priv->selection_bubble &&

View File

@ -39,6 +39,7 @@
#include "gtkgesturesingleprivate.h" #include "gtkgesturesingleprivate.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkdebug.h"
typedef struct _GtkGestureSinglePrivate GtkGestureSinglePrivate; typedef struct _GtkGestureSinglePrivate GtkGestureSinglePrivate;
@ -301,7 +302,8 @@ gtk_gesture_single_init (GtkGestureSingle *gesture)
priv = gtk_gesture_single_get_instance_private (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; priv->touch_only = FALSE;
else else
priv->touch_only = TRUE; priv->touch_only = TRUE;

View File

@ -177,7 +177,8 @@ static const GDebugKey gtk_debug_keys[] = {
{"baselines", GTK_DEBUG_BASELINES}, {"baselines", GTK_DEBUG_BASELINES},
{"pixel-cache", GTK_DEBUG_PIXEL_CACHE}, {"pixel-cache", GTK_DEBUG_PIXEL_CACHE},
{"no-pixel-cache", GTK_DEBUG_NO_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 */ #endif /* G_ENABLE_DEBUG */

View File

@ -31,6 +31,7 @@
#include "gtkadjustmentprivate.h" #include "gtkadjustmentprivate.h"
#include "gtkbindings.h" #include "gtkbindings.h"
#include "gtkdnd.h" #include "gtkdnd.h"
#include "gtkdebug.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkmain.h" #include "gtkmain.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
@ -5091,6 +5092,7 @@ gtk_text_view_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
device = gdk_event_get_source_device ((GdkEvent *) event); device = gdk_event_get_source_device ((GdkEvent *) event);
is_touchscreen = test_touchscreen || is_touchscreen = test_touchscreen ||
(gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
if (n_press == 1) if (n_press == 1)
@ -6999,6 +7001,7 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
device = gdk_event_get_source_device (event); device = gdk_event_get_source_device (event);
is_touchscreen = test_touchscreen || is_touchscreen = test_touchscreen ||
(gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
if (data->granularity == SELECT_CHARACTERS) 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); event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
device = gdk_event_get_source_device (event); device = gdk_event_get_source_device (event);
is_touchscreen = test_touchscreen || is_touchscreen = test_touchscreen ||
(gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0 ||
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN; gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
if (priv->selection_bubble && if (priv->selection_bubble &&