From 927d9e23fadb8babaf8ee93b215a25c448c5f6f2 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 6 Oct 2017 14:37:44 -0500 Subject: [PATCH] desktop-shell: refactor maximized size calculation into its own function We need to calculate maximized size to resolve a bug with unsetting fullscreen, might as well share the code. Signed-off-by: Derek Foreman Reviewed-by: Daniel Stone --- desktop-shell/shell.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index a0070a04..8c9b59ae 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2584,6 +2584,19 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface, } } +static void +get_maximized_size(struct shell_surface *shsurf, int32_t *width, int32_t *height) +{ + struct desktop_shell *shell; + pixman_rectangle32_t area; + + shell = shell_surface_get_shell(shsurf); + get_output_work_area(shell, shsurf->output, &area); + + *width = area.width; + *height = area.height; +} + static void set_fullscreen(struct shell_surface *shsurf, bool fullscreen, struct weston_output *output) @@ -2689,8 +2702,6 @@ set_maximized(struct shell_surface *shsurf, bool maximized) if (maximized) { struct weston_output *output; - struct desktop_shell *shell; - pixman_rectangle32_t area; if (!weston_surface_is_mapped(surface)) output = get_focused_output(surface->compositor); @@ -2699,11 +2710,7 @@ set_maximized(struct shell_surface *shsurf, bool maximized) shell_surface_set_output(shsurf, output); - shell = shell_surface_get_shell(shsurf); - get_output_work_area(shell, shsurf->output, &area); - - width = area.width; - height = area.height; + get_maximized_size(shsurf, &width, &height); } weston_desktop_surface_set_maximized(desktop_surface, maximized); weston_desktop_surface_set_size(desktop_surface, width, height);