commit 32a2608

Michael Forney  ·  2014-11-30 00:55:53 +0000 UTC
parent dc33892
compositor: Look for the parent in the view list

This way, we don't have to keep track of the children list.
2 files changed,  +13, -16
+12, -15
 1@@ -480,7 +480,6 @@ struct compositor_view * swc_compositor_create_view
 2     view->border.color = 0x000000;
 3     view->border.damaged = false;
 4     pixman_region32_init(&view->clip);
 5-    wl_list_init(&view->children);
 6     wl_signal_init(&view->destroy_signal);
 7     swc_surface_set_view(surface, &view->base);
 8     wl_list_insert(&compositor.views, &view->link);
 9@@ -496,10 +495,6 @@ void compositor_view_destroy(struct compositor_view * view)
10     view_finalize(&view->base);
11     pixman_region32_fini(&view->clip);
12     wl_list_remove(&view->link);
13-
14-    if (view->parent)
15-        wl_list_remove(&view->child_link);
16-
17     free(view);
18 }
19 
20@@ -511,11 +506,7 @@ struct compositor_view * compositor_view(struct view * view)
21 void compositor_view_set_parent(struct compositor_view * view,
22                                 struct compositor_view * parent)
23 {
24-    if (view->parent)
25-        wl_list_remove(&view->child_link);
26-
27     view->parent = view;
28-    wl_list_insert(&parent->children, &view->child_link);
29 
30     if (parent->visible)
31         compositor_view_show(view);
32@@ -525,7 +516,7 @@ void compositor_view_set_parent(struct compositor_view * view,
33 
34 void compositor_view_show(struct compositor_view * view)
35 {
36-    struct compositor_view * child;
37+    struct compositor_view * other;
38 
39     if (view->visible)
40         return;
41@@ -540,13 +531,16 @@ void compositor_view_show(struct compositor_view * view)
42     damage_view(view);
43     update(&view->base);
44 
45-    wl_list_for_each(child, &view->children, child_link)
46-        compositor_view_show(child);
47+    wl_list_for_each(other, &compositor.views, link)
48+    {
49+        if (other->parent == view)
50+            compositor_view_show(other);
51+    }
52 }
53 
54 void compositor_view_hide(struct compositor_view * view)
55 {
56-    struct compositor_view * child;
57+    struct compositor_view * other;
58 
59     if (!view->visible)
60         return;
61@@ -558,8 +552,11 @@ void compositor_view_hide(struct compositor_view * view)
62     view_set_screens(&view->base, 0);
63     view->visible = false;
64 
65-    wl_list_for_each(child, &view->children, child_link)
66-        compositor_view_hide(child);
67+    wl_list_for_each(other, &compositor.views, link)
68+    {
69+        if (other->parent == view)
70+            compositor_view_hide(other);
71+    }
72 }
73 
74 void compositor_view_set_border_width(struct compositor_view * view,
+1, -1
1@@ -72,7 +72,7 @@ struct compositor_view
2         bool damaged;
3     } border;
4 
5-    struct wl_list link, children, child_link;
6+    struct wl_list link;
7     struct wl_signal destroy_signal;
8 };
9