diff --git a/demos/gtk-demo/multitouch.c b/demos/gtk-demo/multitouch.c index a85161f638..0fcec64ca0 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 6c6ce974fe..5103d44db7 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 cd70cf3add..86afd91e17 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);