diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index c5afd8e1..9ebc9550 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -2451,6 +2451,17 @@ desktop_surface_set_xwayland_position(struct weston_desktop_surface *surface, shsurf->xwayland.is_set = true; } +static void +desktop_surface_get_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); + + *x = shsurf->view->geometry.x; + *y = shsurf->view->geometry.y; +} + static const struct weston_desktop_api shell_desktop_api = { .struct_size = sizeof(struct weston_desktop_api), .surface_added = desktop_surface_added, @@ -2465,6 +2476,7 @@ static const struct weston_desktop_api shell_desktop_api = { .ping_timeout = desktop_surface_ping_timeout, .pong = desktop_surface_pong, .set_xwayland_position = desktop_surface_set_xwayland_position, + .get_position = desktop_surface_get_position, }; /* ************************ * diff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h index 3e7ac738..313179ef 100644 --- a/include/libweston-desktop/libweston-desktop.h +++ b/include/libweston-desktop/libweston-desktop.h @@ -113,6 +113,9 @@ struct weston_desktop_api { */ void (*set_xwayland_position)(struct weston_desktop_surface *surface, int32_t x, int32_t y, void *user_data); + void (*get_position)(struct weston_desktop_surface *surface, + int32_t *x, int32_t *y, + void *user_data); }; void diff --git a/kiosk-shell/kiosk-shell.c b/kiosk-shell/kiosk-shell.c index 62949ed4..e13742fb 100644 --- a/kiosk-shell/kiosk-shell.c +++ b/kiosk-shell/kiosk-shell.c @@ -951,6 +951,17 @@ desktop_surface_set_xwayland_position(struct weston_desktop_surface *desktop_sur shsurf->xwayland.is_set = true; } +static void +desktop_surface_get_position(struct weston_desktop_surface *desktop_surface, + int32_t *x, int32_t *y, void *shell) +{ + struct kiosk_shell_surface *shsurf = + weston_desktop_surface_get_user_data(desktop_surface); + + *x = shsurf->view->geometry.x; + *y = shsurf->view->geometry.y; +} + static const struct weston_desktop_api kiosk_shell_desktop_api = { .struct_size = sizeof(struct weston_desktop_api), .surface_added = desktop_surface_added, @@ -965,6 +976,7 @@ static const struct weston_desktop_api kiosk_shell_desktop_api = { .ping_timeout = desktop_surface_ping_timeout, .pong = desktop_surface_pong, .set_xwayland_position = desktop_surface_set_xwayland_position, + .get_position = desktop_surface_get_position, }; /* diff --git a/libweston/desktop/internal.h b/libweston/desktop/internal.h index 8fdd4a28..f45b6601 100644 --- a/libweston/desktop/internal.h +++ b/libweston/desktop/internal.h @@ -86,6 +86,11 @@ weston_desktop_api_set_xwayland_position(struct weston_desktop *desktop, struct weston_desktop_surface *surface, int32_t x, int32_t y); +void +weston_desktop_api_get_position(struct weston_desktop *desktop, + struct weston_desktop_surface *surface, + int32_t *x, int32_t *y); + struct weston_desktop_seat * weston_desktop_seat_from_seat(struct weston_seat *wseat); diff --git a/libweston/desktop/libweston-desktop.c b/libweston/desktop/libweston-desktop.c index ea6fbebe..f7ecc709 100644 --- a/libweston/desktop/libweston-desktop.c +++ b/libweston/desktop/libweston-desktop.c @@ -237,3 +237,14 @@ weston_desktop_api_set_xwayland_position(struct weston_desktop *desktop, desktop->api.set_xwayland_position(surface, x, y, desktop->user_data); } + +void +weston_desktop_api_get_position(struct weston_desktop *desktop, + struct weston_desktop_surface *surface, + int32_t *x, int32_t *y) +{ + if (!desktop->api.get_position) + return; + + desktop->api.get_position(surface, x, y, desktop->user_data); +}