xdg-shell: drop automatic surface configuration

Compositors now are expected to wait for an initial commit by checking
wlr_xdg_surface.initial_commit on every surface commit and send
(schedule) configure events manually.
This commit is contained in:
Kirill Primak 2023-11-23 16:10:39 +03:00 committed by Isaac Freund
parent d368028bd5
commit 811ca199c4
6 changed files with 69 additions and 37 deletions

View file

@ -246,13 +246,6 @@ void handle_xdg_popup_client_commit(struct wlr_xdg_popup *popup) {
}
}
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup) {
if (popup->base->initial_commit && !popup->sent_initial_configure) {
wlr_xdg_surface_schedule_configure(popup->base);
popup->sent_initial_configure = true;
}
}
static const struct xdg_popup_interface xdg_popup_implementation;
struct wlr_xdg_popup *wlr_xdg_popup_from_resource(
@ -285,7 +278,7 @@ static void xdg_popup_handle_grab(struct wl_client *client,
wlr_xdg_popup_destroy(popup);
return;
}
if (popup->sent_initial_configure) {
if (popup->base->surface->mapped) {
wl_resource_post_error(popup->resource,
XDG_POPUP_ERROR_INVALID_GRAB,
"xdg_popup is already mapped");
@ -472,8 +465,6 @@ void reset_xdg_popup(struct wlr_xdg_popup *popup) {
popup->seat = NULL;
}
popup->sent_initial_configure = false;
}
void destroy_xdg_popup(struct wlr_xdg_popup *popup) {

View file

@ -309,16 +309,12 @@ static void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
assert(0 && "not reached");
return;
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
if (surface->toplevel != NULL) {
handle_xdg_toplevel_committed(surface->toplevel);
} else {
if (surface->toplevel == NULL) {
return;
}
break;
case WLR_XDG_SURFACE_ROLE_POPUP:
if (surface->popup != NULL) {
handle_xdg_popup_committed(surface->popup);
} else {
if (surface->popup == NULL) {
return;
}
break;

View file

@ -131,24 +131,6 @@ void handle_xdg_toplevel_client_commit(struct wlr_xdg_toplevel *toplevel) {
}
}
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) {
if (toplevel->base->initial_commit) {
// On the initial commit, send a configure request to tell the client it
// is added
wlr_xdg_surface_schedule_configure(toplevel->base);
if (toplevel->base->client->shell->version >=
XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) {
// The first configure event must carry WM capabilities
wlr_xdg_toplevel_set_wm_capabilities(toplevel,
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE);
}
}
}
static const struct xdg_toplevel_interface xdg_toplevel_implementation;
struct wlr_xdg_toplevel *wlr_xdg_toplevel_from_resource(
@ -506,6 +488,16 @@ void create_xdg_toplevel(struct wlr_xdg_surface *surface,
set_xdg_surface_role_object(surface, surface->toplevel->resource);
if (surface->client->shell->version >= XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) {
// The first configure event must carry WM capabilities
surface->toplevel->scheduled.wm_capabilities =
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN |
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE;
surface->toplevel->scheduled.fields |= WLR_XDG_TOPLEVEL_CONFIGURE_WM_CAPABILITIES;
}
wl_signal_emit_mutable(&surface->client->shell->events.new_toplevel, surface->toplevel);
return;