xwayland: Move attach buffer out of post damage

For libdecor, we will have to attach a new buffer and commit from two
different handlers (libdecor configure and commit).

Having xwl_window_attach_buffer() separate from xwl_window_post_damage()
is to allow for that.

This commit should not introduce any functional change.

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 16:39:03 +02:00
parent 4bb1f976d5
commit 8bbd908d1d

View File

@ -57,6 +57,8 @@ static DevPrivateKeyRec xwl_window_private_key;
static DevPrivateKeyRec xwl_damage_private_key;
static const char *xwl_surface_tag = "xwl-surface";
static Bool xwl_window_attach_buffer(struct xwl_window *);
struct xwl_window *
xwl_window_get(WindowPtr window)
{
@ -1312,8 +1314,8 @@ xwl_destroy_window(WindowPtr window)
return ret;
}
void
xwl_window_post_damage(struct xwl_window *xwl_window)
static Bool
xwl_window_attach_buffer(struct xwl_window *xwl_window)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
RegionPtr region;
@ -1322,8 +1324,6 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
PixmapPtr pixmap;
int i;
assert(!xwl_window->frame_callback);
region = DamageRegion(window_get_damage(xwl_window->window));
pixmap = xwl_window_buffers_get_pixmap(xwl_window, region);
@ -1336,14 +1336,14 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
if (!buffer) {
ErrorF("Error getting buffer\n");
return;
return FALSE;
}
#ifdef XWL_HAS_GLAMOR
if (xwl_screen->glamor) {
if (!xwl_glamor_post_damage(xwl_window, pixmap, region)) {
ErrorF("glamor: Failed to post damage\n");
return;
return FALSE;
}
}
#endif
@ -1370,6 +1370,17 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
}
}
return TRUE;
}
void
xwl_window_post_damage(struct xwl_window *xwl_window)
{
assert(!xwl_window->frame_callback);
if (!xwl_window_attach_buffer(xwl_window))
return;
xwl_window_create_frame_callback(xwl_window);
DamageEmpty(window_get_damage(xwl_window->window));
}