shells: Add libweston-desktop API to query position and add to shells

We're going to need this to properly send xwayland events later, so add
API to get the current x,y co-ordinates of a shell surface and add it to
the kiosk and desktop shells.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
dev
Derek Foreman 2 years ago committed by Pekka Paalanen
parent ed97387a4e
commit d615abdffd
  1. 12
      desktop-shell/shell.c
  2. 3
      include/libweston-desktop/libweston-desktop.h
  3. 12
      kiosk-shell/kiosk-shell.c
  4. 5
      libweston/desktop/internal.h
  5. 11
      libweston/desktop/libweston-desktop.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,
};
/* ************************ *

@ -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

@ -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,
};
/*

@ -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);

@ -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);
}

Loading…
Cancel
Save