xwayland: refactor into xwl_window_post_damage()
Refactor xwl_screen_post_damage() and split the window specific code into a new function xwl_window_post_damage(). This is a pure refactoring, there are no behavioral changes. An assert is added to xwl_window_post_damage() to ensure frame callbacks are not leaked if a future patch changes the call. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
This commit is contained in:
parent
8e3f9ce6c0
commit
f7b8560f23
|
@ -458,14 +458,46 @@ static const struct wl_callback_listener frame_listener = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xwl_screen_post_damage(struct xwl_screen *xwl_screen)
|
xwl_window_post_damage(struct xwl_window *xwl_window)
|
||||||
{
|
{
|
||||||
struct xwl_window *xwl_window, *next_xwl_window;
|
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
|
||||||
RegionPtr region;
|
RegionPtr region;
|
||||||
BoxPtr box;
|
BoxPtr box;
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
|
|
||||||
|
assert(!xwl_window->frame_callback);
|
||||||
|
|
||||||
|
region = DamageRegion(xwl_window->damage);
|
||||||
|
pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
|
||||||
|
|
||||||
|
#if GLAMOR_HAS_GBM
|
||||||
|
if (xwl_screen->glamor)
|
||||||
|
buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
|
||||||
|
#endif
|
||||||
|
if (!xwl_screen->glamor)
|
||||||
|
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
|
||||||
|
|
||||||
|
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
|
||||||
|
|
||||||
|
box = RegionExtents(region);
|
||||||
|
wl_surface_damage(xwl_window->surface, box->x1, box->y1,
|
||||||
|
box->x2 - box->x1, box->y2 - box->y1);
|
||||||
|
|
||||||
|
xwl_window->frame_callback = wl_surface_frame(xwl_window->surface);
|
||||||
|
wl_callback_add_listener(xwl_window->frame_callback, &frame_listener, xwl_window);
|
||||||
|
|
||||||
|
wl_surface_commit(xwl_window->surface);
|
||||||
|
DamageEmpty(xwl_window->damage);
|
||||||
|
|
||||||
|
xorg_list_del(&xwl_window->link_damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xwl_screen_post_damage(struct xwl_screen *xwl_screen)
|
||||||
|
{
|
||||||
|
struct xwl_window *xwl_window, *next_xwl_window;
|
||||||
|
|
||||||
xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
|
xorg_list_for_each_entry_safe(xwl_window, next_xwl_window,
|
||||||
&xwl_screen->damage_window_list, link_damage) {
|
&xwl_screen->damage_window_list, link_damage) {
|
||||||
/* If we're waiting on a frame callback from the server,
|
/* If we're waiting on a frame callback from the server,
|
||||||
|
@ -473,29 +505,7 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
|
||||||
if (xwl_window->frame_callback)
|
if (xwl_window->frame_callback)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
region = DamageRegion(xwl_window->damage);
|
xwl_window_post_damage(xwl_window);
|
||||||
pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
|
|
||||||
|
|
||||||
#if GLAMOR_HAS_GBM
|
|
||||||
if (xwl_screen->glamor)
|
|
||||||
buffer = xwl_glamor_pixmap_get_wl_buffer(pixmap);
|
|
||||||
#endif
|
|
||||||
if (!xwl_screen->glamor)
|
|
||||||
buffer = xwl_shm_pixmap_get_wl_buffer(pixmap);
|
|
||||||
|
|
||||||
wl_surface_attach(xwl_window->surface, buffer, 0, 0);
|
|
||||||
|
|
||||||
box = RegionExtents(region);
|
|
||||||
wl_surface_damage(xwl_window->surface, box->x1, box->y1,
|
|
||||||
box->x2 - box->x1, box->y2 - box->y1);
|
|
||||||
|
|
||||||
xwl_window->frame_callback = wl_surface_frame(xwl_window->surface);
|
|
||||||
wl_callback_add_listener(xwl_window->frame_callback, &frame_listener, xwl_window);
|
|
||||||
|
|
||||||
wl_surface_commit(xwl_window->surface);
|
|
||||||
DamageEmpty(xwl_window->damage);
|
|
||||||
|
|
||||||
xorg_list_del(&xwl_window->link_damage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue