diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-09-22 21:19:27 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-09-22 21:19:27 -0400 |
commit | c05910e27035d7a006c557049f0dd3fb24d122e8 (patch) | |
tree | 6e369680359be5f7c5cbe26f830d8ad4b6dc2731 | |
parent | 19919903ae471bdb3b2740179717f408a325921b (diff) |
Make non-rootless work again
-rw-r--r-- | src/i830.h | 4 | ||||
-rw-r--r-- | src/i830_driver.c | 4 | ||||
-rw-r--r-- | src/wayland.c | 70 |
3 files changed, 40 insertions, 38 deletions
@@ -623,9 +623,9 @@ typedef struct _I830Rec { } I830Rec; #ifdef WAYLAND -extern Bool wayland_pre_init(ScrnInfoPtr pScrn); +extern Bool wayland_pre_init(ScrnInfoPtr pScrn, Bool rootless); +extern void wayland_init(ScrnInfoPtr pScrn); extern void wayland_post_damage(I830Ptr pI830); -extern void wayland_init_rootless(ScrnInfoPtr pScrn); #endif #define I830PTR(p) ((I830Ptr)((p)->driverPrivate)) diff --git a/src/i830_driver.c b/src/i830_driver.c index f6dd9209..883d4c02 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -614,7 +614,7 @@ i830CreateScreenResources(ScreenPtr pScreen) i830_uxa_create_screen_resources(pScreen); - wayland_init_rootless (pScrn); + wayland_init(pScrn); return TRUE; } @@ -1591,7 +1591,7 @@ I830PreInit(ScrnInfoPtr pScrn, int flags) i830_check_dri_option(pScrn); if (xorgWayland) { - if (!wayland_pre_init(pScrn)) + if (!wayland_pre_init(pScrn, xorgRootless)) return FALSE; } else if (pI830->use_drm_mode) { if (!I830DrmModeInit(pScrn)) diff --git a/src/wayland.c b/src/wayland.c index c5406887..0205d5e7 100644 --- a/src/wayland.c +++ b/src/wayland.c @@ -64,13 +64,14 @@ struct xwl_context { struct wl_compositor *compositor; struct wl_surface *surface; uint32_t mask; - int rootless; + Bool rootless; PixmapPtr ref_pixmaps[16]; int ref_index; /* FIXME: Hack. */ int32_t width, height; + int32_t root_x, root_y; CreateWindowProcPtr CreateWindow; RealizeWindowProcPtr RealizeWindow; @@ -256,6 +257,7 @@ handle_motion(void *data, struct wl_input_device *input_device, ScreenPtr pScreen; struct xwl_window *window; struct xwl_input_device *d = data; + struct xwl_context *context = d->context; int32_t dx, dy; if (d->focus_window) { @@ -273,9 +275,23 @@ handle_motion(void *data, struct wl_input_device *input_device, window = d->focus_window; pScreen = window->window->drawable.pScreen; + (*pScreen->MoveWindow)(window->window, d->grab_x + x, d->grab_y + y, NullWindow, VTMove); + + /* We don't get the pScreen->MoveWindow callback for the root + * window. Special case it here so we can still move it. */ + if (window->window->parent == NULL) { + context->root_x = d->grab_x + x; + context->root_y = d->grab_y + y; + wl_surface_map(window->surface, + d->grab_x + x, + d->grab_y + y, + window->window->drawable.width, + window->window->drawable.height); + wl_compositor_commit(window->context->compositor, 16); + } } static void @@ -284,11 +300,17 @@ handle_button(void *data, struct wl_input_device *input_device, int32_t x, int32_t y, int32_t sx, int32_t sy) { struct xwl_input_device *d = data; + struct xwl_context *context = d->context; int index; if (button == BTN_LEFT && state == 1 && d->alt) { - d->grab_x = d->focus_window->window->drawable.x - x; - d->grab_y = d->focus_window->window->drawable.y - y; + if (d->focus_window->window->parent == NULL) { + d->grab_x = context->root_x - x; + d->grab_y = context->root_y - y; + } else { + d->grab_x = d->focus_window->window->drawable.x - x; + d->grab_y = d->focus_window->window->drawable.y - y; + } d->grab = TRUE; return; } else if (button == BTN_LEFT && state == 0 && d->grab) { @@ -353,8 +375,6 @@ handle_keyboard_focus(void *data, struct wl_array *keys) { struct xwl_input_device *d = data; - struct xwl_window *window; - Window id; uint32_t *k, *end; end = (uint32_t *) ((char *) keys->data + keys->size); @@ -405,28 +425,6 @@ static Bool crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int x, int y) { - ScrnInfoPtr pScrn = crtc->scrn; - I830Ptr pI830 = I830PTR(pScrn); - struct xwl_context *context = pI830->wayland_data; - uint32_t name; - struct wl_visual *visual; - - if (context->rootless) - return TRUE; - - visual = wl_display_get_rgb_visual(context->display); - - if (dri_bo_flink(pI830->front_buffer->bo, &name) != 0) - /* failed to name buffer */ - return FALSE; - - wl_surface_attach(context->surface, name, - mode->HDisplay, mode->VDisplay, - pScrn->displayWidth * pI830->cpp, visual); - wl_surface_map(context->surface, 0, 0, - mode->HDisplay, mode->VDisplay); - wl_compositor_commit(context->compositor, 16); - return TRUE; } @@ -705,11 +703,10 @@ wayland_create_window(WindowPtr pWin) context->CreateWindow = pScreen->CreateWindow; pScreen->CreateWindow = wayland_create_window; - if (pWin->parent != NULL) + if (!context->rootless || pWin->parent != NULL) return ret; len = snprintf(buffer, sizeof buffer, "_NET_WM_CM_S%d", pScreen->myNum); - ErrorF("selection name: %s (%d)\n", buffer, len); name = MakeAtom(buffer, len, TRUE); rc = AddSelection(&pSel, name, serverClient); if (rc != Success) @@ -742,8 +739,13 @@ wayland_realize_window(WindowPtr pWin) context->RealizeWindow = pScreen->RealizeWindow; pScreen->RealizeWindow = wayland_realize_window; - if (pWin->redirectDraw != RedirectDrawManual) - return ret; + if (context->rootless) { + if (pWin->redirectDraw != RedirectDrawManual) + return ret; + } else { + if (pWin->parent) + return ret; + } window = malloc(sizeof *window); window->context = context; @@ -851,7 +853,7 @@ wayland_move_window(WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind) } void -wayland_init_rootless(ScrnInfoPtr pScrn) +wayland_init(ScrnInfoPtr pScrn) { ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex]; I830Ptr pI830 = I830PTR(pScrn); @@ -874,7 +876,7 @@ wayland_init_rootless(ScrnInfoPtr pScrn) } Bool -wayland_pre_init(ScrnInfoPtr pScrn) +wayland_pre_init(ScrnInfoPtr pScrn, Bool rootless) { struct xwl_context *context; I830Ptr pI830 = I830PTR(pScrn); @@ -889,8 +891,8 @@ wayland_pre_init(ScrnInfoPtr pScrn) } memset(context, 0, sizeof *context); - context->rootless = 1; context->pScrn = pScrn; + context->rootless = rootless; context->display = wl_display_create(socket_name, sizeof socket_name); if (context->display == NULL) { ErrorF("wl_display_create failed\n"); |