121 lines
4.2 KiB
Diff
121 lines
4.2 KiB
Diff
From ff8735d6821bb2e8828dac5a9f2e0c321a2ffdd1 Mon Sep 17 00:00:00 2001
|
|
From: Jeffy Chen <jeffy.chen@rock-chips.com>
|
|
Date: Wed, 27 Feb 2019 17:06:58 +0800
|
|
Subject: [PATCH 08/79] HACK: xdg-shell: Support setting window position
|
|
|
|
Set window position when .set_window_geometry() called with size 0x0.
|
|
|
|
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
|
|
---
|
|
desktop-shell/shell.c | 6 ++++++
|
|
include/libweston-desktop/libweston-desktop.h | 4 ++++
|
|
include/libweston/libweston.h | 2 ++
|
|
libweston/compositor.c | 2 ++
|
|
libweston/desktop/surface.c | 10 ++++++++++
|
|
libweston/desktop/xdg-shell.c | 10 ++++++++++
|
|
6 files changed, 34 insertions(+)
|
|
|
|
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
|
|
index 9da08aef..7363ee36 100644
|
|
--- a/desktop-shell/shell.c
|
|
+++ b/desktop-shell/shell.c
|
|
@@ -3821,6 +3821,12 @@ weston_view_set_initial_position(struct weston_view *view,
|
|
struct weston_seat *seat;
|
|
pixman_rectangle32_t area;
|
|
|
|
+ if (view->has_position) {
|
|
+ weston_view_set_position(view,
|
|
+ view->geometry.x, view->geometry.y);
|
|
+ return;
|
|
+ }
|
|
+
|
|
/* As a heuristic place the new window on the same output as the
|
|
* pointer. Falling back to the output containing 0, 0.
|
|
*
|
|
diff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h
|
|
index 3536935b..09e00c6a 100644
|
|
--- a/include/libweston-desktop/libweston-desktop.h
|
|
+++ b/include/libweston-desktop/libweston-desktop.h
|
|
@@ -176,6 +176,10 @@ weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
|
|
void
|
|
weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface,
|
|
enum weston_top_level_tiled_orientation tile_orientation);
|
|
+
|
|
+void
|
|
+weston_desktop_surface_set_position(struct weston_desktop_surface *surface,
|
|
+ int32_t x, int32_t y);
|
|
void
|
|
weston_desktop_surface_close(struct weston_desktop_surface *surface);
|
|
void
|
|
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
|
|
index 7382dd2d..89c5feb9 100644
|
|
--- a/include/libweston/libweston.h
|
|
+++ b/include/libweston/libweston.h
|
|
@@ -1489,6 +1489,8 @@ struct weston_view {
|
|
pixman_region32_t scissor; /* always a simple rect */
|
|
} geometry;
|
|
|
|
+ bool has_position;
|
|
+
|
|
/* State derived from geometry state, read-only.
|
|
* This is updated by weston_view_update_transform().
|
|
*/
|
|
diff --git a/libweston/compositor.c b/libweston/compositor.c
|
|
index e166911e..caec3e23 100644
|
|
--- a/libweston/compositor.c
|
|
+++ b/libweston/compositor.c
|
|
@@ -1810,6 +1810,8 @@ weston_surface_damage(struct weston_surface *surface)
|
|
WL_EXPORT void
|
|
weston_view_set_position(struct weston_view *view, float x, float y)
|
|
{
|
|
+ view->has_position = true;
|
|
+
|
|
if (view->geometry.x == x && view->geometry.y == y)
|
|
return;
|
|
|
|
diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c
|
|
index 6b3f4aeb..54e493cf 100644
|
|
--- a/libweston/desktop/surface.c
|
|
+++ b/libweston/desktop/surface.c
|
|
@@ -695,6 +695,16 @@ weston_desktop_surface_get_min_size(struct weston_desktop_surface *surface)
|
|
surface->implementation_data);
|
|
}
|
|
|
|
+void
|
|
+weston_desktop_surface_set_position(struct weston_desktop_surface *surface,
|
|
+ int32_t x, int32_t y)
|
|
+{
|
|
+ struct weston_desktop_view *view;
|
|
+
|
|
+ wl_list_for_each(view, &surface->view_list, link)
|
|
+ weston_view_set_position(view->view, x, y);
|
|
+}
|
|
+
|
|
void
|
|
weston_desktop_surface_set_title(struct weston_desktop_surface *surface,
|
|
const char *title)
|
|
diff --git a/libweston/desktop/xdg-shell.c b/libweston/desktop/xdg-shell.c
|
|
index ca9862c1..636dc292 100644
|
|
--- a/libweston/desktop/xdg-shell.c
|
|
+++ b/libweston/desktop/xdg-shell.c
|
|
@@ -1342,6 +1342,16 @@ weston_desktop_xdg_surface_protocol_set_window_geometry(struct wl_client *wl_cli
|
|
struct weston_desktop_xdg_surface *surface =
|
|
weston_desktop_surface_get_implementation_data(dsurface);
|
|
|
|
+ /* HACK: For setting window position */
|
|
+ if (!width && !height) {
|
|
+ struct weston_desktop_xdg_toplevel *toplevel =
|
|
+ weston_desktop_surface_get_implementation_data(dsurface);
|
|
+ if (!toplevel->current.state.fullscreen &&
|
|
+ !toplevel->current.state.maximized)
|
|
+ weston_desktop_surface_set_position(dsurface, x, y);
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (!weston_desktop_xdg_surface_check_role(surface))
|
|
return;
|
|
|
|
--
|
|
2.20.1
|
|
|