[gtk+/touchscreens: 39/65] gtk, pah: Show a bigger press-and-hold indicator on touchscreens
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touchscreens: 39/65] gtk, pah: Show a bigger press-and-hold indicator on touchscreens
- Date: Tue, 13 Dec 2011 18:59:21 +0000 (UTC)
commit 6f1c468621f2bf4e62355d5f33ab7538d2a5417e
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Nov 23 21:40:53 2011 +0100
gtk,pah: Show a bigger press-and-hold indicator on touchscreens
On touch devices it uses a 2.5cm diameter via gdk_screen_get_width_mm()
in the hope that it'll pop out of the finger area.
gtk/gtkwidget.c | 37 ++++++++++++++++++++++---------------
1 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 236bec4..6c6411b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -547,6 +547,7 @@ typedef struct
/* animation */
GtkWidget *popup;
guint delay_animation_id;
+ guint size;
gint start_x;
gint start_y;
@@ -7020,14 +7021,9 @@ _gtk_widget_press_and_hold_check_threshold (GtkWidget *widget,
}
if (data->popup)
- {
- guint cursor_size;
-
- cursor_size = gdk_display_get_default_cursor_size (gtk_widget_get_display (widget));
- gtk_window_move (GTK_WINDOW (data->popup),
- event->x_root - cursor_size / 2,
- event->y_root - cursor_size / 2);
- }
+ gtk_window_move (GTK_WINDOW (data->popup),
+ event->x_root - data->size / 2,
+ event->y_root - data->size / 2);
return FALSE;
}
@@ -7123,17 +7119,15 @@ gtk_widget_press_and_hold_begin_animation_timeout (gpointer user_data)
GtkWidget *widget = GTK_WIDGET (user_data);
PressAndHoldData *data;
gint x, y;
- guint cursor_size;
data = gtk_widget_peek_press_and_hold_data (widget);
g_assert (data != NULL);
gdk_window_get_device_position (gdk_screen_get_root_window (gtk_widget_get_screen (widget)),
data->device, &x, &y, NULL);
- cursor_size = gdk_display_get_default_cursor_size (gtk_widget_get_display (widget));
gtk_window_move (GTK_WINDOW (data->popup),
- x - cursor_size / 2,
- y - cursor_size / 2);
+ x - data->size / 2,
+ y - data->size / 2);
gtk_widget_show (data->popup);
gtk_widget_set_state_flags (GTK_WIDGET (data->popup),
@@ -7178,11 +7172,13 @@ _gtk_widget_press_and_hold_check_start (GtkWidget *widget,
if (gtk_widget_press_and_hold_query (widget, data->device,
event->x, event->y))
{
- gint timeout, begin_ani_timeout, cursor_size;
+ gint timeout, begin_ani_timeout;
GdkScreen *screen;
GdkVisual *visual;
GtkStyleContext *context;
cairo_region_t *region;
+ GdkDevice *source_device;
+ GdkInputSource source;
_gtk_widget_find_at_coords (event->window,
event->x, event->y,
@@ -7213,8 +7209,19 @@ _gtk_widget_press_and_hold_check_start (GtkWidget *widget,
G_CALLBACK (press_and_hold_animation_draw),
widget);
- cursor_size = gdk_display_get_default_cursor_size (gtk_widget_get_display (widget));
- gtk_window_resize (GTK_WINDOW (data->popup), cursor_size, cursor_size);
+ source_device = gdk_event_get_source_device ((GdkEvent *) event);
+ source = gdk_device_get_source (source_device);
+
+ if (source == GDK_SOURCE_TOUCH)
+ {
+ /* Have an indicator with 2.5cm of diameter */
+ data->size = (25 * gdk_screen_get_width (screen)) /
+ gdk_screen_get_width_mm (screen);
+ }
+ else
+ data->size = gdk_display_get_default_cursor_size (gtk_widget_get_display (widget));
+
+ gtk_window_resize (GTK_WINDOW (data->popup), data->size, data->size);
region = cairo_region_create ();
gdk_window_input_shape_combine_region (gtk_widget_get_window (data->popup), region, 0, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]