[PATCH weston] libweston-desktop: fix the size of unmaximized xdg surfaces

Giulio Camuffo giuliocamuffo at gmail.com
Thu Jul 27 13:01:40 UTC 2017


When unmaximizing a surface the configure event should send 0,0 as the
requested size, so that the client can use the size that it had before
maximizing
---
 libweston-desktop/xdg-shell-v6.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 1344dda0..3a02815f 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -578,11 +578,29 @@ weston_desktop_xdg_toplevel_send_configure(struct weston_desktop_xdg_toplevel *t
 };
 
 static void
+weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
+				     void *user_data,
+				     int32_t width, int32_t height)
+{
+	struct weston_desktop_xdg_toplevel *toplevel = user_data;
+
+	toplevel->pending.size.width = width;
+	toplevel->pending.size.height = height;
+
+	weston_desktop_xdg_surface_schedule_configure(&toplevel->base, false);
+}
+
+static void
 weston_desktop_xdg_toplevel_set_maximized(struct weston_desktop_surface *dsurface,
 					  void *user_data, bool maximized)
 {
 	struct weston_desktop_xdg_toplevel *toplevel = user_data;
 
+	/* if we're unmaximizing set the size to 0 so that when the configure event is sent
+	   it will tell the client to use the size it wants */
+	if (toplevel->pending.state.maximized && !maximized)
+		weston_desktop_xdg_toplevel_set_size(dsurface, toplevel, 0, 0);
+
 	toplevel->pending.state.maximized = maximized;
 	weston_desktop_xdg_surface_schedule_configure(&toplevel->base, false);
 }
@@ -618,19 +636,6 @@ weston_desktop_xdg_toplevel_set_activated(struct weston_desktop_surface *dsurfac
 }
 
 static void
-weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
-				     void *user_data,
-				     int32_t width, int32_t height)
-{
-	struct weston_desktop_xdg_toplevel *toplevel = user_data;
-
-	toplevel->pending.size.width = width;
-	toplevel->pending.size.height = height;
-
-	weston_desktop_xdg_surface_schedule_configure(&toplevel->base, false);
-}
-
-static void
 weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel,
 				      int32_t sx, int32_t sy)
 {
-- 
2.13.3



More information about the wayland-devel mailing list