commit 5234b83

Michael Forney  ·  2014-02-23 22:13:47 +0000 UTC
parent 6fef8ee
compositor: Use compositor_view directly
5 files changed,  +60, -73
+11, -55
  1@@ -61,33 +61,6 @@ struct target
  2     struct wl_listener screen_listener;
  3 };
  4 
  5-struct compositor_view
  6-{
  7-    struct swc_view base;
  8-    struct wl_listener event_listener;
  9-    struct swc_surface * surface;
 10-    struct wld_buffer * buffer;
 11-
 12-    /* Whether or not the view is visible (mapped). */
 13-    bool visible;
 14-
 15-    /* The box that the surface covers (including it's border). */
 16-    pixman_box32_t extents;
 17-
 18-    /* The region that is covered by opaque regions of surfaces above this
 19-     * surface. */
 20-    pixman_region32_t clip;
 21-
 22-    struct
 23-    {
 24-        uint32_t width;
 25-        uint32_t color;
 26-        bool damaged;
 27-    } border;
 28-
 29-    struct wl_list link;
 30-};
 31-
 32 static bool handle_motion(struct pointer_handler * handler, uint32_t time,
 33                           wl_fixed_t x, wl_fixed_t y);
 34 static void perform_update(void * data);
 35@@ -515,7 +488,8 @@ static void handle_view_event(struct wl_listener * listener, void * data)
 36     }
 37 }
 38 
 39-struct swc_view * swc_compositor_create_view(struct swc_surface * surface)
 40+struct compositor_view * swc_compositor_create_view
 41+    (struct swc_surface * surface)
 42 {
 43     struct compositor_view * view;
 44 
 45@@ -540,28 +514,20 @@ struct swc_view * swc_compositor_create_view(struct swc_surface * surface)
 46     pixman_region32_init(&view->clip);
 47     swc_surface_set_view(surface, &view->base);
 48 
 49-    return &view->base;
 50+    return view;
 51 }
 52 
 53-void compositor_view_destroy(struct swc_view * base)
 54+void compositor_view_destroy(struct compositor_view * view)
 55 {
 56-    struct compositor_view * view = (void *) base;
 57-
 58-    assert(view->base.impl == &view_impl);
 59-
 60-    compositor_view_hide(&view->base);
 61+    compositor_view_hide(view);
 62     swc_surface_set_view(view->surface, NULL);
 63     swc_view_finalize(&view->base);
 64     pixman_region32_fini(&view->clip);
 65     free(view);
 66 }
 67 
 68-void compositor_view_show(struct swc_view * base)
 69+void compositor_view_show(struct compositor_view * view)
 70 {
 71-    struct compositor_view * view = (void *) base;
 72-
 73-    assert(view->base.impl == &view_impl);
 74-
 75     if (view->visible)
 76         return;
 77 
 78@@ -577,12 +543,8 @@ void compositor_view_show(struct swc_view * base)
 79     wl_list_insert(&compositor.views, &view->link);
 80 }
 81 
 82-void compositor_view_hide(struct swc_view * base)
 83+void compositor_view_hide(struct compositor_view * view)
 84 {
 85-    struct compositor_view * view = (void *) base;
 86-
 87-    assert(view->base.impl == &view_impl);
 88-
 89     if (!view->visible)
 90         return;
 91 
 92@@ -595,12 +557,9 @@ void compositor_view_hide(struct swc_view * base)
 93     view->visible = false;
 94 }
 95 
 96-void compositor_view_set_border_width(struct swc_view * base, uint32_t width)
 97+void compositor_view_set_border_width(struct compositor_view * view,
 98+                                      uint32_t width)
 99 {
100-    struct compositor_view * view = (void *) base;
101-
102-    assert(view->base.impl == &view_impl);
103-
104     if (view->border.width == width)
105         return;
106 
107@@ -613,12 +572,9 @@ void compositor_view_set_border_width(struct swc_view * base, uint32_t width)
108     update(&view->base);
109 }
110 
111-void compositor_view_set_border_color(struct swc_view * base, uint32_t color)
112+void compositor_view_set_border_color(struct compositor_view * view,
113+                                      uint32_t color)
114 {
115-    struct compositor_view * view = (void *) base;
116-
117-    assert(view->base.impl == &view_impl);
118-
119     if (view->border.color == color)
120         return;
121 
+38, -8
 1@@ -24,9 +24,10 @@
 2 #ifndef SWC_COMPOSITOR_H
 3 #define SWC_COMPOSITOR_H
 4 
 5-#include <stdbool.h>
 6+#include "view.h"
 7 
 8-struct swc_surface;
 9+#include <stdbool.h>
10+#include <pixman.h>
11 
12 struct swc_compositor
13 {
14@@ -36,16 +37,45 @@ struct swc_compositor
15 bool swc_compositor_initialize();
16 void swc_compositor_finalize();
17 
18-struct swc_view * swc_compositor_create_view
19+struct compositor_view
20+{
21+    struct swc_view base;
22+    struct wl_listener event_listener;
23+    struct swc_surface * surface;
24+    struct wld_buffer * buffer;
25+
26+    /* Whether or not the view is visible (mapped). */
27+    bool visible;
28+
29+    /* The box that the surface covers (including it's border). */
30+    pixman_box32_t extents;
31+
32+    /* The region that is covered by opaque regions of surfaces above this
33+     * surface. */
34+    pixman_region32_t clip;
35+
36+    struct
37+    {
38+        uint32_t width;
39+        uint32_t color;
40+        bool damaged;
41+    } border;
42+
43+    struct wl_list link;
44+};
45+
46+struct compositor_view * swc_compositor_create_view
47     (struct swc_surface * surface);
48 
49-void compositor_view_destroy(struct swc_view * view);
50+void compositor_view_destroy(struct compositor_view * view);
51 
52-void compositor_view_show(struct swc_view * view);
53-void compositor_view_hide(struct swc_view * view);
54+void compositor_view_show(struct compositor_view * view);
55+void compositor_view_hide(struct compositor_view * view);
56 
57-void compositor_view_set_border_color(struct swc_view * view, uint32_t color);
58-void compositor_view_set_border_width(struct swc_view * view, uint32_t width);
59+void compositor_view_set_border_color(struct compositor_view * view,
60+                                      uint32_t color);
61+void compositor_view_set_border_width(struct compositor_view * view,
62+                                      uint32_t width);
63 
64 #endif
65 
+4, -4
 1@@ -42,7 +42,7 @@ struct panel
 2 
 3     struct swc_surface * surface;
 4     struct wl_listener surface_destroy_listener;
 5-    struct swc_view * view;
 6+    struct compositor_view * view;
 7     struct wl_listener view_listener;
 8     struct screen * screen;
 9     struct screen_modifier modifier;
10@@ -55,7 +55,7 @@ static void update_position(struct panel * panel)
11 {
12     int32_t x, y;
13     struct swc_rectangle * screen = &panel->screen->base.geometry,
14-                         * view = &panel->view->geometry;
15+                         * view = &panel->view->base.geometry;
16 
17     switch (panel->edge)
18     {
19@@ -78,7 +78,7 @@ static void update_position(struct panel * panel)
20         default: return;
21     }
22 
23-    swc_view_move(panel->surface->view, x, y);
24+    swc_view_move(&panel->view->base, x, y);
25 }
26 
27 static void dock(struct wl_client * client, struct wl_resource * resource,
28@@ -128,7 +128,7 @@ static void dock(struct wl_client * client, struct wl_resource * resource,
29 
30     update_position(panel);
31     compositor_view_show(panel->view);
32-    wl_signal_add(&panel->view->event_signal, &panel->view_listener);
33+    wl_signal_add(&panel->view->base.event_signal, &panel->view_listener);
34     wl_list_insert(&screen->modifiers, &panel->modifier.link);
35 
36     if (focus)
+6, -5
 1@@ -99,14 +99,14 @@ void swc_window_set_geometry(struct swc_window * base,
 2     if (window->impl->configure)
 3         window->impl->configure(window, geometry);
 4 
 5-    swc_view_move(window->view, geometry->x, geometry->y);
 6+    swc_view_move(&window->view->base, geometry->x, geometry->y);
 7 }
 8 
 9 EXPORT
10 void swc_window_set_border(struct swc_window * window,
11                            uint32_t border_color, uint32_t border_width)
12 {
13-    struct swc_view * view = INTERNAL(window)->view;
14+    struct compositor_view * view = INTERNAL(window)->view;
15 
16     compositor_view_set_border_color(view, border_color);
17     compositor_view_set_border_width(view, border_width);
18@@ -130,7 +130,7 @@ static inline void window_begin_interaction
19 void window_begin_interactive_move(struct window * window,
20                                    struct button_press * button)
21 {
22-    struct swc_rectangle * geometry = &window->view->geometry;
23+    struct swc_rectangle * geometry = &window->view->base.geometry;
24     int32_t px = wl_fixed_to_int(swc.seat->pointer->x),
25             py = wl_fixed_to_int(swc.seat->pointer->y);
26 
27@@ -190,8 +190,9 @@ static bool move_motion(struct pointer_handler * handler, uint32_t time,
28     struct window * window
29         = CONTAINER_OF(handler, typeof(*window), move.interaction.handler);
30 
31-    swc_view_move(window->view, wl_fixed_to_int(fx) + window->move.offset.x,
32-                                wl_fixed_to_int(fy) + window->move.offset.y);
33+    swc_view_move(&window->view->base,
34+                  wl_fixed_to_int(fx) + window->move.offset.x,
35+                  wl_fixed_to_int(fy) + window->move.offset.y);
36 
37     return true;
38 }
+1, -1
1@@ -41,7 +41,7 @@ struct window
2     const struct window_impl * impl;
3 
4     struct swc_surface * surface;
5-    struct swc_view * view;
6+    struct compositor_view * view;
7 
8     struct
9     {