swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 5234b837be457ddf8138b389826750d329bc2cb9
parent 6fef8ee07a584c0f029ec2af1b3b04cc45311279
Author: Michael Forney <mforney@mforney.org>
Date:   Sun, 23 Feb 2014 14:13:47 -0800

compositor: Use compositor_view directly

Diffstat:
Mlibswc/compositor.c | 66+++++++++++-------------------------------------------------------
Mlibswc/compositor.h | 46++++++++++++++++++++++++++++++++++++++--------
Mlibswc/panel.c | 8++++----
Mlibswc/window.c | 11++++++-----
Mlibswc/window.h | 2+-
5 files changed, 60 insertions(+), 73 deletions(-)

diff --git a/libswc/compositor.c b/libswc/compositor.c @@ -61,33 +61,6 @@ struct target struct wl_listener screen_listener; }; -struct compositor_view -{ - struct swc_view base; - struct wl_listener event_listener; - struct swc_surface * surface; - struct wld_buffer * buffer; - - /* Whether or not the view is visible (mapped). */ - bool visible; - - /* The box that the surface covers (including it's border). */ - pixman_box32_t extents; - - /* The region that is covered by opaque regions of surfaces above this - * surface. */ - pixman_region32_t clip; - - struct - { - uint32_t width; - uint32_t color; - bool damaged; - } border; - - struct wl_list link; -}; - static bool handle_motion(struct pointer_handler * handler, uint32_t time, wl_fixed_t x, wl_fixed_t y); static void perform_update(void * data); @@ -515,7 +488,8 @@ static void handle_view_event(struct wl_listener * listener, void * data) } } -struct swc_view * swc_compositor_create_view(struct swc_surface * surface) +struct compositor_view * swc_compositor_create_view + (struct swc_surface * surface) { struct compositor_view * view; @@ -540,28 +514,20 @@ struct swc_view * swc_compositor_create_view(struct swc_surface * surface) pixman_region32_init(&view->clip); swc_surface_set_view(surface, &view->base); - return &view->base; + return view; } -void compositor_view_destroy(struct swc_view * base) +void compositor_view_destroy(struct compositor_view * view) { - struct compositor_view * view = (void *) base; - - assert(view->base.impl == &view_impl); - - compositor_view_hide(&view->base); + compositor_view_hide(view); swc_surface_set_view(view->surface, NULL); swc_view_finalize(&view->base); pixman_region32_fini(&view->clip); free(view); } -void compositor_view_show(struct swc_view * base) +void compositor_view_show(struct compositor_view * view) { - struct compositor_view * view = (void *) base; - - assert(view->base.impl == &view_impl); - if (view->visible) return; @@ -577,12 +543,8 @@ void compositor_view_show(struct swc_view * base) wl_list_insert(&compositor.views, &view->link); } -void compositor_view_hide(struct swc_view * base) +void compositor_view_hide(struct compositor_view * view) { - struct compositor_view * view = (void *) base; - - assert(view->base.impl == &view_impl); - if (!view->visible) return; @@ -595,12 +557,9 @@ void compositor_view_hide(struct swc_view * base) view->visible = false; } -void compositor_view_set_border_width(struct swc_view * base, uint32_t width) +void compositor_view_set_border_width(struct compositor_view * view, + uint32_t width) { - struct compositor_view * view = (void *) base; - - assert(view->base.impl == &view_impl); - if (view->border.width == width) return; @@ -613,12 +572,9 @@ void compositor_view_set_border_width(struct swc_view * base, uint32_t width) update(&view->base); } -void compositor_view_set_border_color(struct swc_view * base, uint32_t color) +void compositor_view_set_border_color(struct compositor_view * view, + uint32_t color) { - struct compositor_view * view = (void *) base; - - assert(view->base.impl == &view_impl); - if (view->border.color == color) return; diff --git a/libswc/compositor.h b/libswc/compositor.h @@ -24,9 +24,10 @@ #ifndef SWC_COMPOSITOR_H #define SWC_COMPOSITOR_H -#include <stdbool.h> +#include "view.h" -struct swc_surface; +#include <stdbool.h> +#include <pixman.h> struct swc_compositor { @@ -36,16 +37,45 @@ struct swc_compositor bool swc_compositor_initialize(); void swc_compositor_finalize(); -struct swc_view * swc_compositor_create_view +struct compositor_view +{ + struct swc_view base; + struct wl_listener event_listener; + struct swc_surface * surface; + struct wld_buffer * buffer; + + /* Whether or not the view is visible (mapped). */ + bool visible; + + /* The box that the surface covers (including it's border). */ + pixman_box32_t extents; + + /* The region that is covered by opaque regions of surfaces above this + * surface. */ + pixman_region32_t clip; + + struct + { + uint32_t width; + uint32_t color; + bool damaged; + } border; + + struct wl_list link; +}; + +struct compositor_view * swc_compositor_create_view (struct swc_surface * surface); -void compositor_view_destroy(struct swc_view * view); +void compositor_view_destroy(struct compositor_view * view); -void compositor_view_show(struct swc_view * view); -void compositor_view_hide(struct swc_view * view); +void compositor_view_show(struct compositor_view * view); +void compositor_view_hide(struct compositor_view * view); -void compositor_view_set_border_color(struct swc_view * view, uint32_t color); -void compositor_view_set_border_width(struct swc_view * view, uint32_t width); +void compositor_view_set_border_color(struct compositor_view * view, + uint32_t color); +void compositor_view_set_border_width(struct compositor_view * view, + uint32_t width); #endif diff --git a/libswc/panel.c b/libswc/panel.c @@ -42,7 +42,7 @@ struct panel struct swc_surface * surface; struct wl_listener surface_destroy_listener; - struct swc_view * view; + struct compositor_view * view; struct wl_listener view_listener; struct screen * screen; struct screen_modifier modifier; @@ -55,7 +55,7 @@ static void update_position(struct panel * panel) { int32_t x, y; struct swc_rectangle * screen = &panel->screen->base.geometry, - * view = &panel->view->geometry; + * view = &panel->view->base.geometry; switch (panel->edge) { @@ -78,7 +78,7 @@ static void update_position(struct panel * panel) default: return; } - swc_view_move(panel->surface->view, x, y); + swc_view_move(&panel->view->base, x, y); } static void dock(struct wl_client * client, struct wl_resource * resource, @@ -128,7 +128,7 @@ static void dock(struct wl_client * client, struct wl_resource * resource, update_position(panel); compositor_view_show(panel->view); - wl_signal_add(&panel->view->event_signal, &panel->view_listener); + wl_signal_add(&panel->view->base.event_signal, &panel->view_listener); wl_list_insert(&screen->modifiers, &panel->modifier.link); if (focus) diff --git a/libswc/window.c b/libswc/window.c @@ -99,14 +99,14 @@ void swc_window_set_geometry(struct swc_window * base, if (window->impl->configure) window->impl->configure(window, geometry); - swc_view_move(window->view, geometry->x, geometry->y); + swc_view_move(&window->view->base, geometry->x, geometry->y); } EXPORT void swc_window_set_border(struct swc_window * window, uint32_t border_color, uint32_t border_width) { - struct swc_view * view = INTERNAL(window)->view; + struct compositor_view * view = INTERNAL(window)->view; compositor_view_set_border_color(view, border_color); compositor_view_set_border_width(view, border_width); @@ -130,7 +130,7 @@ static inline void window_begin_interaction void window_begin_interactive_move(struct window * window, struct button_press * button) { - struct swc_rectangle * geometry = &window->view->geometry; + struct swc_rectangle * geometry = &window->view->base.geometry; int32_t px = wl_fixed_to_int(swc.seat->pointer->x), py = wl_fixed_to_int(swc.seat->pointer->y); @@ -190,8 +190,9 @@ static bool move_motion(struct pointer_handler * handler, uint32_t time, struct window * window = CONTAINER_OF(handler, typeof(*window), move.interaction.handler); - swc_view_move(window->view, wl_fixed_to_int(fx) + window->move.offset.x, - wl_fixed_to_int(fy) + window->move.offset.y); + swc_view_move(&window->view->base, + wl_fixed_to_int(fx) + window->move.offset.x, + wl_fixed_to_int(fy) + window->move.offset.y); return true; } diff --git a/libswc/window.h b/libswc/window.h @@ -41,7 +41,7 @@ struct window const struct window_impl * impl; struct swc_surface * surface; - struct swc_view * view; + struct compositor_view * view; struct {