diff options
author | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-11-24 11:45:25 +0200 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-02-23 13:30:11 -0500 |
commit | f7b8560f23ac5582e2f97dc9f6de32a42e61e520 (patch) | |
tree | 5aeebfae102f5f0b703374b9d202ca829f15663c /hw/xwayland/xwayland.c | |
parent | 8e3f9ce6c06e7605832c55dfd180396f66ec8b66 (diff) |
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>
Diffstat (limited to 'hw/xwayland/xwayland.c')
-rw-r--r-- | hw/xwayland/xwayland.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 9e1ecf8f5..c2ac4b3ff 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -458,44 +458,54 @@ static const struct wl_callback_listener frame_listener = { }; 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; BoxPtr box; struct wl_buffer *buffer; PixmapPtr pixmap; - xorg_list_for_each_entry_safe(xwl_window, next_xwl_window, - &xwl_screen->damage_window_list, link_damage) { - /* If we're waiting on a frame callback from the server, - * don't attach a new buffer. */ - if (xwl_window->frame_callback) - continue; + assert(!xwl_window->frame_callback); - region = DamageRegion(xwl_window->damage); - pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window); + 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); + 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); + if (!xwl_screen->glamor) + buffer = xwl_shm_pixmap_get_wl_buffer(pixmap); - wl_surface_attach(xwl_window->surface, buffer, 0, 0); + 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); + 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); + 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); + wl_surface_commit(xwl_window->surface); + DamageEmpty(xwl_window->damage); - xorg_list_del(&xwl_window->link_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, + &xwl_screen->damage_window_list, link_damage) { + /* If we're waiting on a frame callback from the server, + * don't attach a new buffer. */ + if (xwl_window->frame_callback) + continue; + + xwl_window_post_damage(xwl_window); } } |