Add a way to test touch features
The GTK_TEST_TOUCHSCREEN envvar is now checked in entries and textviews to allow testing of text handles with other kinds of devices.
This commit is contained in:
@ -318,6 +318,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
static gboolean test_touchscreen = FALSE;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CURSOR_STANDARD,
|
CURSOR_STANDARD,
|
||||||
@ -1938,6 +1939,7 @@ gtk_entry_class_init (GtkEntryClass *class)
|
|||||||
G_PARAM_DEPRECATED));
|
G_PARAM_DEPRECATED));
|
||||||
|
|
||||||
g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate));
|
g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate));
|
||||||
|
test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN") != NULL;
|
||||||
|
|
||||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE);
|
||||||
}
|
}
|
||||||
@ -4044,7 +4046,8 @@ gtk_entry_button_press (GtkWidget *widget,
|
|||||||
GdkDevice *source;
|
GdkDevice *source;
|
||||||
|
|
||||||
source = gdk_event_get_source_device ((GdkEvent *) event);
|
source = gdk_event_get_source_device ((GdkEvent *) event);
|
||||||
is_touchscreen = gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
|
is_touchscreen = test_touchscreen ||
|
||||||
|
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
|
||||||
|
|
||||||
priv->select_words = FALSE;
|
priv->select_words = FALSE;
|
||||||
priv->select_lines = FALSE;
|
priv->select_lines = FALSE;
|
||||||
@ -4229,7 +4232,8 @@ gtk_entry_button_release (GtkWidget *widget,
|
|||||||
|
|
||||||
source = gdk_event_get_source_device ((GdkEvent *) event);
|
source = gdk_event_get_source_device ((GdkEvent *) event);
|
||||||
|
|
||||||
if (gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
|
if (test_touchscreen ||
|
||||||
|
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
|
||||||
gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
|
gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
|
||||||
|
|
||||||
priv->in_drag = 0;
|
priv->in_drag = 0;
|
||||||
@ -4411,7 +4415,7 @@ gtk_entry_motion_notify (GtkWidget *widget,
|
|||||||
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 (input_source == GDK_SOURCE_TOUCHSCREEN)
|
if (test_touchscreen || input_source == GDK_SOURCE_TOUCHSCREEN)
|
||||||
gtk_entry_update_handles (entry,
|
gtk_entry_update_handles (entry,
|
||||||
(priv->current_pos == priv->selection_bound) ?
|
(priv->current_pos == priv->selection_bound) ?
|
||||||
GTK_TEXT_HANDLE_MODE_CURSOR :
|
GTK_TEXT_HANDLE_MODE_CURSOR :
|
||||||
|
@ -574,6 +574,7 @@ static gint text_window_get_height (GtkTextWindow *win);
|
|||||||
|
|
||||||
|
|
||||||
static guint signals[LAST_SIGNAL] = { 0 };
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
|
static gboolean test_touchscreen = FALSE;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkTextView, gtk_text_view, GTK_TYPE_CONTAINER,
|
G_DEFINE_TYPE_WITH_CODE (GtkTextView, gtk_text_view, GTK_TYPE_CONTAINER,
|
||||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
|
||||||
@ -1405,6 +1406,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
|||||||
g_type_class_add_private (gobject_class, sizeof (GtkTextViewPrivate));
|
g_type_class_add_private (gobject_class, sizeof (GtkTextViewPrivate));
|
||||||
|
|
||||||
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_VIEW_ACCESSIBLE);
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_VIEW_ACCESSIBLE);
|
||||||
|
test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN") != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4808,7 +4810,8 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
device = gdk_event_get_source_device ((GdkEvent *) event);
|
device = gdk_event_get_source_device ((GdkEvent *) event);
|
||||||
is_touchscreen = gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
|
is_touchscreen = test_touchscreen ||
|
||||||
|
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
|
||||||
|
|
||||||
if (event->type == GDK_BUTTON_PRESS)
|
if (event->type == GDK_BUTTON_PRESS)
|
||||||
{
|
{
|
||||||
@ -4952,7 +4955,8 @@ gtk_text_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
|
|||||||
device = gdk_event_get_source_device ((GdkEvent *) event);
|
device = gdk_event_get_source_device ((GdkEvent *) event);
|
||||||
|
|
||||||
if (gtk_widget_is_sensitive (widget) &&
|
if (gtk_widget_is_sensitive (widget) &&
|
||||||
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)
|
(test_touchscreen ||
|
||||||
|
gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN))
|
||||||
mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
||||||
else
|
else
|
||||||
mode = GTK_TEXT_HANDLE_MODE_NONE;
|
mode = GTK_TEXT_HANDLE_MODE_NONE;
|
||||||
@ -6759,7 +6763,7 @@ selection_motion_event_handler (GtkTextView *text_view,
|
|||||||
text_view->priv->scroll_timeout =
|
text_view->priv->scroll_timeout =
|
||||||
gdk_threads_add_timeout (50, selection_scan_timeout, text_view);
|
gdk_threads_add_timeout (50, selection_scan_timeout, text_view);
|
||||||
|
|
||||||
if (input_source == GDK_SOURCE_TOUCHSCREEN)
|
if (test_touchscreen || input_source == GDK_SOURCE_TOUCHSCREEN)
|
||||||
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
|
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Reference in New Issue
Block a user