diff options
author | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
commit | 2553bdd7c359cd87525d367761c86932cec5adff (patch) | |
tree | ae71245933c98474a699d3e392de5820879b2018 /xorg-server/miext/rootless/rootlessWindow.c | |
parent | e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78 (diff) | |
parent | 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 (diff) | |
download | vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.gz vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.bz2 vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.zip |
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/miext/rootless/rootlessWindow.c')
-rw-r--r-- | xorg-server/miext/rootless/rootlessWindow.c | 278 |
1 files changed, 201 insertions, 77 deletions
diff --git a/xorg-server/miext/rootless/rootlessWindow.c b/xorg-server/miext/rootless/rootlessWindow.c index 681fefef3..73eb6d5c1 100644 --- a/xorg-server/miext/rootless/rootlessWindow.c +++ b/xorg-server/miext/rootless/rootlessWindow.c @@ -63,9 +63,11 @@ extern int darwinMainScreenX, darwinMainScreenY; #define SCREEN_TO_GLOBAL_Y 0 #endif +#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x))) + #define DEFINE_ATOM_HELPER(func,atom_name) \ static Atom func (void) { \ - static unsigned int generation; \ + static unsigned int generation = 0; \ static Atom atom; \ if (generation != serverGeneration) { \ generation = serverGeneration; \ @@ -82,13 +84,6 @@ static Bool no_configure_window; static Bool windows_hidden; // TODO - abstract xp functions -static const int normal_window_levels[AppleWMNumWindowLevels+1] = { - 0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29, -}; -static const int rooted_window_levels[AppleWMNumWindowLevels+1] = { - 202, 203, 204, 205, 201, 200 -}; - static inline int configure_window (xp_window_id id, unsigned int mask, const xp_window_changes *values) @@ -120,12 +115,10 @@ rootlessHasRoot (ScreenPtr pScreen) #ifdef __APPLE__ void -RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state) +RootlessNativeWindowStateChanged (WindowPtr pWin, unsigned int state) { - WindowPtr pWin; RootlessWindowRec *winRec; - pWin = xprGetXWindow (id); if (pWin == NULL) return; winRec = WINREC (pWin); @@ -133,43 +126,42 @@ RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state) winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0); winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0); - // pWin->rootlessUnhittable = winRec->is_offscreen; + pWin->rootlessUnhittable = winRec->is_offscreen; } -void -RootlessNativeWindowMoved (WindowPtr pWin) -{ - xp_box bounds; - int sx, sy; - XID vlist[2]; - Mask mask; - ClientPtr client; - RootlessWindowRec *winRec = WINREC(pWin); - - if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return; - - sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX; - sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY; - - /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */ - - vlist[0] = (INT16) bounds.x1 - sx; - vlist[1] = (INT16) bounds.y1 - sy; - mask = CWX | CWY; - - /* pretend we're the owner of the window! */ +void RootlessNativeWindowMoved (WindowPtr pWin) { + xp_box bounds; + int sx, sy, err; + XID vlist[2]; + Mask mask; + ClientPtr pClient; + RootlessWindowRec *winRec; + + winRec = WINREC(pWin); + + if (xp_get_window_bounds (MAKE_WINDOW_ID(winRec->wid), &bounds) != Success) return; + + sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX; + sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY; + + /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */ + vlist[0] = (INT16) bounds.x1 - sx; + vlist[1] = (INT16) bounds.y1 - sy; + mask = CWX | CWY; + + /* pretend we're the owner of the window! */ err = dixLookupClient(&pClient, pWin->drawable.id, NullClient, DixUnknownAccess); if(err != Success) { ErrorF("RootlessNativeWindowMoved(): Failed to lookup window: 0x%x\n", (unsigned int)pWin->drawable.id); return; } - - /* Don't want to do anything to the physical window (avoids + + /* Don't want to do anything to the physical window (avoids notification-response feedback loops) */ - - no_configure_window = TRUE; - ConfigureWindow (pWin, mask, vlist, client); - no_configure_window = FALSE; + + no_configure_window = TRUE; + ConfigureWindow (pWin, mask, vlist, pClient); + no_configure_window = FALSE; } /* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */ @@ -273,13 +265,18 @@ RootlessDestroyWindow(WindowPtr pWin) } -#ifdef SHAPE static Bool RootlessGetShape(WindowPtr pWin, RegionPtr pShape) { ScreenPtr pScreen = pWin->drawable.pScreen; + /* + * Avoid a warning. + * REGION_NULL and the other macros don't actually seem to use pScreen. + */ + (void)pScreen; + if (wBoundingShape(pWin) == NULL) return FALSE; @@ -353,7 +350,6 @@ RootlessSetShape(WindowPtr pWin) RootlessReshapeFrame(pWin); } -#endif // SHAPE /* Disallow ParentRelative background on top-level windows @@ -457,7 +453,7 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec) Bool RootlessColormapCallback (void *data, int first_color, int n_colors, uint32_t *colors) { - return RootlessResolveColormap (data, first_color, n_colors, colors); + return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch); } /* @@ -471,9 +467,7 @@ RootlessEnsureFrame(WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; RootlessWindowRec *winRec; -#ifdef SHAPE RegionRec shape; -#endif RegionPtr pShape = NULL; if (WINREC(pWin) != NULL) @@ -499,11 +493,9 @@ RootlessEnsureFrame(WindowPtr pWin) SETWINREC(pWin, winRec); -#ifdef SHAPE // Set the frame's shape if the window is shaped if (RootlessGetShape(pWin, &shape)) pShape = &shape; -#endif RL_DEBUG_MSG("creating frame "); @@ -521,10 +513,8 @@ RootlessEnsureFrame(WindowPtr pWin) if (pWin->drawable.depth == 8) RootlessFlushWindowColormap(pWin); -#ifdef SHAPE if (pShape != NULL) REGION_UNINIT(pScreen, &shape); -#endif return winRec; } @@ -642,7 +632,7 @@ RootlessReorderWindow(WindowPtr pWin) { RootlessWindowRec *winRec = WINREC(pWin); - if (winRec != NULL && !winRec->is_reorder_pending) { + if (pWin->realized && winRec != NULL && !winRec->is_reorder_pending && !windows_hidden) { WindowPtr newPrevW; RootlessWindowRec *newPrev; RootlessFrameID newPrevID; @@ -1346,34 +1336,55 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y, RegionRec saveRoot; RL_DEBUG_MSG("resizewindow start (win 0x%x) ", pWin); + + if(pWin->parent) { + if (winRec) { + oldBW = winRec->borderWidth; + oldX = winRec->x; + oldY = winRec->y; + oldW = winRec->width; + oldH = winRec->height; - if (winRec) { - oldBW = winRec->borderWidth; - oldX = winRec->x; - oldY = winRec->y; - oldW = winRec->width; - oldH = winRec->height; - - newBW = oldBW; - newX = x; - newY = y; - newW = w + 2*newBW; - newH = h + 2*newBW; - - resize_after = StartFrameResize(pWin, TRUE, - oldX, oldY, oldW, oldH, oldBW, - newX, newY, newW, newH, newBW); - } + newBW = oldBW; + newX = x; + newY = y; + newW = w + 2*newBW; + newH = h + 2*newBW; - HUGE_ROOT(pWin); - SCREEN_UNWRAP(pScreen, ResizeWindow); - pScreen->ResizeWindow(pWin, x, y, w, h, pSib); - SCREEN_WRAP(pScreen, ResizeWindow); - NORMAL_ROOT(pWin); + resize_after = StartFrameResize(pWin, TRUE, + oldX, oldY, oldW, oldH, oldBW, + newX, newY, newW, newH, newBW); + } - if (winRec) { - FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW, - newX, newY, newW, newH, newBW, resize_after); + HUGE_ROOT(pWin); + SCREEN_UNWRAP(pScreen, ResizeWindow); + pScreen->ResizeWindow(pWin, x, y, w, h, pSib); + SCREEN_WRAP(pScreen, ResizeWindow); + NORMAL_ROOT(pWin); + + if (winRec) { + FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW, + newX, newY, newW, newH, newBW, resize_after); + } + } else { + /* Special case for resizing the root window */ + BoxRec box; + + pWin->drawable.x = x; + pWin->drawable.y = y; + pWin->drawable.width = w; + pWin->drawable.height = h; + + box.x1 = x; box.y1 = y; + box.x2 = x + w; box.y2 = y + h; + REGION_UNINIT(pScreen, &pWin->winSize); + REGION_INIT(pScreen, &pWin->winSize, &box, 1); + REGION_COPY(pScreen, &pWin->borderSize, &pWin->winSize); + REGION_COPY(pScreen, &pWin->clipList, &pWin->winSize); + REGION_COPY(pScreen, &pWin->borderClip, &pWin->winSize); + + miSendExposures(pWin, &pWin->borderClip, + pWin->drawable.x, pWin->drawable.y); } RL_DEBUG_MSG("resizewindow end\n"); @@ -1434,6 +1445,10 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) pTopWin = TopLevelParent(pWin); assert(pTopWin != pWin); + + pWin->rootlessUnhittable = FALSE; + + DeleteProperty (serverClient, pWin, xa_native_window_id ()); if (WINREC(pTopWin) != NULL) { /* We're screwed. */ @@ -1490,7 +1505,7 @@ RootlessFlushWindowColormap (WindowPtr pWin) wc.colormap = RootlessColormapCallback; wc.colormap_data = pWin->drawable.pScreen; - configure_window (winRec->wid, XP_COLORMAP, &wc); + configure_window (MAKE_WINDOW_ID(winRec->wid), XP_COLORMAP, &wc); } /* @@ -1556,7 +1571,10 @@ RootlessOrderAllWindows (void) { int i; WindowPtr pWin; - + + if (windows_hidden) + return; + RL_DEBUG_MSG("RootlessOrderAllWindows() "); for (i = 0; i < screenInfo.numScreens; i++) { if (screenInfo.screens[i] == NULL) continue; @@ -1571,3 +1589,109 @@ RootlessOrderAllWindows (void) } RL_DEBUG_MSG("RootlessOrderAllWindows() done"); } + +void +RootlessEnableRoot (ScreenPtr pScreen) +{ + WindowPtr pRoot; + pRoot = WindowTable[pScreen->myNum]; + + RootlessEnsureFrame (pRoot); + (*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE); + RootlessReorderWindow (pRoot); +} + +void +RootlessDisableRoot (ScreenPtr pScreen) +{ + WindowPtr pRoot; + RootlessWindowRec *winRec; + + pRoot = WindowTable[pScreen->myNum]; + winRec = WINREC (pRoot); + + if (NULL == winRec) + return; + + RootlessDestroyFrame (pRoot, winRec); + /* + * gstaplin: I fixed the usage of this DeleteProperty so that it would compile. + * QUESTION: Where is this xa_native_window_id set? + */ + DeleteProperty (serverClient, pRoot, xa_native_window_id ()); +} + +void +RootlessHideAllWindows (void) +{ + int i; + ScreenPtr pScreen; + WindowPtr pWin; + RootlessWindowRec *winRec; + xp_window_changes wc; + + if (windows_hidden) + return; + + windows_hidden = TRUE; + + for (i = 0; i < screenInfo.numScreens; i++) + { + pScreen = screenInfo.screens[i]; + pWin = WindowTable[i]; + if (pScreen == NULL || pWin == NULL) + continue; + + for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) + { + if (!pWin->realized) + continue; + + RootlessStopDrawing (pWin, FALSE); + + winRec = WINREC (pWin); + if (winRec != NULL) + { + wc.stack_mode = XP_UNMAPPED; + wc.sibling = 0; + configure_window (MAKE_WINDOW_ID(winRec->wid), XP_STACKING, &wc); + } + } + } +} + +void +RootlessShowAllWindows (void) +{ + int i; + ScreenPtr pScreen; + WindowPtr pWin; + RootlessWindowRec *winRec; + + if (!windows_hidden) + return; + + windows_hidden = FALSE; + + for (i = 0; i < screenInfo.numScreens; i++) + { + pScreen = screenInfo.screens[i]; + pWin = WindowTable[i]; + if (pScreen == NULL || pWin == NULL) + continue; + + for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) + { + if (!pWin->realized) + continue; + + winRec = RootlessEnsureFrame (pWin); + if (winRec == NULL) + continue; + + RootlessReorderWindow (pWin); + } + + RootlessScreenExpose (pScreen); + } +} |