diff options
author | Tiago Vignatti <tiago.vignatti@intel.com> | 2012-08-17 14:59:14 +0300 |
---|---|---|
committer | Tiago Vignatti <tiago.vignatti@intel.com> | 2012-09-13 18:12:50 +0300 |
commit | d8563ac2794404e61e93c64696d74c4dce18cf41 (patch) | |
tree | 6a9aa04413d3e627fd0f48562150c8992e376816 | |
parent | d9773a55bff5027a51292e8dbe72b7c6e4cf817e (diff) |
xwayland: Track protocol changes for window positioning
It's based on global window coordinates, which is the "right way".
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
-rw-r--r-- | hw/xfree86/xwayland/xserver.xml | 33 | ||||
-rw-r--r-- | hw/xfree86/xwayland/xwayland-input.c | 6 | ||||
-rw-r--r-- | hw/xfree86/xwayland/xwayland-private.h | 3 | ||||
-rw-r--r-- | hw/xfree86/xwayland/xwayland-window.c | 7 | ||||
-rw-r--r-- | hw/xfree86/xwayland/xwayland.c | 62 |
5 files changed, 103 insertions, 8 deletions
diff --git a/hw/xfree86/xwayland/xserver.xml b/hw/xfree86/xwayland/xserver.xml index 5c0630dc6..f59303d93 100644 --- a/hw/xfree86/xwayland/xserver.xml +++ b/hw/xfree86/xwayland/xserver.xml @@ -33,6 +33,25 @@ <arg name="surface" type="object" interface="wl_surface"/> <arg name="id" type="uint"/> </request> + + <event name="map"> + <description summary="announce when window is ready to be mapped"> + Announce Xwayland that window id is ready to be mapped. Effectively + this happens after a MapNotify hits the X Window Manager, which just + sent a wm_map to the compositor. + </description> + <arg name="id" type="uint"/> + </event> + + <event name="position"> + <description summary="suggest global window coordinates"> + </description> + + <arg name="id" type="uint"/> + <arg name="x" type="int"/> + <arg name="y" type="int"/> + </event> + </interface> <interface name="wm_connect" version="1"> @@ -72,6 +91,17 @@ <arg name="flags" type="uint"/> </request> + <request name="map"> + <description summary="announce when window is ready to be mapped"> + Announce compositor that window id is ready to be mapped via Xwayland. + Effectively this happens after a MapNotify hits the X Window Manager; + the compositor would have to proceed sending to Xwayland via + xserver_send_map. + </description> + + <arg name="id" type="uint"/> + </request> + <request name="move"> <arg name="id" type="uint"/> </request> @@ -97,8 +127,9 @@ <arg name="height" type="int"/> </event> - <event name="activate"> + <event name="state"> <arg name="id" type="uint"/> + <arg name="activate" type="uint"/> </event> </interface> diff --git a/hw/xfree86/xwayland/xwayland-input.c b/hw/xfree86/xwayland/xwayland-input.c index e31fbec53..9859c260f 100644 --- a/hw/xfree86/xwayland/xwayland-input.c +++ b/hw/xfree86/xwayland/xwayland-input.c @@ -270,6 +270,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, int i; int sx = wl_fixed_to_int(sx_w); int sy = wl_fixed_to_int(sy_w); + int32_t dx, dy; ScreenPtr pScreen = xwl_seat->xwl_screen->screen; xwl_seat->xwl_screen->serial = serial; @@ -277,7 +278,10 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, xwl_seat->focus_window = wl_surface_get_user_data(surface); - (*pScreen->SetCursorPosition) (dev, pScreen, sx, sy, TRUE); + dx = xwl_seat->focus_window->window->drawable.x; + dy = xwl_seat->focus_window->window->drawable.y; + + (*pScreen->SetCursorPosition) (dev, pScreen, sx + dx, sy + dy, TRUE); SetDeviceRedirectWindow(xwl_seat->pointer, xwl_seat->focus_window->window); diff --git a/hw/xfree86/xwayland/xwayland-private.h b/hw/xfree86/xwayland/xwayland-private.h index a9e05780e..58720f929 100644 --- a/hw/xfree86/xwayland/xwayland-private.h +++ b/hw/xfree86/xwayland/xwayland-private.h @@ -101,6 +101,9 @@ struct xwl_seat { struct xwl_screen *xwl_screen_get(ScreenPtr screen); +void +xwl_window_attach(struct xwl_window *xwl_window, PixmapPtr pixmap); + void xwayland_screen_preinit_output(struct xwl_screen *xwl_screen, ScrnInfoPtr scrninfo); int xwl_screen_init_cursor(struct xwl_screen *xwl_screen, ScreenPtr screen); diff --git a/hw/xfree86/xwayland/xwayland-window.c b/hw/xfree86/xwayland/xwayland-window.c index 3c9679334..892e7dbaa 100644 --- a/hw/xfree86/xwayland/xwayland-window.c +++ b/hw/xfree86/xwayland/xwayland-window.c @@ -59,7 +59,7 @@ static const struct wl_callback_listener free_pixmap_listener = { free_pixmap, }; -static void +void xwl_window_attach(struct xwl_window *xwl_window, PixmapPtr pixmap) { struct xwl_screen *xwl_screen = xwl_window->xwl_screen; @@ -192,12 +192,7 @@ xwl_realize_window(WindowPtr window) return FALSE; } - if (xwl_screen->xserver) - xserver_set_window_surface(xwl_screen->xserver, - xwl_window->surface, window->drawable.id); - wl_surface_set_user_data(xwl_window->surface, xwl_window); - xwl_window_attach(xwl_window, (*screen->GetWindowPixmap)(window)); dixSetPrivate(&window->devPrivates, &xwl_window_private_key, xwl_window); diff --git a/hw/xfree86/xwayland/xwayland.c b/hw/xfree86/xwayland/xwayland.c index 647b43f97..dfe6da315 100644 --- a/hw/xfree86/xwayland/xwayland.c +++ b/hw/xfree86/xwayland/xwayland.c @@ -74,6 +74,66 @@ static const struct xserver_connect_listener xserver_connect_listener = { }; static void +xwl_get_map(void *data, struct xserver *xserver, int id) +{ + struct xwl_screen *xwl_screen = data; + struct xwl_window *xwl_window, *wtmp; + ScreenPtr screen = xwl_screen->screen; + WindowPtr pWin; + + xorg_list_for_each_entry_safe(xwl_window, wtmp, + &xwl_screen->window_list, link) { + pWin = xwl_window->window; + if (pWin->drawable.id == id) { + xserver_set_window_surface(xwl_screen->xserver, + xwl_window->surface, + pWin->drawable.id); + xwl_window_attach(xwl_window, (*screen->GetWindowPixmap)(pWin)); + return; + } + } +} + +static void +xwl_get_position(void *data, struct xserver *xserver, uint32_t id, int x, int y) +{ + struct xwl_screen *xwl_screen = data; + struct xwl_window *xwl_window, *wtmp; + WindowPtr pWin; + ClientPtr pClient; + int err; + XID vlist[2]; + + vlist[0] = x; + vlist[1] = y; + + xorg_list_for_each_entry_safe(xwl_window, wtmp, + &xwl_screen->window_list, link) { + pWin = xwl_window->window; + if (pWin->drawable.id == id) { + err = + dixLookupClient(&pClient, pWin->drawable.id, serverClient, + DixUnknownAccess); + if (err != Success) { + ErrorF("Failed to lookup window: 0x%x\n", + (unsigned int) pWin->drawable.id); + return; + } + + ConfigureWindow(pWin, CWX | CWY, vlist, pClient); + + return; + } + } + +} + +static const struct xserver_listener xserver_listener = { + xwl_get_map, + xwl_get_position +}; + +static void xwl_input_delayed_init(void *data, struct wl_callback *callback, uint32_t time) { struct xwl_screen *xwl_screen = data; @@ -108,6 +168,8 @@ global_handler(struct wl_display *display_, } else if (strcmp (interface, "xserver") == 0) { xwl_screen->xserver = wl_display_bind(xwl_screen->display, id, &xserver_interface); + xserver_add_listener(xwl_screen->xserver, &xserver_listener, + xwl_screen); } else if (strcmp (interface, "xserver_connect") == 0) { xwl_screen->xserver_conn = wl_display_bind(xwl_screen->display, id, &xserver_connect_interface); |