diff options
Diffstat (limited to 'xorg-server/miext/rootless/rootlessWindow.c')
-rw-r--r-- | xorg-server/miext/rootless/rootlessWindow.c | 284 |
1 files changed, 206 insertions, 78 deletions
diff --git a/xorg-server/miext/rootless/rootlessWindow.c b/xorg-server/miext/rootless/rootlessWindow.c index 0dad44a99..5ce26bd2f 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) @@ -117,12 +112,10 @@ rootlessHasRoot (ScreenPtr pScreen) } 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); @@ -130,39 +123,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! */ - client = LookupClient (pWin->drawable.id, NullClient); - - /* Don't want to do anything to the physical window (avoids +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 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. */ @@ -265,13 +261,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; @@ -345,7 +346,6 @@ RootlessSetShape(WindowPtr pWin) RootlessReshapeFrame(pWin); } -#endif // SHAPE /* Disallow ParentRelative background on top-level windows @@ -449,7 +449,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); } /* @@ -463,9 +463,7 @@ RootlessEnsureFrame(WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; RootlessWindowRec *winRec; -#ifdef SHAPE RegionRec shape; -#endif RegionPtr pShape = NULL; if (WINREC(pWin) != NULL) @@ -491,11 +489,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 "); @@ -513,10 +509,8 @@ RootlessEnsureFrame(WindowPtr pWin) if (pWin->drawable.depth == 8) RootlessFlushWindowColormap(pWin); -#ifdef SHAPE if (pShape != NULL) REGION_UNINIT(pScreen, &shape); -#endif return winRec; } @@ -634,7 +628,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; @@ -1338,34 +1332,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"); @@ -1426,6 +1441,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. */ @@ -1482,7 +1501,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); } /* @@ -1548,7 +1567,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; @@ -1563,3 +1585,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); + } +} |