[PATCH weston 08/12] window: add surface pointer to widget

Pekka Paalanen ppaalanen at gmail.com
Wed Feb 13 06:17:19 PST 2013


So that given a widget, we can access the surface specific data, like
buffers, and input and opaque regions.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 clients/window.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index ecc38b0..9ebd1ac 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -245,6 +245,7 @@ struct window {
 
 struct widget {
 	struct window *window;
+	struct surface *surface;
 	struct tooltip *tooltip;
 	struct wl_list child_list;
 	struct wl_list link;
@@ -1369,15 +1370,16 @@ window_find_widget(struct window *window, int32_t x, int32_t y)
 }
 
 static struct widget *
-widget_create(struct window *window, void *data)
+widget_create(struct window *window, struct surface *surface, void *data)
 {
 	struct widget *widget;
 
 	widget = malloc(sizeof *widget);
 	memset(widget, 0, sizeof *widget);
 	widget->window = window;
+	widget->surface = surface;
 	widget->user_data = data;
-	widget->allocation = window->main_surface->allocation;
+	widget->allocation = surface->allocation;
 	wl_list_init(&widget->child_list);
 	widget->opaque = 0;
 	widget->tooltip = NULL;
@@ -1392,7 +1394,7 @@ window_add_widget(struct window *window, void *data)
 {
 	struct widget *widget;
 
-	widget = widget_create(window, data);
+	widget = widget_create(window, window->main_surface, data);
 	wl_list_init(&widget->link);
 	window->main_surface->widget = widget;
 
@@ -1404,7 +1406,7 @@ widget_add_widget(struct widget *parent, void *data)
 {
 	struct widget *widget;
 
-	widget = widget_create(parent->window, data);
+	widget = widget_create(parent->window, parent->surface, data);
 	wl_list_insert(parent->child_list.prev, &widget->link);
 
 	return widget;
@@ -1734,7 +1736,7 @@ frame_resize_handler(struct widget *widget,
 	struct widget *child = frame->child;
 	struct rectangle allocation;
 	struct display *display = widget->window->display;
-	struct surface *surface = widget->window->main_surface;
+	struct surface *surface = widget->surface;
 	struct frame_button * button;
 	struct theme *t = display->theme;
 	int x_l, x_r, y, w, h;
-- 
1.7.12.4



More information about the wayland-devel mailing list