From 7485b2c553b66973b441df44bf91ac195b736aba 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 07/74] 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 | 3 +++
|
include/libweston/libweston.h | 2 ++
|
libweston-desktop/surface.c | 10 ++++++++++
|
libweston-desktop/xdg-shell.c | 10 ++++++++++
|
libweston/compositor.c | 2 ++
|
6 files changed, 33 insertions(+)
|
|
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
|
index 63e1431..3c71192 100644
|
--- a/desktop-shell/shell.c
|
+++ b/desktop-shell/shell.c
|
@@ -4243,6 +4243,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 3e7ac73..6b54d3a 100644
|
--- a/include/libweston-desktop/libweston-desktop.h
|
+++ b/include/libweston-desktop/libweston-desktop.h
|
@@ -163,6 +163,9 @@ void
|
weston_desktop_surface_set_size(struct weston_desktop_surface *surface,
|
int32_t width, int32_t height);
|
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
|
weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface *surface,
|
diff --git a/include/libweston/libweston.h b/include/libweston/libweston.h
|
index d99dc76..bfa7e36 100644
|
--- a/include/libweston/libweston.h
|
+++ b/include/libweston/libweston.h
|
@@ -1326,6 +1326,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-desktop/surface.c b/libweston-desktop/surface.c
|
index 433f08a..21ff080 100644
|
--- a/libweston-desktop/surface.c
|
+++ b/libweston-desktop/surface.c
|
@@ -685,6 +685,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 6cbf55e..a0161f6 100644
|
--- a/libweston-desktop/xdg-shell.c
|
+++ b/libweston-desktop/xdg-shell.c
|
@@ -1266,6 +1266,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;
|
|
diff --git a/libweston/compositor.c b/libweston/compositor.c
|
index bfb4c0f..70d7127 100644
|
--- a/libweston/compositor.c
|
+++ b/libweston/compositor.c
|
@@ -1792,6 +1792,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;
|
|
--
|
2.20.1
|