[PATCH xserver v2 3/5] xwayland: refactor into xwl_window_post_damage()
Pekka Paalanen
ppaalanen at gmail.com
Fri Dec 9 12:24:14 UTC 2016
From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
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 at collabora.co.uk>
Reviewed-by: Olivier Fourdan <ofourdan at redhat.com>
---
hw/xwayland/xwayland.c | 56 +++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 9e1ecf8..c2ac4b3 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);
}
}
--
2.7.3
More information about the xorg-devel
mailing list