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.
This commit is contained in:
Carlos Garnacho
2012-01-12 02:11:01 +01:00
parent 075911ccfd
commit c38159d4d7
3 changed files with 18 additions and 10 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);