diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-09-17 18:18:47 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-09-17 18:18:47 -0400 |
commit | 216e659080d5dae8743dde2b2242b395309efb59 (patch) | |
tree | b7f7e131f5277ed8346b48ddf5b883ca0c0346cb | |
parent | 446fccc722fbf05af9a37344337a9cb634ffdb32 (diff) |
User surface user data instead of find_window
-rw-r--r-- | src/wayland.c | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/src/wayland.c b/src/wayland.c index e15fd17d..8f75ed72 100644 --- a/src/wayland.c +++ b/src/wayland.c @@ -48,7 +48,6 @@ struct xwl_window { struct wl_visual *visual; int x, y; WindowPtr window; - struct wl_list link; }; struct xwl_context { @@ -65,8 +64,6 @@ struct xwl_context { RealizeWindowProcPtr RealizeWindow; UnrealizeWindowProcPtr UnrealizeWindow; - - struct wl_list window_list; }; struct xwl_output { @@ -239,24 +236,6 @@ block_handler(pointer data, struct timeval **tv, pointer read_mask) WL_DISPLAY_WRITABLE); } -static struct xwl_window * -find_window(struct xwl_context *context, struct wl_surface *surface) -{ - struct xwl_window *window; - - window = container_of(context->window_list.next, struct xwl_window, link); - while (&window->link != &context->window_list) { - - if (window->surface == surface) - return window; - - window = container_of(window->link.next, - struct xwl_window, link); - } - - return NULL; -} - static void handle_motion(void *data, struct wl_input_device *input_device, int32_t x, int32_t y, int32_t sx, int32_t sy) @@ -350,7 +329,7 @@ handle_pointer_focus(void *data, { struct xwl_input_device *d = data; - d->focus_window = find_window(d->context, surface); + d->focus_window = wl_surface_get_user_data(surface); if (d->focus_window) SetDeviceRedirectWindow(d->pointer, d->focus_window->window); @@ -697,6 +676,7 @@ wayland_realize_window (WindowPtr pWin) ErrorF("wl_display_create_surface failed\n"); return ret; } + wl_surface_set_user_data(priv->surface, priv); priv->window = pWin; priv->visual = wl_display_get_rgb_visual(context->display); priv->x = pWin->drawable.x; @@ -720,7 +700,7 @@ wayland_realize_window (WindowPtr pWin) /* FIXME: Set private in CreateWindow, probably. */ dixSetPrivate(&pWin->devPrivates, wayland_window_private_key, priv); - wl_list_insert(&context->window_list, &priv->link); + ErrorF("realize %p, name %u\n", pWin, name); return ret; } @@ -735,6 +715,8 @@ 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; @@ -745,7 +727,6 @@ wayland_unrealize_window (WindowPtr pWin) priv = dixLookupPrivate(&pWin->devPrivates, wayland_window_private_key); if (priv) { wl_surface_destroy(priv->surface); - wl_list_remove(&priv->link); free(priv); dixSetPrivate(&pWin->devPrivates, wayland_window_private_key, NULL); } @@ -785,7 +766,6 @@ wayland_pre_init(ScrnInfoPtr pScrn) memset(context, 0, sizeof *context); context->rootless = 1; context->pScrn = pScrn; - wl_list_init(&context->window_list); context->display = wl_display_create(socket_name, sizeof socket_name); if (context->display == NULL) { ErrorF("wl_display_create failed\n"); |