diff --git a/include/libweston-desktop/libweston-desktop.h b/include/libweston-desktop/libweston-desktop.h index 8257e467..3536935b 100644 --- a/include/libweston-desktop/libweston-desktop.h +++ b/include/libweston-desktop/libweston-desktop.h @@ -44,6 +44,14 @@ enum weston_desktop_surface_edge { WESTON_DESKTOP_SURFACE_EDGE_BOTTOM_RIGHT = 10, }; +enum weston_top_level_tiled_orientation { + WESTON_TOP_LEVEL_TILED_ORIENTATION_NONE = 0 << 0, + WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT = 1 << 1, + WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT = 1 << 2, + WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP = 1 << 3, + WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM = 1 << 4, +}; + struct weston_desktop; struct weston_desktop_client; struct weston_desktop_surface; @@ -166,6 +174,9 @@ void weston_desktop_surface_set_size(struct weston_desktop_surface *surface, int32_t width, int32_t height); void +weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface, + enum weston_top_level_tiled_orientation tile_orientation); +void weston_desktop_surface_close(struct weston_desktop_surface *surface); void weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface *surface, diff --git a/libweston/desktop/internal.h b/libweston/desktop/internal.h index f45b6601..1d035d5c 100644 --- a/libweston/desktop/internal.h +++ b/libweston/desktop/internal.h @@ -105,6 +105,8 @@ struct weston_desktop_surface_implementation { void *user_data, bool resizing); void (*set_size)(struct weston_desktop_surface *surface, void *user_data, int32_t width, int32_t height); + void (*set_orientation)(struct weston_desktop_surface *surface, + void *user_data, enum weston_top_level_tiled_orientation tiled_orientation); void (*committed)(struct weston_desktop_surface *surface, void *user_data, int32_t sx, int32_t sy); void (*update_position)(struct weston_desktop_surface *surface, diff --git a/libweston/desktop/surface.c b/libweston/desktop/surface.c index 433f08ae..6b3f4aeb 100644 --- a/libweston/desktop/surface.c +++ b/libweston/desktop/surface.c @@ -506,6 +506,16 @@ weston_desktop_surface_set_size(struct weston_desktop_surface *surface, int32_t width, height); } +WL_EXPORT void +weston_desktop_surface_set_orientation(struct weston_desktop_surface *surface, + enum weston_top_level_tiled_orientation tile_orientation) +{ + if (surface->implementation->set_orientation != NULL) + surface->implementation->set_orientation(surface, + surface->implementation_data, + tile_orientation); +} + WL_EXPORT void weston_desktop_surface_close(struct weston_desktop_surface *surface) { diff --git a/libweston/desktop/xdg-shell.c b/libweston/desktop/xdg-shell.c index 002a8231..ca9862c1 100644 --- a/libweston/desktop/xdg-shell.c +++ b/libweston/desktop/xdg-shell.c @@ -94,6 +94,7 @@ struct weston_desktop_xdg_toplevel_state { bool fullscreen; bool resizing; bool activated; + uint32_t tiled_orientation; }; struct weston_desktop_xdg_toplevel_configure { @@ -625,6 +626,30 @@ weston_desktop_xdg_toplevel_send_configure(struct weston_desktop_xdg_toplevel *t *s = XDG_TOPLEVEL_STATE_ACTIVATED; } + if (toplevel->pending.state.tiled_orientation & + WESTON_TOP_LEVEL_TILED_ORIENTATION_LEFT) { + s = wl_array_add(&states, sizeof(uint32_t)); + *s = XDG_TOPLEVEL_STATE_TILED_LEFT; + } + + if (toplevel->pending.state.tiled_orientation & + WESTON_TOP_LEVEL_TILED_ORIENTATION_RIGHT) { + s = wl_array_add(&states, sizeof(uint32_t)); + *s = XDG_TOPLEVEL_STATE_TILED_RIGHT; + } + + if (toplevel->pending.state.tiled_orientation & + WESTON_TOP_LEVEL_TILED_ORIENTATION_TOP) { + s = wl_array_add(&states, sizeof(uint32_t)); + *s = XDG_TOPLEVEL_STATE_TILED_TOP; + } + + if (toplevel->pending.state.tiled_orientation & + WESTON_TOP_LEVEL_TILED_ORIENTATION_BOTTOM) { + s = wl_array_add(&states, sizeof(uint32_t)); + *s = XDG_TOPLEVEL_STATE_TILED_BOTTOM; + } + xdg_toplevel_send_configure(toplevel->resource, toplevel->pending.size.width, toplevel->pending.size.height, @@ -686,6 +711,16 @@ weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface, weston_desktop_xdg_surface_schedule_configure(&toplevel->base); } +static void +weston_desktop_xdg_toplevel_set_orientation(struct weston_desktop_surface *surface, void *user_data, + enum weston_top_level_tiled_orientation tiled_orientation) +{ + struct weston_desktop_xdg_toplevel *toplevel = user_data; + + toplevel->pending.state.tiled_orientation = tiled_orientation; + weston_desktop_xdg_surface_schedule_configure(&toplevel->base); +} + static void weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplevel, int32_t sx, int32_t sy) @@ -1104,6 +1139,9 @@ weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel *to return false; if (toplevel->pending.state.resizing != configured.state.resizing) return false; + if (toplevel->pending.state.tiled_orientation != + configured.state.tiled_orientation) + return false; if (toplevel->pending.size.width == configured.size.width && toplevel->pending.size.height == configured.size.height) @@ -1478,6 +1516,7 @@ static const struct weston_desktop_surface_implementation weston_desktop_xdg_sur .set_resizing = weston_desktop_xdg_toplevel_set_resizing, .set_activated = weston_desktop_xdg_toplevel_set_activated, .set_size = weston_desktop_xdg_toplevel_set_size, + .set_orientation = weston_desktop_xdg_toplevel_set_orientation, .get_maximized = weston_desktop_xdg_toplevel_get_maximized, .get_fullscreen = weston_desktop_xdg_toplevel_get_fullscreen,