From 2d50ea8013e7c1639d570e227b53b037fb567565 Mon Sep 17 00:00:00 2001 From: Ben Byer Date: Sat, 3 Nov 2007 05:34:19 -0700 Subject: [PATCH] Initial support for Spaces -- if you use Expose to drag an X11 window to another Space, it will work correctly (as opposed to just leaving a ghost window). We accomplish this by listening for the notification from Xplugin that our window has been moved, and then we ask X11 to move the window to the new location. --- hw/darwin/quartz/quartz.c | 13 ++++++++++--- hw/darwin/quartz/xpr/xprFrame.c | 5 +++-- hw/darwin/quartz/xpr/xprScreen.c | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c index 8670e57f9..a24aeb1b4 100644 --- a/hw/darwin/quartz/quartz.c +++ b/hw/darwin/quartz/quartz.c @@ -400,9 +400,16 @@ void DarwinModeProcessEvent( break; case kXDarwinWindowState: - case kXDarwinWindowMoved: - // FIXME: Not implemented yet - break; + ErrorF("kXDarwinWindowState\n"); + break; + case kXDarwinWindowMoved: { + WindowPtr pWin = (WindowPtr)xe->u.clientMessage.u.l.longs0; + short x = xe->u.clientMessage.u.l.longs1, + y = xe->u.clientMessage.u.l.longs2; + ErrorF("kXDarwinWindowMoved(%p, %hd, %hd)\n", pWin, x, y); + RootlessMoveWindow(pWin, x, y, pWin->nextSib, VTMove); + } + break; default: ErrorF("Unknown application defined event type %d.\n", diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c index 0e3b200e7..53fbb31f9 100644 --- a/hw/darwin/quartz/xpr/xprFrame.c +++ b/hw/darwin/quartz/xpr/xprFrame.c @@ -68,6 +68,7 @@ static inline xp_error xprConfigureWindow(xp_window_id id, unsigned int mask, const xp_window_changes *values) { + // ErrorF("xprConfigureWindow()\n"); if (!no_configure_window) return xp_configure_window(id, mask, values); else @@ -185,7 +186,7 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY) wc.x = newX; wc.y = newY; - + // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY); xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc); } @@ -411,7 +412,7 @@ xprInit(ScreenPtr pScreen) * Given the id of a physical window, try to find the top-level (or root) * X window that it represents. */ -static WindowPtr +WindowPtr xprGetXWindow(xp_window_id wid) { RootlessWindowRec *winRec; diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c index 92886fcd8..9284d5d14 100644 --- a/hw/darwin/quartz/xpr/xprScreen.c +++ b/hw/darwin/quartz/xpr/xprScreen.c @@ -61,10 +61,12 @@ eventHandler(unsigned int type, const void *arg, switch (type) { case XP_EVENT_DISPLAY_CHANGED: + // ErrorF("XP_EVENT_DISPLAY_MOVED\n"); QuartzMessageServerThread(kXDarwinDisplayChanged, 0); break; case XP_EVENT_WINDOW_STATE_CHANGED: + // ErrorF("XP_EVENT_WINDOW_STATE_CHANGED\n"); if (arg_size >= sizeof(xp_window_state_event)) { const xp_window_state_event *ws_arg = arg; @@ -75,16 +77,24 @@ eventHandler(unsigned int type, const void *arg, break; case XP_EVENT_WINDOW_MOVED: + // ErrorF("XP_EVENT_WINDOW_MOVED\n"); if (arg_size == sizeof(xp_window_id)) { xp_window_id id = * (xp_window_id *) arg; - - QuartzMessageServerThread(kXDarwinWindowMoved, 1, id); + WindowPtr pWin = xprGetXWindow(id); + BoxRec box; + xp_error retval = xp_get_window_bounds(id, &box); + if (retval != Success) { + ErrorF("Unable to find new bounds for window\n"); + break; + } + QuartzMessageServerThread(kXDarwinWindowMoved, 3, pWin, box.x1, box.y1); } break; case XP_EVENT_SURFACE_DESTROYED: case XP_EVENT_SURFACE_CHANGED: + // ErrorF("XP_EVENT_SURFACE_MOVED\n"); if (arg_size == sizeof(xp_surface_id)) { int kind;