xwayland: detect initially positioned X11 windows

X11 applications expect -geometry command line option to work for
setting the initial window position, but currently this does not work.

During map, detect X11 windows that set an explicit position. This works
by heuristics: if window position is not 0,0 then it is explicitly
positioned. Legacy fullscreen windows are also at 0,0 but these are
detected earlier.

Explicitly store the window position at map request time to detect
client-positioned windows, and use it as the suggested initial position.
weston_wm_window::x and y have been overwritten due to reparenting when
we eventually need the initial position.

This patch requires that the new set_toplevel_with_position() hook is
implemented in the shell.

Note that this patch is about positioning xwayland toplevels, not
override-redirect windows which are already handled.

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>
dev
Pekka Paalanen 8 years ago
parent 37111e157a
commit 882aff0932
  1. 29
      xwayland/window-manager.c

@ -35,6 +35,7 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <limits.h>
#include <assert.h> #include <assert.h>
#include <X11/Xcursor/Xcursor.h> #include <X11/Xcursor/Xcursor.h>
#include <linux/input.h> #include <linux/input.h>
@ -152,8 +153,11 @@ struct weston_wm_window {
uint32_t protocols; uint32_t protocols;
xcb_atom_t type; xcb_atom_t type;
int width, height; int width, height;
int x, y; int x;
int y;
bool pos_dirty; bool pos_dirty;
int map_request_x;
int map_request_y;
struct weston_output_weak_ref legacy_fullscreen_output; struct weston_output_weak_ref legacy_fullscreen_output;
int saved_width, saved_height; int saved_width, saved_height;
int decorate; int decorate;
@ -1030,12 +1034,16 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
*/ */
assert(!window->shsurf); assert(!window->shsurf);
window->map_request_x = window->x;
window->map_request_y = window->y;
if (window->frame_id == XCB_WINDOW_NONE) if (window->frame_id == XCB_WINDOW_NONE)
weston_wm_window_create_frame(window); weston_wm_window_create_frame(window);
wm_log("XCB_MAP_REQUEST (window %d, %p, frame %d, %dx%d @ %d,%d)\n", wm_log("XCB_MAP_REQUEST (window %d, %p, frame %d, %dx%d @ %d,%d)\n",
window->id, window, window->frame_id, window->id, window, window->frame_id,
window->width, window->height, window->x, window->y); window->width, window->height,
window->map_request_x, window->map_request_y);
weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE); weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE);
weston_wm_window_set_net_wm_state(window); weston_wm_window_set_net_wm_state(window);
@ -1283,6 +1291,8 @@ weston_wm_window_create(struct weston_wm *wm,
window->x = x; window->x = x;
window->y = y; window->y = y;
window->pos_dirty = false; window->pos_dirty = false;
window->map_request_x = INT_MIN; /* out of range for valid positions */
window->map_request_y = INT_MIN; /* out of range for valid positions */
weston_output_weak_ref_init(&window->legacy_fullscreen_output); weston_output_weak_ref_init(&window->legacy_fullscreen_output);
geometry_reply = xcb_get_geometry_reply(wm->conn, geometry_cookie, NULL); geometry_reply = xcb_get_geometry_reply(wm->conn, geometry_cookie, NULL);
@ -2580,6 +2590,17 @@ legacy_fullscreen(struct weston_wm *wm,
return 0; return 0;
} }
static bool
weston_wm_window_is_positioned(struct weston_wm_window *window)
{
if (window->map_request_x == INT_MIN ||
window->map_request_y == INT_MIN)
weston_log("XWM warning: win %d did not see map request\n",
window->id);
return window->map_request_x != 0 || window->map_request_y != 0;
}
static bool static bool
weston_wm_window_type_inactive(struct weston_wm_window *window) weston_wm_window_type_inactive(struct weston_wm_window *window)
{ {
@ -2670,6 +2691,10 @@ xserver_map_shell_surface(struct weston_wm_window *window,
xwayland_interface->set_xwayland(window->shsurf, xwayland_interface->set_xwayland(window->shsurf,
window->x, window->x,
window->y); window->y);
} else if (weston_wm_window_is_positioned(window)) {
xwayland_interface->set_toplevel_with_position(window->shsurf,
window->map_request_x,
window->map_request_y);
} else { } else {
xwayland_interface->set_toplevel(window->shsurf); xwayland_interface->set_toplevel(window->shsurf);
} }

Loading…
Cancel
Save