xdg-shell-v6: redesign the configure/ack_configure workflow

master
emersion 7 years ago
parent 125138f1a0
commit e74ddaaf10
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -62,19 +62,10 @@ enum wlr_xdg_surface_v6_role {
}; };
struct wlr_xdg_toplevel_v6_state { struct wlr_xdg_toplevel_v6_state {
bool maximized; bool maximized, fullscreen, resizing, activated;
bool fullscreen; uint32_t width, height;
bool resizing; uint32_t max_width, max_height;
bool activated; uint32_t min_width, min_height;
uint32_t width;
uint32_t height;
uint32_t max_width;
uint32_t max_height;
uint32_t min_width;
uint32_t min_height;
}; };
struct wlr_xdg_toplevel_v6 { struct wlr_xdg_toplevel_v6 {
@ -90,7 +81,8 @@ struct wlr_xdg_toplevel_v6 {
struct wlr_xdg_surface_v6_configure { struct wlr_xdg_surface_v6_configure {
struct wl_list link; // wlr_xdg_surface_v6::configure_list struct wl_list link; // wlr_xdg_surface_v6::configure_list
uint32_t serial; 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 { struct wlr_xdg_surface_v6 {
@ -100,6 +92,7 @@ struct wlr_xdg_surface_v6 {
struct wl_list link; // wlr_xdg_client_v6::surfaces struct wl_list link; // wlr_xdg_client_v6::surfaces
enum wlr_xdg_surface_v6_role role; enum wlr_xdg_surface_v6_role role;
// TODO: the _state prefix should be dropped
union { union {
struct wlr_xdg_toplevel_v6 *toplevel_state; struct wlr_xdg_toplevel_v6 *toplevel_state;
struct wlr_xdg_popup_v6 *popup_state; struct wlr_xdg_popup_v6 *popup_state;
@ -118,7 +111,7 @@ struct wlr_xdg_surface_v6 {
bool has_next_geometry; bool has_next_geometry;
struct wlr_box *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; 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}; float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
// Check if we can delegate the fullscreen surface to the output // 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; struct roots_view *view = output->fullscreen_view;
// Make sure the view is centered on screen // 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->close = close;
view->destroy = destroy; view->destroy = destroy;
roots_surface->view = view; 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 *surface,
struct wlr_xdg_surface_v6_configure *configure) { struct wlr_xdg_surface_v6_configure *configure) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->next = configure->state;
surface->toplevel_state->pending.width = 0; surface->toplevel_state->current.maximized =
surface->toplevel_state->pending.height = 0; 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, 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 { } else {
struct wlr_xdg_surface_v6_configure *configure = struct wlr_xdg_surface_v6_configure *configure =
wl_container_of(state->base->configure_list.prev, configure, link); wl_container_of(state->base->configure_list.prev, configure, link);
configured.state = configure->state; configured.state = configure->toplevel_state;
configured.width = configure->state.width; configured.width = configure->toplevel_state.width;
configured.height = configure->state.height; configured.height = configure->toplevel_state.height;
} }
if (state->pending.activated != configured.state.activated) { if (state->pending.activated != configured.state.activated) {
@ -1019,7 +1025,7 @@ static void wlr_xdg_toplevel_v6_send_configure(
uint32_t *s; uint32_t *s;
struct wl_array states; struct wl_array states;
configure->state = surface->toplevel_state->pending; configure->toplevel_state = surface->toplevel_state->pending;
wl_array_init(&states); wl_array_init(&states);
if (surface->toplevel_state->pending.maximized) { if (surface->toplevel_state->pending.maximized) {
@ -1160,8 +1166,7 @@ static void wlr_xdg_surface_v6_toplevel_committed(
struct wlr_xdg_surface_v6 *surface) { struct wlr_xdg_surface_v6 *surface) {
assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
if (!wlr_surface_has_buffer(surface->surface) if (!surface->toplevel_state->added) {
&& !surface->toplevel_state->added) {
// on the first commit, send a configure request to tell the client it // on the first commit, send a configure request to tell the client it
// is added // is added
wlr_xdg_surface_v6_schedule_configure(surface); wlr_xdg_surface_v6_schedule_configure(surface);
@ -1169,11 +1174,15 @@ static void wlr_xdg_surface_v6_toplevel_committed(
return; return;
} }
if (!wlr_surface_has_buffer(surface->surface)) { // update state that doesn't need compositor approval
return; surface->toplevel_state->current.max_width =
} surface->toplevel_state->next.max_width;
surface->toplevel_state->current.min_width =
surface->toplevel_state->current = surface->toplevel_state->next; 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( 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); assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL);
surface->toplevel_state->pending.width = width; surface->toplevel_state->pending.width = width;
surface->toplevel_state->pending.height = height; 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); return wlr_xdg_surface_v6_schedule_configure(surface);
} }

Loading…
Cancel
Save