Commit 34245515 authored by Matthias Clasen's avatar Matthias Clasen

Add a 'touchscreen' debug flag

This has the same effect as the GTK_TEST_TOUCHSCREEN environment
variable, but can be toggled at runtime.
parent 562a942f
......@@ -198,6 +198,10 @@ additional environment variables.
<term>text</term>
<listitem><para>Text widget internals</para></listitem>
</varlistentry>
<varlistentry>
<term>touchscreen</term>
<listitem><para>Pretend the pointer is a touchscreen device</para></listitem>
</varlistentry>
<varlistentry>
<term>tree</term>
<listitem><para>Tree widget internals</para></listitem>
......
......@@ -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
......
......@@ -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 &&
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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 &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment