mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
xdg-surface: fix init state flow
Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3677
This commit is contained in:
parent
016494af1b
commit
0fdbdc36c0
4 changed files with 19 additions and 10 deletions
|
@ -166,7 +166,6 @@ struct wlr_xdg_toplevel_requested {
|
|||
struct wlr_xdg_toplevel {
|
||||
struct wl_resource *resource;
|
||||
struct wlr_xdg_surface *base;
|
||||
bool sent_initial_configure;
|
||||
|
||||
struct wlr_xdg_toplevel *parent;
|
||||
struct wl_listener parent_unmap;
|
||||
|
@ -257,6 +256,9 @@ struct wlr_xdg_surface {
|
|||
|
||||
struct wlr_xdg_surface_state current, pending;
|
||||
|
||||
bool initialized;
|
||||
bool initial_commit;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
struct wl_signal ping_timeout;
|
||||
|
|
|
@ -245,13 +245,12 @@ void handle_xdg_popup_committed(struct wlr_xdg_popup *popup) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!popup->sent_initial_configure) {
|
||||
popup->current = popup->pending;
|
||||
|
||||
if (popup->base->initial_commit && !popup->sent_initial_configure) {
|
||||
wlr_xdg_surface_schedule_configure(popup->base);
|
||||
popup->sent_initial_configure = true;
|
||||
return;
|
||||
}
|
||||
|
||||
popup->current = popup->pending;
|
||||
}
|
||||
|
||||
static const struct xdg_popup_interface xdg_popup_implementation;
|
||||
|
|
|
@ -25,6 +25,7 @@ static void xdg_surface_configure_destroy(
|
|||
|
||||
static void reset_xdg_surface(struct wlr_xdg_surface *surface) {
|
||||
surface->client_mapped = false;
|
||||
surface->initialized = false;
|
||||
surface->configured = false;
|
||||
|
||||
struct wlr_xdg_popup *popup, *popup_tmp;
|
||||
|
@ -166,6 +167,11 @@ uint32_t wlr_xdg_surface_schedule_configure(struct wlr_xdg_surface *surface) {
|
|||
struct wl_display *display = wl_client_get_display(surface->client->client);
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(display);
|
||||
|
||||
if (!surface->initialized) {
|
||||
wlr_log(WLR_ERROR, "A configure is scheduled for an uninitialized xdg_surface %p",
|
||||
surface);
|
||||
}
|
||||
|
||||
if (surface->configure_idle == NULL) {
|
||||
surface->scheduled_serial = wl_display_next_serial(display);
|
||||
surface->configure_idle = wl_event_loop_add_idle(loop,
|
||||
|
@ -270,10 +276,15 @@ static void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
|
|||
return;
|
||||
}
|
||||
|
||||
surface->initial_commit = !surface->initialized;
|
||||
|
||||
if (surface->client_mapped && !wlr_surface_has_buffer(wlr_surface)) {
|
||||
assert(!surface->initial_commit);
|
||||
// This commit has unmapped the surface
|
||||
reset_xdg_surface_role_object(surface);
|
||||
reset_xdg_surface(surface);
|
||||
} else {
|
||||
surface->initialized = true;
|
||||
}
|
||||
|
||||
surface->current = surface->pending;
|
||||
|
|
|
@ -138,11 +138,10 @@ void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel) {
|
|||
|
||||
toplevel->current = toplevel->pending;
|
||||
|
||||
if (!toplevel->sent_initial_configure) {
|
||||
// on the first commit, send a configure request to tell the client it
|
||||
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);
|
||||
toplevel->sent_initial_configure = true;
|
||||
|
||||
if (toplevel->base->client->shell->version >=
|
||||
XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) {
|
||||
|
@ -525,8 +524,6 @@ void reset_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
|
|||
toplevel->requested.fullscreen = false;
|
||||
toplevel->requested.maximized = false;
|
||||
toplevel->requested.minimized = false;
|
||||
|
||||
toplevel->sent_initial_configure = false;
|
||||
}
|
||||
|
||||
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
|
||||
|
|
Loading…
Reference in a new issue