[gtk+/xi21: 8/12] Add gdk_window_[create|remove]_touch_cluster()



commit 776477ee9628e5bc9317197b432704dcf0781a3b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 11 20:53:07 2011 +0100

    Add gdk_window_[create|remove]_touch_cluster()
    
    These are the functions to create/destroy a GdkTouchCluster,
    as they are associated to GdkWindows.

 docs/reference/gdk/gdk3-sections.txt |    4 +++
 gdk/gdkinternals.h                   |    2 +
 gdk/gdkwindow.c                      |   49 ++++++++++++++++++++++++++++++++++
 gdk/gdkwindow.h                      |    6 ++++
 4 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 7c4986b..00c6fa0 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -856,6 +856,10 @@ gdk_touch_cluster_set_device
 gdk_touch_cluster_get_device
 gdk_touch_cluster_get_touches
 
+<SUBSECTION>
+gdk_window_create_touch_cluster
+gdk_window_remove_touch_cluster
+
 <SUBSECTION Standard>
 GDK_TYPE_TOUCH_CLUSTER
 
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 4fd8129..817b260 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -248,6 +248,8 @@ struct _GdkWindow
   GHashTable *source_event_masks;
   gulong device_added_handler_id;
   gulong device_changed_handler_id;
+
+  GList *touch_clusters;
 };
 
 #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type)
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 413e2ce..c6a2147 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -567,6 +567,9 @@ gdk_window_finalize (GObject *object)
   if (window->devices_inside)
     g_list_free (window->devices_inside);
 
+  g_list_foreach (window->touch_clusters, (GFunc) g_object_unref, NULL);
+  g_list_free (window->touch_clusters);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -10925,3 +10928,49 @@ gdk_property_delete (GdkWindow *window,
 {
   GDK_WINDOW_IMPL_GET_CLASS (window->impl)->delete_property (window, property);
 }
+
+/**
+ * gdk_window_create_touch_cluster:
+ * @window: a #GdkWindow
+ *
+ * Creates a #GdkTouchCluster associated to @window.
+ *
+ * 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)
+{
+  GdkTouchCluster *cluster;
+
+  g_return_val_if_fail (GDK_IS_WINDOW (window), NULL);
+
+  cluster = g_object_new (GDK_TYPE_TOUCH_CLUSTER, NULL);
+  window->touch_clusters = g_list_prepend (window->touch_clusters, cluster);
+
+  return cluster;
+}
+
+/**
+ * gdk_window_remove_touch_cluster:
+ * @window: a #GdkWindow
+ * @cluster: a #GdkTouchCluster from @window
+ *
+ * Removes @cluster from @window.
+ **/
+void
+gdk_window_remove_touch_cluster (GdkWindow       *window,
+                                 GdkTouchCluster *cluster)
+{
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (GDK_IS_TOUCH_CLUSTER (cluster));
+
+  if (!window->touch_clusters ||
+      !g_list_find (window->touch_clusters, cluster))
+    return;
+
+  gdk_touch_cluster_remove_all (cluster);
+  window->touch_clusters = g_list_remove (window->touch_clusters, cluster);
+  g_object_unref (cluster);
+}
diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h
index b400ee4..005b9c3 100644
--- a/gdk/gdkwindow.h
+++ b/gdk/gdkwindow.h
@@ -33,6 +33,7 @@
 
 #include <gdk/gdktypes.h>
 #include <gdk/gdkevents.h>
+#include <gdk/gdktouchcluster.h>
 
 G_BEGIN_DECLS
 
@@ -862,6 +863,11 @@ void       gdk_window_set_support_multidevice (GdkWindow *window,
                                                gboolean   support_multidevice);
 gboolean   gdk_window_get_support_multidevice (GdkWindow *window);
 
+/* Multitouch support */
+GdkTouchCluster * gdk_window_create_touch_cluster (GdkWindow       *window);
+void              gdk_window_remove_touch_cluster (GdkWindow       *window,
+                                                   GdkTouchCluster *cluster);
+
 G_END_DECLS
 
 #endif /* __GDK_WINDOW_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]