diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-11-16 15:17:14 +0200 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2017-01-18 13:21:02 +0200 |
commit | 77a6d95a0f31a0a51ac2fd85a67c45a624aa34bc (patch) | |
tree | 12cbf36fa45eca43b540b2c04d63af8803555df2 | |
parent | 882aff09324ba72d1d9136d6ad9f3c99dab1631b (diff) |
shell: implement set_xwayland_position
Store the initial xwayland position explicitly in struct shell_surface.
New variables are needed, because e.g. saved_x, saved_y are the view
position, and to compute that we need the window geometry, which is not
available before the first commit, so it's not available at
set_xwayland_position() time.
Regression: kcachegrind (Qt 4, X11), the first menu invocation will
slightly misplace the menu if the window has not been manually moved.
Problem: geometry is not taken into account due to a race between XWM
drawing decorations and Xwayland committing the first buffer.
Use the same debugging guard as XWM.
v3: merged with "desktop-shell: debug set_position_from_xwayland"
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r-- | desktop-shell/shell.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index d8ef3fd7..f80088f7 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -134,6 +134,12 @@ struct shell_surface { bool lowered; } state; + struct { + bool is_set; + int32_t x; + int32_t y; + } xwayland; + int focus_count; bool destroying; @@ -2386,6 +2392,28 @@ set_maximized_position(struct desktop_shell *shell, } static void +set_position_from_xwayland(struct shell_surface *shsurf) +{ + struct weston_geometry geometry; + float x; + float y; + + assert(shsurf->xwayland.is_set); + + geometry = weston_desktop_surface_get_geometry(shsurf->desktop_surface); + x = shsurf->xwayland.x - geometry.x; + y = shsurf->xwayland.y - geometry.y; + + weston_view_set_position(shsurf->view, x, y); + +#ifdef WM_DEBUG + weston_log("%s: XWM %d, %d; geometry %d, %d; view %f, %f\n", + __func__, shsurf->xwayland.x, shsurf->xwayland.y, + geometry.x, geometry.y, x, y); +#endif +} + +static void map(struct desktop_shell *shell, struct shell_surface *shsurf, int32_t sx, int32_t sy) { @@ -2400,6 +2428,8 @@ map(struct desktop_shell *shell, struct shell_surface *shsurf, shell_map_fullscreen(shsurf); } else if (shsurf->state.maximized) { set_maximized_position(shell, shsurf); + } else if (shsurf->xwayland.is_set) { + set_position_from_xwayland(shsurf); } else { weston_view_set_initial_position(shsurf->view, shell); } @@ -2784,6 +2814,18 @@ desktop_surface_pong(struct weston_desktop_client *desktop_client, end_busy_cursor(shell->compositor, desktop_client); } +static void +desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface, + int32_t x, int32_t y, void *shell_) +{ + struct shell_surface *shsurf = + weston_desktop_surface_get_user_data(surface); + + shsurf->xwayland.x = x; + shsurf->xwayland.y = y; + shsurf->xwayland.is_set = true; +} + static const struct weston_desktop_api shell_desktop_api = { .struct_size = sizeof(struct weston_desktop_api), .surface_added = desktop_surface_added, @@ -2796,6 +2838,7 @@ static const struct weston_desktop_api shell_desktop_api = { .minimized_requested = desktop_surface_minimized_requested, .ping_timeout = desktop_surface_ping_timeout, .pong = desktop_surface_pong, + .set_xwayland_position = desktop_surface_set_xwayland_position, }; /* ************************ * |