1*4882a593SmuzhiyunFrom 467e75739f3afddeaa1c3208fd029e36a34c7fc0 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Jeffy Chen <jeffy.chen@rock-chips.com> 3*4882a593SmuzhiyunDate: Wed, 27 Feb 2019 17:06:58 +0800 4*4882a593SmuzhiyunSubject: [PATCH 08/93] HACK: xdg-shell: Support setting window position 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunSet window position when .set_window_geometry() called with size 0x0. 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunSigned-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 9*4882a593Smuzhiyun--- 10*4882a593Smuzhiyun desktop-shell/shell.c | 6 ++++++ 11*4882a593Smuzhiyun include/libweston-desktop/libweston-desktop.h | 4 ++++ 12*4882a593Smuzhiyun include/libweston/libweston.h | 2 ++ 13*4882a593Smuzhiyun libweston/compositor.c | 2 ++ 14*4882a593Smuzhiyun libweston/desktop/surface.c | 10 ++++++++++ 15*4882a593Smuzhiyun libweston/desktop/xdg-shell.c | 10 ++++++++++ 16*4882a593Smuzhiyun 6 files changed, 34 insertions(+) 17*4882a593Smuzhiyun 18*4882a593Smuzhiyundiff --git a/desktop-shell/shell.c b/desktop-shell/shell.c 19*4882a593Smuzhiyunindex 9da08ae..7363ee3 100644 20*4882a593Smuzhiyun--- a/desktop-shell/shell.c 21*4882a593Smuzhiyun+++ b/desktop-shell/shell.c 22*4882a593Smuzhiyun@@ -3821,6 +3821,12 @@ weston_view_set_initial_position(struct weston_view *view, 23*4882a593Smuzhiyun struct weston_seat *seat; 24*4882a593Smuzhiyun pixman_rectangle32_t area; 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun+ if (view->has_position) { 27*4882a593Smuzhiyun+ weston_view_set_position(view, 28*4882a593Smuzhiyun+ view->geometry.x, view->geometry.y); 29*4882a593Smuzhiyun+ return; 30*4882a593Smuzhiyun+ } 31*4882a593Smuzhiyun+ 32*4882a593Smuzhiyun /* As a heuristic place the new window on the same output as the 33*4882a593Smuzhiyun * pointer. Falling back to the output containing 0, 0. 34*4882a593Smuzhiyun * 35*4882a593Smuzhiyundiff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h 36*4882a593Smuzhiyunindex 3536935..09e00c6 100644 37*4882a593Smuzhiyun--- a/include/libweston-desktop/libweston-desktop.h 38*4882a593Smuzhiyun+++ b/include/libweston-desktop/libweston-desktop.h 39*4882a593Smuzhiyun@@ -176,6 +176,10 @@ weston_desktop_surface_set_size(struct weston_desktop_surface *surface, 40*4882a593Smuzhiyun void 41*4882a593Smuzhiyun weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface, 42*4882a593Smuzhiyun enum weston_top_level_tiled_orientation tile_orientation); 43*4882a593Smuzhiyun+ 44*4882a593Smuzhiyun+void 45*4882a593Smuzhiyun+weston_desktop_surface_set_position(struct weston_desktop_surface *surface, 46*4882a593Smuzhiyun+ int32_t x, int32_t y); 47*4882a593Smuzhiyun void 48*4882a593Smuzhiyun weston_desktop_surface_close(struct weston_desktop_surface *surface); 49*4882a593Smuzhiyun void 50*4882a593Smuzhiyundiff --git a/include/libweston/libweston.h b/include/libweston/libweston.h 51*4882a593Smuzhiyunindex 7382dd2..89c5feb 100644 52*4882a593Smuzhiyun--- a/include/libweston/libweston.h 53*4882a593Smuzhiyun+++ b/include/libweston/libweston.h 54*4882a593Smuzhiyun@@ -1489,6 +1489,8 @@ struct weston_view { 55*4882a593Smuzhiyun pixman_region32_t scissor; /* always a simple rect */ 56*4882a593Smuzhiyun } geometry; 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun+ bool has_position; 59*4882a593Smuzhiyun+ 60*4882a593Smuzhiyun /* State derived from geometry state, read-only. 61*4882a593Smuzhiyun * This is updated by weston_view_update_transform(). 62*4882a593Smuzhiyun */ 63*4882a593Smuzhiyundiff --git a/libweston/compositor.c b/libweston/compositor.c 64*4882a593Smuzhiyunindex e166911..caec3e2 100644 65*4882a593Smuzhiyun--- a/libweston/compositor.c 66*4882a593Smuzhiyun+++ b/libweston/compositor.c 67*4882a593Smuzhiyun@@ -1810,6 +1810,8 @@ weston_surface_damage(struct weston_surface *surface) 68*4882a593Smuzhiyun WL_EXPORT void 69*4882a593Smuzhiyun weston_view_set_position(struct weston_view *view, float x, float y) 70*4882a593Smuzhiyun { 71*4882a593Smuzhiyun+ view->has_position = true; 72*4882a593Smuzhiyun+ 73*4882a593Smuzhiyun if (view->geometry.x == x && view->geometry.y == y) 74*4882a593Smuzhiyun return; 75*4882a593Smuzhiyun 76*4882a593Smuzhiyundiff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c 77*4882a593Smuzhiyunindex 6b3f4ae..54e493c 100644 78*4882a593Smuzhiyun--- a/libweston/desktop/surface.c 79*4882a593Smuzhiyun+++ b/libweston/desktop/surface.c 80*4882a593Smuzhiyun@@ -695,6 +695,16 @@ weston_desktop_surface_get_min_size(struct weston_desktop_surface *surface) 81*4882a593Smuzhiyun surface->implementation_data); 82*4882a593Smuzhiyun } 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun+void 85*4882a593Smuzhiyun+weston_desktop_surface_set_position(struct weston_desktop_surface *surface, 86*4882a593Smuzhiyun+ int32_t x, int32_t y) 87*4882a593Smuzhiyun+{ 88*4882a593Smuzhiyun+ struct weston_desktop_view *view; 89*4882a593Smuzhiyun+ 90*4882a593Smuzhiyun+ wl_list_for_each(view, &surface->view_list, link) 91*4882a593Smuzhiyun+ weston_view_set_position(view->view, x, y); 92*4882a593Smuzhiyun+} 93*4882a593Smuzhiyun+ 94*4882a593Smuzhiyun void 95*4882a593Smuzhiyun weston_desktop_surface_set_title(struct weston_desktop_surface *surface, 96*4882a593Smuzhiyun const char *title) 97*4882a593Smuzhiyundiff --git a/libweston/desktop/xdg-shell.c b/libweston/desktop/xdg-shell.c 98*4882a593Smuzhiyunindex ca9862c..636dc29 100644 99*4882a593Smuzhiyun--- a/libweston/desktop/xdg-shell.c 100*4882a593Smuzhiyun+++ b/libweston/desktop/xdg-shell.c 101*4882a593Smuzhiyun@@ -1342,6 +1342,16 @@ weston_desktop_xdg_surface_protocol_set_window_geometry(struct wl_client *wl_cli 102*4882a593Smuzhiyun struct weston_desktop_xdg_surface *surface = 103*4882a593Smuzhiyun weston_desktop_surface_get_implementation_data(dsurface); 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun+ /* HACK: For setting window position */ 106*4882a593Smuzhiyun+ if (!width && !height) { 107*4882a593Smuzhiyun+ struct weston_desktop_xdg_toplevel *toplevel = 108*4882a593Smuzhiyun+ weston_desktop_surface_get_implementation_data(dsurface); 109*4882a593Smuzhiyun+ if (!toplevel->current.state.fullscreen && 110*4882a593Smuzhiyun+ !toplevel->current.state.maximized) 111*4882a593Smuzhiyun+ weston_desktop_surface_set_position(dsurface, x, y); 112*4882a593Smuzhiyun+ return; 113*4882a593Smuzhiyun+ } 114*4882a593Smuzhiyun+ 115*4882a593Smuzhiyun if (!weston_desktop_xdg_surface_check_role(surface)) 116*4882a593Smuzhiyun return; 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun-- 119*4882a593Smuzhiyun2.20.1 120*4882a593Smuzhiyun 121