diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2016-06-23 18:55:19 +0200 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2016-11-21 18:17:46 +0000 |
commit | 581df06ad13961568ecc99dd2e4142b33a4de089 (patch) | |
tree | 6de3707cb1f5cb4d978b987e9593cda62a7f0f49 /desktop-shell | |
parent | 55d5701ddf018887a30d9ddede38550967da61bc (diff) |
desktop-shell: Compute panel size without using output
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'desktop-shell')
-rw-r--r-- | desktop-shell/shell.c | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index a43c2e2a..92b4bee5 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -284,6 +284,23 @@ shell_grab_start(struct shell_grab *grab, } static void +get_panel_size(struct desktop_shell *shell, + struct weston_view *view, + int *width, + int *height) +{ + float x1, y1; + float x2, y2; + weston_view_to_global_float(view, 0, 0, &x1, &y1); + weston_view_to_global_float(view, + view->surface->width, + view->surface->height, + &x2, &y2); + *width = (int)(x2 - x1); + *height = (int)(y2 - y1); +} + +static void get_output_panel_size(struct desktop_shell *shell, struct weston_output *output, int *width, @@ -298,36 +315,9 @@ get_output_panel_size(struct desktop_shell *shell, return; wl_list_for_each(view, &shell->panel_layer.view_list.link, layer_link.link) { - float x, y; - - if (view->surface->output != output) - continue; - - switch (shell->panel_position) { - case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP: - case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM: - weston_view_to_global_float(view, - view->surface->width, 0, - &x, &y); - - *width = (int)x - output->x; - *height = view->surface->height + (int) y - output->y; - return; - - case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT: - case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT: - weston_view_to_global_float(view, - 0, view->surface->height, - &x, &y); - - *width = view->surface->width + (int)x - output->x; - *height = (int)y - output->y; + if (view->surface->output == output) { + get_panel_size(shell, view, width, height); return; - - default: - /* we've already set width and height to - * fallback values. */ - break; } } |