[PATCH weston 09/11] Update the xwayland interface to handle views

Jason Ekstrand jason at jlekstrand.net
Fri Sep 13 19:44:59 PDT 2013


Because we have to inform the client every time it gets moved on screen, we
need to know what view to consider "primary" and report to the client.  To
do this, a get_primary_view vfunc is added to the shell interface that
takes a shell sruface and returns the view that should be considered
"primary".  The window manager will then listen to this view for changes
and update the X client accordingly.

Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
---
 src/compositor.h              |  2 ++
 src/xwayland/window-manager.c | 26 +++++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index 4c3b7a5..357f2a5 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -92,6 +92,8 @@ struct weston_shell_interface {
 	struct shell_surface *(*create_shell_surface)(void *shell,
 						      struct weston_surface *surface,
 						      const struct weston_shell_client *client);
+	struct weston_view *(*get_primary_view)(void *shell,
+						struct shell_surface *shsurf);
 
 	void (*set_toplevel)(struct shell_surface *shsurf);
 
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index b4f64d3..bafb0a7 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -122,6 +122,7 @@ struct weston_wm_window {
 	cairo_surface_t *cairo_surface;
 	struct weston_surface *surface;
 	struct shell_surface *shsurf;
+	struct weston_view *view;
 	struct wl_listener surface_destroy_listener;
 	struct wl_event_source *repaint_source;
 	struct wl_event_source *configure_source;
@@ -698,13 +699,13 @@ weston_wm_window_transform(struct wl_listener *listener, void *data)
 	if (!window || !wm)
 		return;
 
-	if (!weston_surface_is_mapped(surface))
+	if (!window->view || !weston_view_is_mapped(window->view))
 		return;
 
-	if (window->x != surface->geometry.x ||
-	    window->y != surface->geometry.y) {
-		values[0] = surface->geometry.x;
-		values[1] = surface->geometry.y;
+	if (window->x != window->view->geometry.x ||
+	    window->y != window->view->geometry.y) {
+		values[0] = window->view->geometry.x;
+		values[1] = window->view->geometry.y;
 		mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
 
 		xcb_configure_window(wm->conn, window->frame_id, mask, values);
@@ -938,7 +939,8 @@ weston_wm_window_draw_decoration(void *data)
 						  window->width + 2,
 						  window->height + 2);
 		}
-		weston_surface_geometry_dirty(window->surface);
+		if (window->view)
+			weston_view_geometry_dirty(window->view);
 	}
 
 	if (window->surface && !window->fullscreen) {
@@ -966,7 +968,8 @@ weston_wm_window_schedule_repaint(struct weston_wm_window *window)
 				pixman_region32_init_rect(&window->surface->pending.opaque, 0, 0,
 							  width, height);
 			}
-			weston_surface_geometry_dirty(window->surface);
+			if (window->view)
+				weston_view_geometry_dirty(window->view);
 		}
 		return;
 	}
@@ -1157,8 +1160,8 @@ weston_wm_window_handle_moveresize(struct weston_wm_window *window,
 	struct weston_shell_interface *shell_interface =
 		&wm->server->compositor->shell_interface;
 
-	if (seat->pointer->button_count != 1 ||
-	    seat->pointer->focus != window->surface)
+	if (seat->pointer->button_count != 1 || !window->view
+	    || seat->pointer->focus != window->view)
 		return;
 
 	detail = client_message->data.data32[2];
@@ -2032,10 +2035,15 @@ xserver_map_shell_surface(struct weston_wm *wm,
 	if (!shell_interface->create_shell_surface)
 		return;
 
+	if (!shell_interface->get_primary_view)
+		return;
+
 	window->shsurf = 
 		shell_interface->create_shell_surface(shell_interface->shell,
 						      window->surface,
 						      &shell_client);
+	window->view = shell_interface->get_primary_view(shell_interface->shell,
+							 window->shsurf);
 
 	if (window->name)
 		shell_interface->set_title(window->shsurf, window->name);
-- 
1.8.3.1



More information about the wayland-devel mailing list