summaryrefslogtreecommitdiff
path: root/server/tree.c
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-11-13 10:29:14 -0600
committerFrediano Ziglio <fziglio@redhat.com>2015-11-17 17:22:05 +0000
commit5897952f46881a3324c9c7be9339065310011079 (patch)
tree026b09e2911fbc6ec698724e5ab9eaf4ea25d7e9 /server/tree.c
parentf6106afa4f83c945892775cef0a1a3e342fdf22b (diff)
Move some tree item functions to tree.[ch]
Also rename some functions slightly: __find_shadow -> tree_item_find_shadow() __contained_by -> tree_item_contained_by() ring_of -> tree_item_container_items(); Acked-by: Fabiano FidĂȘncio <fidencio@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
Diffstat (limited to 'server/tree.c')
-rw-r--r--server/tree.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/server/tree.c b/server/tree.c
index ad31f09b..a3dfbde2 100644
--- a/server/tree.c
+++ b/server/tree.c
@@ -250,3 +250,52 @@ void container_cleanup(Container *container)
container = next;
}
}
+
+/* FIXME: document weird function: go down containers, and return drawable->shadow? */
+Shadow* tree_item_find_shadow(TreeItem *item)
+{
+ while (item->type == TREE_ITEM_TYPE_CONTAINER) {
+ if (!(item = (TreeItem *)ring_get_tail(&((Container *)item)->items))) {
+ return NULL;
+ }
+ }
+
+ if (item->type != TREE_ITEM_TYPE_DRAWABLE) {
+ return NULL;
+ }
+
+ return ((DrawItem *)item)->shadow;
+}
+
+Ring *tree_item_container_items(TreeItem *item, Ring *ring)
+{
+ return (item->container) ? &item->container->items : ring;
+}
+
+int tree_item_contained_by(TreeItem *item, Ring *ring)
+{
+ spice_assert(item && ring);
+ do {
+ Ring *now = tree_item_container_items(item, ring);
+ if (now == ring) {
+ return TRUE;
+ }
+ } while ((item = (TreeItem *)item->container));
+
+ return FALSE;
+}
+
+void draw_item_remove_shadow(DrawItem *item)
+{
+ Shadow *shadow;
+
+ if (!item->shadow) {
+ return;
+ }
+ shadow = item->shadow;
+ item->shadow = NULL;
+ ring_remove(&shadow->base.siblings_link);
+ region_destroy(&shadow->base.rgn);
+ region_destroy(&shadow->on_hold);
+ free(shadow);
+}