diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-09-17 18:39:08 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-09-17 18:39:08 -0400 |
commit | ddf99a13611675ddd499bfd48927e486b2437f87 (patch) | |
tree | a8f4939cae8251fc2984cda38a25591985a9fc99 | |
parent | 216e659080d5dae8743dde2b2242b395309efb59 (diff) |
Don't destroy pixmaps before they get to the compositor
-rw-r--r-- | src/wayland.c | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/wayland.c b/src/wayland.c index 8f75ed72..1f5ff932 100644 --- a/src/wayland.c +++ b/src/wayland.c @@ -59,6 +59,9 @@ struct xwl_context { uint32_t mask; int rootless; + PixmapPtr ref_pixmaps[16]; + int ref_index; + /* FIXME: Hack. */ int32_t width, height; @@ -271,7 +274,7 @@ handle_motion(void *data, struct wl_input_device *input_device, window->y, window->window->drawable.width, window->window->drawable.height); - wl_compositor_commit(d->context->compositor, 0); + wl_compositor_commit(d->context->compositor, 16); } static void @@ -329,7 +332,11 @@ handle_pointer_focus(void *data, { struct xwl_input_device *d = data; - d->focus_window = wl_surface_get_user_data(surface); + if (surface) + d->focus_window = wl_surface_get_user_data(surface); + else + d->focus_window = NULL; + if (d->focus_window) SetDeviceRedirectWindow(d->pointer, d->focus_window->window); @@ -415,7 +422,7 @@ crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, pScrn->displayWidth * pI830->cpp, visual); wl_surface_map(context->surface, 0, 0, mode->HDisplay, mode->VDisplay); - wl_compositor_commit(context->compositor, 0); + wl_compositor_commit(context->compositor, 16); return TRUE; } @@ -588,6 +595,34 @@ create_input_device(struct xwl_context *context, struct wl_object *object) } static void +handle_acknowledge(void *data, + struct wl_compositor *compositor, + uint32_t key, uint32_t frame) +{ + struct xwl_context *context = data; + PixmapPtr pPixmap; + ScreenPtr pScreen; + + if (key < 16) { + pPixmap = context->ref_pixmaps[key]; + pScreen = pPixmap->drawable.pScreen; + (*pScreen->DestroyPixmap)(pPixmap); + } +} + +static void +handle_frame(void *data, + struct wl_compositor *compositor, + uint32_t frame, uint32_t timestamp) +{ +} + +static const struct wl_compositor_listener compositor_listener = { + handle_acknowledge, + handle_frame, +}; + +static void global_handler(struct wl_display *display, struct wl_object *object, void *data) { @@ -595,6 +630,8 @@ global_handler(struct wl_display *display, if (wl_object_implements(object, "compositor", 1)) { context->compositor = (struct wl_compositor *) object; + wl_compositor_add_listener(context->compositor, + &compositor_listener, context); } else if (wl_object_implements(object, "output", 1)) { create_output(context, object); } else if (wl_object_implements(object, "input_device", 1)) { @@ -695,13 +732,14 @@ wayland_realize_window (WindowPtr pWin) priv->x, priv->y, pPixmap->drawable.width, pPixmap->drawable.height); - wl_compositor_commit(context->compositor, 0); + wl_compositor_commit(context->compositor, context->ref_index); + context->ref_pixmaps[context->ref_index] = pPixmap; + context->ref_index = (context->ref_index + 1) & 15; + pPixmap->refcnt++; /* FIXME: Set private in CreateWindow, probably. */ dixSetPrivate(&pWin->devPrivates, wayland_window_private_key, priv); - ErrorF("realize %p, name %u\n", pWin, name); - return ret; } @@ -715,8 +753,6 @@ wayland_unrealize_window (WindowPtr pWin) struct xwl_window *priv; Bool ret = TRUE; - ErrorF("unrealize %p\n", pWin); - pScreen->UnrealizeWindow = context->UnrealizeWindow; if (!(*pScreen->UnrealizeWindow)(pWin)) ret = FALSE; @@ -801,7 +837,7 @@ void wayland_post_damage(I830Ptr pI830) /* FIXME: Need a list of surfaces with damage. */ wl_surface_damage(context->surface, 0, 0, 10, 10); - wl_compositor_commit(context->compositor, 0); + wl_compositor_commit(context->compositor, 16); while (context->mask & WL_DISPLAY_WRITABLE) wl_display_iterate(context->display, |