[PATCH weston 2/7] desktop-shell: Compute panel size without using output

Quentin Glidic sardemff7+wayland at sardemff7.net
Thu Jun 23 16:55:19 UTC 2016


From: Quentin Glidic <sardemff7+git at sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 desktop-shell/shell.c | 48 +++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 29 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 2c88176..a5fca56 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -400,6 +400,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,
@@ -415,36 +432,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;
 		}
 	}
 
-- 
2.9.0



More information about the wayland-devel mailing list