[RFC weston v2 1/2] xwayland: make maximized state a flag for toplevel surfaces

Ilia Bozhinov ammen99 at gmail.com
Tue Jun 27 20:51:35 UTC 2017


Currently xwayland desktop surfaces have multiple states for toplevel
surfaces - MAXIMIZED/FULLSCREEN/TOPLEVEL. With this change all "toplevel"
surfaces are marked as TOPLEVEL state and maximized/fullscreen are
boolean flags, just like they are in xdg-shell. This way maximized state
isn't lost when for example a maximized window is fullscreened
and then unfullscreened. We must also make sure to call set_toplevel()
in XWM for maximized/fullscreen windows, as now they are "toplevel" with
maximized state

Signed-off-by: Ilia Bozhinov <ammen99 at gmail.com>
---
 libweston-desktop/xwayland.c | 23 +++++++++--------------
 xwayland/window-manager.c    |  2 ++
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 4f4b453f..9ab9dfbf 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -40,8 +40,6 @@
 enum weston_desktop_xwayland_surface_state {
 	NONE,
 	TOPLEVEL,
-	MAXIMIZED,
-	FULLSCREEN,
 	TRANSIENT,
 	XWAYLAND,
 };
@@ -62,6 +60,8 @@ struct weston_desktop_xwayland_surface {
 	struct weston_geometry next_geometry;
 	bool has_next_geometry;
 	bool added;
+	bool maximized;
+	bool fullscreen;
 	enum weston_desktop_xwayland_surface_state state;
 };
 
@@ -190,7 +190,7 @@ weston_desktop_xwayland_surface_get_maximized(struct weston_desktop_surface *dsu
 {
 	struct weston_desktop_xwayland_surface *surface = user_data;
 
-	return surface->state == MAXIMIZED;
+	return surface->maximized;
 }
 
 static bool
@@ -199,7 +199,7 @@ weston_desktop_xwayland_surface_get_fullscreen(struct weston_desktop_surface *ds
 {
 	struct weston_desktop_xwayland_surface *surface = user_data;
 
-	return surface->state == FULLSCREEN;
+	return surface->fullscreen;
 }
 
 static const struct weston_desktop_surface_implementation weston_desktop_xwayland_surface_internal_implementation = {
@@ -305,8 +305,7 @@ static void
 set_fullscreen(struct weston_desktop_xwayland_surface *surface,
 	       struct weston_output *output)
 {
-	weston_desktop_xwayland_surface_change_state(surface, FULLSCREEN, NULL,
-						     0, 0);
+	surface->fullscreen = true;
 	weston_desktop_api_fullscreen_requested(surface->desktop,
 						surface->surface, true, output);
 }
@@ -316,15 +315,14 @@ set_xwayland(struct weston_desktop_xwayland_surface *surface, int x, int y)
 {
 	weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL,
 						     x, y);
+	surface->maximized = surface->fullscreen = false;
 }
 
 static int
 move(struct weston_desktop_xwayland_surface *surface,
      struct weston_pointer *pointer)
 {
-	if (surface->state == TOPLEVEL ||
-	    surface->state == MAXIMIZED ||
-	    surface->state == FULLSCREEN)
+	if (surface->state == TOPLEVEL)
 		weston_desktop_api_move(surface->desktop, surface->surface,
 					pointer->seat, pointer->grab_serial);
 	return 0;
@@ -334,9 +332,7 @@ static int
 resize(struct weston_desktop_xwayland_surface *surface,
        struct weston_pointer *pointer, uint32_t edges)
 {
-	if (surface->state == TOPLEVEL ||
-	    surface->state == MAXIMIZED ||
-	    surface->state == FULLSCREEN)
+	if (surface->state == TOPLEVEL)
 		weston_desktop_api_resize(surface->desktop, surface->surface,
 					  pointer->seat, pointer->grab_serial,
 					  edges);
@@ -363,8 +359,7 @@ set_window_geometry(struct weston_desktop_xwayland_surface *surface,
 static void
 set_maximized(struct weston_desktop_xwayland_surface *surface)
 {
-	weston_desktop_xwayland_surface_change_state(surface, MAXIMIZED, NULL,
-						     0, 0);
+	surface->maximized = true;
 	weston_desktop_api_maximized_requested(surface->desktop,
 					       surface->surface, true);
 }
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 13acc84e..b0f78e2d 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -2750,6 +2750,7 @@ xserver_map_shell_surface(struct weston_wm_window *window,
 	if (window->fullscreen) {
 		window->saved_width = window->width;
 		window->saved_height = window->height;
+		xwayland_interface->set_toplevel(window->shsurf);
 		xwayland_interface->set_fullscreen(window->shsurf,
 						   window->legacy_fullscreen_output.output);
 		return;
@@ -2769,6 +2770,7 @@ xserver_map_shell_surface(struct weston_wm_window *window,
 						       parent->surface);
 		}
 	} else if (weston_wm_window_is_maximized(window)) {
+		xwayland_interface->set_toplevel(window->shsurf);
 		xwayland_interface->set_maximized(window->shsurf);
 	} else {
 		if (weston_wm_window_type_inactive(window)) {
-- 
2.13.0



More information about the wayland-devel mailing list