commit 335822a1d88e5ea16049bcdddd07e01602204036
parent 7fd91671d66e3d2d446028f41a0edf2e55584782
Author: Michael Forney <mforney@mforney.org>
Date: Sat, 23 Nov 2013 22:40:15 -0800
Remove awkward internal struct stuff
Diffstat:
4 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/libswc/internal.h b/libswc/internal.h
@@ -26,13 +26,6 @@
#include "util.h"
-#define INTERNAL_DECL(type, name) \
- struct \
- { \
- struct swc_ ## type name; \
- struct swc_ ## type ## _internal _ ## name ## _internal; \
- }
-
#define INTERNAL_ASSOCIATIONS(ptr, base) \
INTERNAL_ASSOCIATION(window, ptr, \
base)
@@ -49,7 +42,7 @@
#if HAVE_GENERIC
# define INTERNAL_ASSOCIATION(type, ptr, next) \
struct swc_ ## type *: \
- &((INTERNAL_DECL(type, dummy) *) ptr)->_dummy_internal \
+ (struct swc_ ## type ## _internal *) ptr \
next
# define INTERNAL(ptr) \
_Generic(ptr, INTERNAL_ASSOCIATIONS(ptr,))
@@ -58,14 +51,10 @@
# define INTERNAL_ASSOCIATION(type, ptr, next) \
__builtin_choose_expr( \
__builtin_types_compatible_p(typeof(ptr), struct swc_ ## type *), \
- &((INTERNAL_DECL(type, dummy) *) ptr)->_dummy_internal, next)
+ (struct swc_ ## type ## _internal *) ptr, next)
# define INTERNAL(ptr) \
INTERNAL_ASSOCIATIONS(ptr, (void) 0)
#endif
-#define CONTAINER_OF_INTERNAL(ptr, type, member) \
- &CONTAINER_OF(ptr, INTERNAL_DECL(type, dummy), \
- _dummy_internal.member)->dummy
-
#endif
diff --git a/libswc/shell_surface.c b/libswc/shell_surface.c
@@ -31,7 +31,7 @@
struct swc_shell_surface
{
- INTERNAL_DECL(window, window);
+ struct swc_window_internal window;
struct wl_resource * resource;
@@ -72,7 +72,8 @@ static void set_toplevel(struct wl_client * client,
return;
shell_surface->type = SHELL_SURFACE_TYPE_TOPLEVEL;
- swc_window_set_state(&shell_surface->window, SWC_WINDOW_STATE_TOPLEVEL);
+ swc_window_set_state(&shell_surface->window.base,
+ SWC_WINDOW_STATE_TOPLEVEL);
}
static void set_transient(struct wl_client * client,
@@ -84,9 +85,9 @@ static void set_transient(struct wl_client * client,
= wl_resource_get_user_data(resource);
struct swc_surface * parent = wl_resource_get_user_data(parent_resource);
- swc_surface_move(INTERNAL(&shell_surface->window)->surface,
+ swc_surface_move(shell_surface->window.surface,
parent->geometry.x + x, parent->geometry.y + y);
- swc_compositor_surface_show(INTERNAL(&shell_surface->window)->surface);
+ swc_compositor_surface_show(shell_surface->window.surface);
/* XXX: Handle transient */
}
@@ -108,9 +109,9 @@ static void set_popup(struct wl_client * client, struct wl_resource * resource,
= wl_resource_get_user_data(resource);
struct swc_surface * parent = wl_resource_get_user_data(parent_resource);
- swc_surface_move(INTERNAL(&shell_surface->window)->surface,
+ swc_surface_move(shell_surface->window.surface,
parent->geometry.x + x, parent->geometry.y + y);
- swc_compositor_surface_show(INTERNAL(&shell_surface->window)->surface);
+ swc_compositor_surface_show(shell_surface->window.surface);
/* XXX: Handle popup */
}
@@ -128,7 +129,7 @@ static void set_title(struct wl_client * client, struct wl_resource * resource,
struct swc_shell_surface * shell_surface
= wl_resource_get_user_data(resource);
- swc_window_set_title(&shell_surface->window, title, -1);
+ swc_window_set_title(&shell_surface->window.base, title, -1);
}
static void set_class(struct wl_client * client, struct wl_resource * resource,
@@ -137,7 +138,7 @@ static void set_class(struct wl_client * client, struct wl_resource * resource,
struct swc_shell_surface * shell_surface
= wl_resource_get_user_data(resource);
- swc_window_set_class(&shell_surface->window, class);
+ swc_window_set_class(&shell_surface->window.base, class);
}
static const struct wl_shell_surface_interface shell_surface_implementation = {
@@ -157,7 +158,7 @@ static void configure(struct swc_window * window,
const struct swc_rectangle * geometry)
{
struct swc_shell_surface * shell_surface
- = CONTAINER_OF(window, typeof(*shell_surface), window);
+ = CONTAINER_OF(window, typeof(*shell_surface), window.base);
wl_shell_surface_send_configure(shell_surface->resource,
WL_SHELL_SURFACE_RESIZE_NONE,
@@ -179,7 +180,8 @@ struct swc_shell_surface * swc_shell_surface_new
return NULL;
shell_surface->type = SHELL_SURFACE_TYPE_UNSPECIFIED;
- swc_window_initialize(&shell_surface->window, &shell_window_impl, surface);
+ swc_window_initialize(&shell_surface->window.base,
+ &shell_window_impl, surface);
shell_surface->resource = wl_resource_create
(client, &wl_shell_surface_interface, 1, id);
diff --git a/libswc/window.c b/libswc/window.c
@@ -95,8 +95,8 @@ void swc_window_set_border(struct swc_window * window,
static void handle_surface_destroy(struct wl_listener * listener, void * data)
{
- struct swc_window * window = CONTAINER_OF_INTERNAL
- (listener, window, surface_destroy_listener);
+ struct swc_window * window = &CONTAINER_OF
+ (listener, struct swc_window_internal, surface_destroy_listener)->base;
swc_send_event(&window->event_signal, SWC_WINDOW_DESTROYED, NULL);
free(window);
@@ -131,8 +131,8 @@ struct swc_window * swc_window_get(struct swc_surface * surface)
listener = wl_resource_get_destroy_listener(surface->resource,
&handle_surface_destroy);
- return listener ? CONTAINER_OF_INTERNAL(listener, window,
- surface_destroy_listener)
+ return listener ? &CONTAINER_OF(listener, struct swc_window_internal,
+ surface_destroy_listener)->base
: NULL;
}
diff --git a/libswc/window.h b/libswc/window.h
@@ -24,11 +24,11 @@
#ifndef SWC_WINDOW_H
#define SWC_WINDOW_H
+#include "swc.h"
+
#include <stdint.h>
#include <wayland-server.h>
-struct swc_window;
-
struct swc_window_impl
{
void (* configure)(struct swc_window * window,
@@ -38,6 +38,8 @@ struct swc_window_impl
struct swc_window_internal
{
+ struct swc_window base;
+
struct swc_surface * surface;
struct wl_listener surface_destroy_listener;
const struct swc_window_impl * impl;