[weston v2 3/8] xwm: Don't resize windows if the application have these hints

Olivier Fourdan ofourdan at redhat.com
Tue Nov 14 14:57:07 UTC 2017


Hey,

I dunno how elaborate the X11 WM in weston is meant to be, but in case, I'll leave my comments below.

> If the minimum and maximum size hints are equal, that means the
> application doesn't want the window manager to allow resizing.
> 
> Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
> ---
>  xwayland/window-manager.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index 4b84b24e..c70938c4 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -973,6 +973,15 @@ weston_wm_window_set_net_wm_state(struct
> weston_wm_window *window)
>  			    i, property);
>  }
>  
> +static inline bool
> +weston_wm_window_is_resizable(struct weston_wm_window *window)
> +{
> +	return (window->size_hints.min_width <= 0 ||
> +	        window->size_hints.min_height <= 0 ||
> +		window->size_hints.min_width != window->size_hints.max_width ||
> +		window->size_hints.min_height != window->size_hints.max_height);
> +}

I am not sure I follow the logic here, I think a window is resizeable if (min_width < max_width) and (min_height < max_height)

btw, a window can be resizeable in one direction but not the other (like resizeable horizontally but not vertically, or vice-versa)

Also, you may need to check the relevant flags (PMinSize and PMaxSize) in the WM_SIZE_HINTS.flags before using the size hints values.

For reference: https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.3

> +
>  static void
>  weston_wm_window_create_frame(struct weston_wm_window *window)
>  {
> @@ -981,7 +990,8 @@ weston_wm_window_create_frame(struct weston_wm_window
> *window)
>  	int x, y, width, height;
>  	int buttons = FRAME_BUTTON_CLOSE;
>  
> -	if (window->decorate & MWM_DECOR_MAXIMIZE)
> +	if (window->decorate & MWM_DECOR_MAXIMIZE &&
> +	    weston_wm_window_is_resizable(window))
>  		buttons |= FRAME_BUTTON_MAXIMIZE;

I think this should be a bit more elaborate that that, a window could be maximizable on a given output if its max size is larger than the output size it's on.

For example, a client may set its max size just a few pixels larger than its min size and that may not be sufficient to be "maximizable" on the current output.

Of course, those are just /hints/ so you could ignore them...

>  	window->frame = frame_create(window->wm->theme,
> @@ -2133,7 +2143,7 @@ weston_wm_handle_button(struct weston_wm *wm,
> xcb_generic_event_t *event)
>  	}
>  
>  	if (frame_status(window->frame) & FRAME_STATUS_RESIZE) {
> -		if (pointer)
> +		if (pointer && weston_wm_window_is_resizable(window))
>  			xwayland_interface->resize(window->shsurf, pointer, location);
>  		frame_status_clear(window->frame, FRAME_STATUS_RESIZE);
>  	}
> @@ -2174,8 +2184,10 @@ weston_wm_handle_motion(struct weston_wm *wm,
> xcb_generic_event_t *event)
>  	if (frame_status(window->frame) & FRAME_STATUS_REPAINT)
>  		weston_wm_window_schedule_repaint(window);
>  
> -	cursor = get_cursor_for_location(location);
> -	weston_wm_window_set_cursor(wm, window->frame_id, cursor);
> +	if (weston_wm_window_is_resizable(window)) {
> +		cursor = get_cursor_for_location(location);
> +		weston_wm_window_set_cursor(wm, window->frame_id, cursor);
> +	}
>  }
>  
>  static void
> @@ -2195,8 +2207,10 @@ weston_wm_handle_enter(struct weston_wm *wm,
> xcb_generic_event_t *event)
>  	if (frame_status(window->frame) & FRAME_STATUS_REPAINT)
>  		weston_wm_window_schedule_repaint(window);
>  
> -	cursor = get_cursor_for_location(location);
> -	weston_wm_window_set_cursor(wm, window->frame_id, cursor);
> +	if (weston_wm_window_is_resizable(window)) {
> +		cursor = get_cursor_for_location(location);
> +		weston_wm_window_set_cursor(wm, window->frame_id, cursor);
> +	}
>  }
>  
>  static void
> --
> 2.13.0
> 
> 


More information about the wayland-devel mailing list