[weston,v2,5/8] xwm: Make sure we respect the window's size hints

Submitted by Louis-Francis Ratté-Boulianne on Nov. 13, 2017, 9:20 p.m.

Details

Message ID 20171113212056.18397-6-lfrb@collabora.com
State New
Headers show
Series "Implement NET_WM_SYNC_REQUEST basic support" ( rev: 2 ) in Wayland

Not browsing as part of any series.

Commit Message

Louis-Francis Ratté-Boulianne Nov. 13, 2017, 9:20 p.m.
Don't just ignore the minimal and maximal sizes requested
by the application.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
---
 xwayland/window-manager.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 3cc6fa24..a0ff6b62 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -2801,6 +2801,20 @@  send_configure(struct weston_surface *surface, int32_t width, int32_t height)
 	else
 		new_height = 1;
 
+	/* Make sure we respect the window's size hints */
+	if (window->size_hints.min_width > 0 &&
+	    new_width < window->size_hints.min_width)
+		new_width = window->size_hints.min_width;
+	if (window->size_hints.min_height > 0 &&
+	    new_height < window->size_hints.min_height)
+		new_height = window->size_hints.min_height;
+	if (window->size_hints.max_width > 0 &&
+	    new_width > window->size_hints.max_width)
+		new_width = window->size_hints.max_width;
+	if (window->size_hints.max_height > 0 &&
+	    new_height > window->size_hints.max_height)
+		new_height = window->size_hints.max_height;
+
 	if (window->width == new_width && window->height == new_height)
 		return;
 

Comments

On 11/13/17 10:20 PM, Louis-Francis Ratté-Boulianne wrote:
> Don't just ignore the minimal and maximal sizes requested
> by the application.
> 
> Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
> ---
>   xwayland/window-manager.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index 3cc6fa24..a0ff6b62 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -2801,6 +2801,20 @@ send_configure(struct weston_surface *surface, int32_t width, int32_t height)
>   	else
>   		new_height = 1;
>   
> +	/* Make sure we respect the window's size hints */
> +	if (window->size_hints.min_width > 0 &&
> +	    new_width < window->size_hints.min_width)
> +		new_width = window->size_hints.min_width;
> +	if (window->size_hints.min_height > 0 &&
> +	    new_height < window->size_hints.min_height)
> +		new_height = window->size_hints.min_height;
> +	if (window->size_hints.max_width > 0 &&
> +	    new_width > window->size_hints.max_width)
> +		new_width = window->size_hints.max_width;
> +	if (window->size_hints.max_height > 0 &&
> +	    new_height > window->size_hints.max_height)
> +		new_height = window->size_hints.max_height;
> +
>   	if (window->width == new_width && window->height == new_height)
>   		return;
>   
> 

This one is wrong. Ultimately, it’s up to the shell to decide.
We should forward these hints to libweston-desktop that will provide 
them just like xdg_shell min/max size.
If the shell decide to configure a size outside these hints, it’s up to 
it. A tiling compositor could also use it to e.g. not expand a tile too 
much and expand the other tiles instead.

Thanks,