[gtk+/multitouch: 110/129] gdkwindow: Add device parameter to gdk_window_create_touch_cluster()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 110/129] gdkwindow: Add device parameter to gdk_window_create_touch_cluster()
- Date: Sat, 18 Feb 2012 17:15:35 +0000 (UTC)
commit c38159d4d78feb0500fc052dab4e21e92203fcbe
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jan 12 02:11:01 2012 +0100
gdkwindow: Add device parameter to gdk_window_create_touch_cluster()
gdk_touch_cluster_set_device() had to be called right after anyway,
so set the device directly within this call, and favor the most common
scenario where there's just 1 single multitouch device behind 1 master
device.
demos/gtk-demo/multitouch.c | 15 ++++++++-------
gdk/gdkwindow.c | 10 ++++++++--
gdk/gdkwindow.h | 3 ++-
3 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/demos/gtk-demo/multitouch.c b/demos/gtk-demo/multitouch.c
index a85161f..0fcec64 100644
--- a/demos/gtk-demo/multitouch.c
+++ b/demos/gtk-demo/multitouch.c
@@ -410,13 +410,14 @@ button_press_cb (GtkWidget *widget,
shape_update_scales (shape);
if (!shape->cluster)
- shape->cluster = gdk_window_create_touch_cluster (gtk_widget_get_window (widget));
-
- /* Only change cluster device if there were no touches or no device */
- if (!gdk_touch_cluster_get_device (shape->cluster) ||
- !gdk_touch_cluster_get_touches (shape->cluster))
- gdk_touch_cluster_set_device (shape->cluster,
- gdk_event_get_device (event));
+ shape->cluster = gdk_window_create_touch_cluster (gtk_widget_get_window (widget),
+ gdk_event_get_device (event));
+ else if (!gdk_touch_cluster_get_touches (shape->cluster))
+ {
+ /* Only change cluster device if there were no touches */
+ gdk_touch_cluster_set_device (shape->cluster,
+ gdk_event_get_device (event));
+ }
gdk_touch_cluster_add_touch (shape->cluster, touch_id);
return TRUE;
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 6c6ce97..5103d44 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -11617,19 +11617,23 @@ touch_cluster_touch_removed (GdkTouchCluster *cluster,
/**
* gdk_window_create_touch_cluster:
* @window: a #GdkWindow
+ * @device: device to be associated to the cluster
*
- * Creates a #GdkTouchCluster associated to @window.
+ * Creates a #GdkTouchCluster associated to @window, with @device
+ * as its current device.
*
* Returns: (transfer none): a newly created @GdkTouchCluster. This
* object is owned by @window and must be freed through
* gdk_window_remove_touch_cluster().
**/
GdkTouchCluster *
-gdk_window_create_touch_cluster (GdkWindow *window)
+gdk_window_create_touch_cluster (GdkWindow *window,
+ GdkDevice *device)
{
GdkTouchCluster *cluster;
g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
cluster = g_object_new (GDK_TYPE_TOUCH_CLUSTER, NULL);
g_signal_connect (cluster, "touch-added",
@@ -11637,6 +11641,8 @@ gdk_window_create_touch_cluster (GdkWindow *window)
g_signal_connect (cluster, "touch-removed",
G_CALLBACK (touch_cluster_touch_removed), window);
+ gdk_touch_cluster_set_device (cluster, device);
+
window->touch_clusters = g_list_prepend (window->touch_clusters, cluster);
return cluster;
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index cd70cf3..86afd91 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -880,7 +880,8 @@ void gdk_window_set_support_multidevice (GdkWindow *window,
gboolean gdk_window_get_support_multidevice (GdkWindow *window);
/* Multitouch support */
-GdkTouchCluster * gdk_window_create_touch_cluster (GdkWindow *window);
+GdkTouchCluster * gdk_window_create_touch_cluster (GdkWindow *window,
+ GdkDevice *device);
void gdk_window_remove_touch_cluster (GdkWindow *window,
GdkTouchCluster *cluster);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]