mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
xdg-shell: add support for v7
This commit is contained in:
parent
a08acfcee0
commit
afe427d149
3 changed files with 39 additions and 3 deletions
|
|
@ -141,6 +141,7 @@ enum wlr_xdg_surface_role {
|
||||||
struct wlr_xdg_toplevel_state {
|
struct wlr_xdg_toplevel_state {
|
||||||
bool maximized, fullscreen, resizing, activated, suspended;
|
bool maximized, fullscreen, resizing, activated, suspended;
|
||||||
uint32_t tiled; // enum wlr_edges
|
uint32_t tiled; // enum wlr_edges
|
||||||
|
uint32_t constrained; // enum wlr_edges
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
int32_t max_width, max_height;
|
int32_t max_width, max_height;
|
||||||
int32_t min_width, min_height;
|
int32_t min_width, min_height;
|
||||||
|
|
@ -168,6 +169,7 @@ struct wlr_xdg_toplevel_configure {
|
||||||
// The following fields must always be set to reflect the current state
|
// The following fields must always be set to reflect the current state
|
||||||
bool maximized, fullscreen, resizing, activated, suspended;
|
bool maximized, fullscreen, resizing, activated, suspended;
|
||||||
uint32_t tiled; // enum wlr_edges
|
uint32_t tiled; // enum wlr_edges
|
||||||
|
uint32_t constrained; // enum wlr_edges
|
||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
|
|
||||||
// Only for WLR_XDG_TOPLEVEL_CONFIGURE_BOUNDS
|
// Only for WLR_XDG_TOPLEVEL_CONFIGURE_BOUNDS
|
||||||
|
|
@ -454,6 +456,14 @@ uint32_t wlr_xdg_toplevel_set_wm_capabilities(struct wlr_xdg_toplevel *toplevel,
|
||||||
uint32_t wlr_xdg_toplevel_set_suspended(struct wlr_xdg_toplevel *toplevel,
|
uint32_t wlr_xdg_toplevel_set_suspended(struct wlr_xdg_toplevel *toplevel,
|
||||||
bool suspended);
|
bool suspended);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request that this toplevel consider itself constrained and doesn't attempt to
|
||||||
|
* resize from some edges. `constrained_edges` is a bitfield of enum wlr_edges.
|
||||||
|
* Returns the associated configure serial.
|
||||||
|
*/
|
||||||
|
uint32_t wlr_xdg_toplevel_set_constrained(struct wlr_xdg_toplevel *toplevel,
|
||||||
|
uint32_t constrained_edges);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request that this toplevel closes.
|
* Request that this toplevel closes.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "types/wlr_xdg_shell.h"
|
#include "types/wlr_xdg_shell.h"
|
||||||
|
|
||||||
#define WM_BASE_VERSION 6
|
#define WM_BASE_VERSION 7
|
||||||
|
|
||||||
static const struct xdg_wm_base_interface xdg_shell_impl;
|
static const struct xdg_wm_base_interface xdg_shell_impl;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ void handle_xdg_toplevel_ack_configure(
|
||||||
toplevel->pending.resizing = configure->resizing;
|
toplevel->pending.resizing = configure->resizing;
|
||||||
toplevel->pending.activated = configure->activated;
|
toplevel->pending.activated = configure->activated;
|
||||||
toplevel->pending.tiled = configure->tiled;
|
toplevel->pending.tiled = configure->tiled;
|
||||||
|
toplevel->pending.constrained = configure->constrained;
|
||||||
toplevel->pending.suspended = configure->suspended;
|
toplevel->pending.suspended = configure->suspended;
|
||||||
|
|
||||||
toplevel->pending.width = configure->width;
|
toplevel->pending.width = configure->width;
|
||||||
|
|
@ -80,7 +81,7 @@ struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
|
||||||
states[nstates++] = XDG_TOPLEVEL_STATE_ACTIVATED;
|
states[nstates++] = XDG_TOPLEVEL_STATE_ACTIVATED;
|
||||||
}
|
}
|
||||||
if (configure->tiled && version >= XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) {
|
if (configure->tiled && version >= XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) {
|
||||||
const struct {
|
static const struct {
|
||||||
enum wlr_edges edge;
|
enum wlr_edges edge;
|
||||||
enum xdg_toplevel_state state;
|
enum xdg_toplevel_state state;
|
||||||
} tiled[] = {
|
} tiled[] = {
|
||||||
|
|
@ -100,6 +101,24 @@ struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
|
||||||
if (configure->suspended && version >= XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION) {
|
if (configure->suspended && version >= XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION) {
|
||||||
states[nstates++] = XDG_TOPLEVEL_STATE_SUSPENDED;
|
states[nstates++] = XDG_TOPLEVEL_STATE_SUSPENDED;
|
||||||
}
|
}
|
||||||
|
if (configure->constrained && version >= XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT_SINCE_VERSION) {
|
||||||
|
static const struct {
|
||||||
|
enum wlr_edges edge;
|
||||||
|
enum xdg_toplevel_state state;
|
||||||
|
} constrained[] = {
|
||||||
|
{ WLR_EDGE_LEFT, XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT },
|
||||||
|
{ WLR_EDGE_RIGHT, XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT },
|
||||||
|
{ WLR_EDGE_TOP, XDG_TOPLEVEL_STATE_CONSTRAINED_TOP },
|
||||||
|
{ WLR_EDGE_BOTTOM, XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sizeof(constrained) / sizeof(constrained[0]); ++i) {
|
||||||
|
if ((configure->constrained & constrained[i].edge) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
states[nstates++] = constrained[i].state;
|
||||||
|
}
|
||||||
|
}
|
||||||
assert(nstates <= sizeof(states) / sizeof(states[0]));
|
assert(nstates <= sizeof(states) / sizeof(states[0]));
|
||||||
|
|
||||||
int32_t width = configure->width;
|
int32_t width = configure->width;
|
||||||
|
|
@ -638,3 +657,10 @@ uint32_t wlr_xdg_toplevel_set_suspended(struct wlr_xdg_toplevel *toplevel,
|
||||||
toplevel->scheduled.suspended = suspended;
|
toplevel->scheduled.suspended = suspended;
|
||||||
return wlr_xdg_surface_schedule_configure(toplevel->base);
|
return wlr_xdg_surface_schedule_configure(toplevel->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t wlr_xdg_toplevel_set_constrained(struct wlr_xdg_toplevel *toplevel, uint32_t constrained) {
|
||||||
|
assert(toplevel->base->client->shell->version >=
|
||||||
|
XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT_SINCE_VERSION);
|
||||||
|
toplevel->scheduled.constrained = constrained;
|
||||||
|
return wlr_xdg_surface_schedule_configure(toplevel->base);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue