xdg-shell-v6: redesign the configure/ack_configure workflow
This commit is contained in:
parent
125138f1a0
commit
e74ddaaf10
|
@ -62,19 +62,10 @@ enum wlr_xdg_surface_v6_role {
|
|||
};
|
||||
|
||||
struct wlr_xdg_toplevel_v6_state {
|
||||
bool maximized;
|
||||
bool fullscreen;
|
||||
bool resizing;
|
||||
bool activated;
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t max_width;
|
||||
uint32_t max_height;
|
||||
|
||||
uint32_t min_width;
|
||||
uint32_t min_height;
|
||||
bool maximized, fullscreen, resizing, activated;
|
||||
uint32_t width, height;
|
||||
uint32_t max_width, max_height;
|
||||
uint32_t min_width, min_height;
|
||||
};
|
||||
|
||||
struct wlr_xdg_toplevel_v6 {
|
||||
|
@ -90,7 +81,8 @@ struct wlr_xdg_toplevel_v6 {
|
|||
struct wlr_xdg_surface_v6_configure {
|
||||
struct wl_list link; // wlr_xdg_surface_v6::configure_list
|
||||
uint32_t serial;
|
||||
struct wlr_xdg_toplevel_v6_state state;
|
||||
|
||||
struct wlr_xdg_toplevel_v6_state toplevel_state; // TODO: should be null-able
|
||||
};
|
||||
|
||||
struct wlr_xdg_surface_v6 {
|
||||
|
@ -100,6 +92,7 @@ struct wlr_xdg_surface_v6 {
|
|||
struct wl_list link; // wlr_xdg_client_v6::surfaces
|
||||
enum wlr_xdg_surface_v6_role role;
|
||||
|
||||
// TODO: the _state prefix should be dropped
|
||||
union {
|
||||
struct wlr_xdg_toplevel_v6 *toplevel_state;
|
||||
struct wlr_xdg_popup_v6 *popup_state;
|
||||
|
@ -118,7 +111,7 @@ struct wlr_xdg_surface_v6 {
|
|||
|
||||
bool has_next_geometry;
|
||||
struct wlr_box *next_geometry;
|
||||
struct wlr_box *geometry;
|
||||
struct wlr_box *geometry; // TODO: should not be a pointer
|
||||
|
||||
struct wl_listener surface_destroy_listener;
|
||||
|
||||
|
|
|
@ -433,7 +433,8 @@ static void render_output(struct roots_output *output) {
|
|||
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
|
||||
|
||||
// Check if we can delegate the fullscreen surface to the output
|
||||
if (output->fullscreen_view != NULL) {
|
||||
if (output->fullscreen_view != NULL &&
|
||||
output->fullscreen_view->wlr_surface != NULL) {
|
||||
struct roots_view *view = output->fullscreen_view;
|
||||
|
||||
// Make sure the view is centered on screen
|
||||
|
|
|
@ -385,4 +385,11 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
view->close = close;
|
||||
view->destroy = destroy;
|
||||
roots_surface->view = view;
|
||||
|
||||
if (surface->toplevel_state->next.maximized) {
|
||||
view_maximize(view, true);
|
||||
}
|
||||
if (surface->toplevel_state->next.fullscreen) {
|
||||
view_set_fullscreen(view, true, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -868,9 +868,15 @@ static void wlr_xdg_toplevel_v6_ack_configure(
|
|||
struct wlr_xdg_surface_v6 *surface,
|
||||
struct wlr_xdg_surface_v6_configure *configure) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->next = configure->state;
|
||||
surface->toplevel_state->pending.width = 0;
|
||||
surface->toplevel_state->pending.height = 0;
|
||||
|
||||
surface->toplevel_state->current.maximized =
|
||||
configure->toplevel_state.maximized;
|
||||
surface->toplevel_state->current.fullscreen =
|
||||
configure->toplevel_state.fullscreen;
|
||||
surface->toplevel_state->current.resizing =
|
||||
configure->toplevel_state.resizing;
|
||||
surface->toplevel_state->current.activated =
|
||||
configure->toplevel_state.activated;
|
||||
}
|
||||
|
||||
static void xdg_surface_handle_ack_configure(struct wl_client *client,
|
||||
|
@ -982,9 +988,9 @@ static bool wlr_xdg_surface_v6_toplevel_state_compare(
|
|||
} else {
|
||||
struct wlr_xdg_surface_v6_configure *configure =
|
||||
wl_container_of(state->base->configure_list.prev, configure, link);
|
||||
configured.state = configure->state;
|
||||
configured.width = configure->state.width;
|
||||
configured.height = configure->state.height;
|
||||
configured.state = configure->toplevel_state;
|
||||
configured.width = configure->toplevel_state.width;
|
||||
configured.height = configure->toplevel_state.height;
|
||||
}
|
||||
|
||||
if (state->pending.activated != configured.state.activated) {
|
||||
|
@ -1019,7 +1025,7 @@ static void wlr_xdg_toplevel_v6_send_configure(
|
|||
uint32_t *s;
|
||||
struct wl_array states;
|
||||
|
||||
configure->state = surface->toplevel_state->pending;
|
||||
configure->toplevel_state = surface->toplevel_state->pending;
|
||||
|
||||
wl_array_init(&states);
|
||||
if (surface->toplevel_state->pending.maximized) {
|
||||
|
@ -1160,8 +1166,7 @@ static void wlr_xdg_surface_v6_toplevel_committed(
|
|||
struct wlr_xdg_surface_v6 *surface) {
|
||||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
|
||||
if (!wlr_surface_has_buffer(surface->surface)
|
||||
&& !surface->toplevel_state->added) {
|
||||
if (!surface->toplevel_state->added) {
|
||||
// on the first commit, send a configure request to tell the client it
|
||||
// is added
|
||||
wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
|
@ -1169,11 +1174,15 @@ static void wlr_xdg_surface_v6_toplevel_committed(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!wlr_surface_has_buffer(surface->surface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
surface->toplevel_state->current = surface->toplevel_state->next;
|
||||
// update state that doesn't need compositor approval
|
||||
surface->toplevel_state->current.max_width =
|
||||
surface->toplevel_state->next.max_width;
|
||||
surface->toplevel_state->current.min_width =
|
||||
surface->toplevel_state->next.min_width;
|
||||
surface->toplevel_state->current.max_height =
|
||||
surface->toplevel_state->next.max_height;
|
||||
surface->toplevel_state->current.min_height =
|
||||
surface->toplevel_state->next.min_height;
|
||||
}
|
||||
|
||||
static void wlr_xdg_surface_v6_popup_committed(
|
||||
|
@ -1482,6 +1491,7 @@ uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface,
|
|||
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
|
||||
surface->toplevel_state->pending.width = width;
|
||||
surface->toplevel_state->pending.height = height;
|
||||
wlr_log(L_DEBUG, "wlr_xdg_toplevel_v6_set_size %d", width);
|
||||
|
||||
return wlr_xdg_surface_v6_schedule_configure(surface);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue