xwayland: attach new buffer from libdecor handlers

The configure handler in libdecor is triggered any time a new
configuration is received.

According to the documentation from libdecor, an application should
respond to that event by creating a suitable libdecor_state, and apply
it using libdecor_frame_commit().

So we ought to attach a new buffer matching the new size and commit
the Wayland surface.

The actual content of the window does not need to be explicitly
repainted, that occurs through the call to SetRootClip():

  xwl_output_set_mode_fixed()
  -> update_screen_size()
     -> SetRootClip()
        -> miHandleValidateExposures()
           -> miWindowExposures()
              -> miPaintWindow()

This fixes an issue with mutter where maximizing a window and then
switching to another window would sometimes resize the Xwayland window
back to its pre-maximized size, or with Weston where the Xwayland window
would initially show up black until the pointer moves to the window.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
This commit is contained in:
Olivier Fourdan 2023-07-24 17:03:56 +02:00
parent e37539e1e2
commit 6d00c2bc10

View File

@ -629,6 +629,9 @@ xwl_window_libdecor_resize(struct xwl_window *xwl_window, int width, int height)
mode = xwl_output_find_mode(xwl_output, width, height); mode = xwl_output_find_mode(xwl_output, width, height);
xwl_output_set_mode_fixed(xwl_output, mode); xwl_output_set_mode_fixed(xwl_output, mode);
xwl_window_attach_buffer(xwl_window);
wl_surface_commit(xwl_window->surface);
} }
static void static void
@ -652,8 +655,6 @@ handle_libdecor_configure(struct libdecor_frame *frame,
state = libdecor_state_new(xwl_screen->width, xwl_screen->height); state = libdecor_state_new(xwl_screen->width, xwl_screen->height);
libdecor_frame_commit(frame, state, configuration); libdecor_frame_commit(frame, state, configuration);
libdecor_state_free(state); libdecor_state_free(state);
wl_surface_commit(xwl_window->surface);
} }
static void static void