void
winMWExtWMUpdateWindowDecoration(win32RootlessWindowPtr pRLWinPriv,
                                 winScreenInfoPtr pScreenInfo)
{
    Bool fDecorate = FALSE;
    DWORD dwExStyle = 0;
    DWORD dwStyle = 0;
    WINDOWPLACEMENT wndPlace;
    UINT showCmd = 0;

    wndPlace.length = sizeof(WINDOWPLACEMENT);

    /* Get current window placement */
    GetWindowPlacement(pRLWinPriv->hWnd, &wndPlace);

    if (winIsInternalWMRunning(pScreenInfo)) {
        if (!pRLWinPriv->pFrame->win->overrideRedirect)
            fDecorate = TRUE;
    }
#if 0
    if (wndPlace.showCmd == SW_HIDE)
        return;                 //showCmd = SWP_HIDEWINDOW;
    else
        showCmd = SWP_SHOWWINDOW;
#else
    if (wndPlace.showCmd == SW_HIDE)
        return;

    if (IsWindowVisible(pRLWinPriv->hWnd))
        showCmd = SWP_SHOWWINDOW;
#endif

    showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;

    winDebug("winMWExtWMUpdateWindowDecoration %08x %s\n",
             (int) pRLWinPriv, fDecorate ? "Decorate" : "Bare");

    /* Get the standard and extended window style information */
    dwExStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE);
    dwStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE);

    if (fDecorate) {
        RECT rcNew;
        int iDx, iDy;
        winWMMessageRec wmMsg;

        winScreenPriv(pScreenInfo->pScreen);

        /* */
        if (!(dwExStyle & WS_EX_APPWINDOW)) {
            winDebug("\tBare=>Decorate\n");
            /* Setup a rectangle with the X window position and size */
            SetRect(&rcNew,
                    pRLWinPriv->pFrame->x,
                    pRLWinPriv->pFrame->y,
                    pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
                    pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);

#ifdef CYGMULTIWINDOW_DEBUG
            winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
                     rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
                     rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
            /* */
            AdjustWindowRectEx(&rcNew,
                               WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
                               FALSE, WS_EX_APPWINDOW);

#ifdef CYGMULTIWINDOW_DEBUG
            winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
                     rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
                     rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
            /* Calculate position deltas */
            iDx = pRLWinPriv->pFrame->x - rcNew.left;
            iDy = pRLWinPriv->pFrame->y - rcNew.top;

            /* Calculate new rectangle */
            rcNew.left += iDx;
            rcNew.right += iDx;
            rcNew.top += iDy;
            rcNew.bottom += iDy;

            /* Set the window extended style flags */
            SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);

            /* Set the window standard style flags */
            SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE,
                             WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);

#ifdef CYGMULTIWINDOW_DEBUG
            winDebug("\tWindowStyle: %08x %08x\n",
                     WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
                     WS_EX_APPWINDOW);
#endif
            /* Position the Windows window */
#ifdef CYGMULTIWINDOW_DEBUG
            winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
                     rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
                     rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
            SetWindowPos(pRLWinPriv->hWnd, NULL,
                         rcNew.left, rcNew.top,
                         rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
                         showCmd);

            wmMsg.hwndWindow = pRLWinPriv->hWnd;
            wmMsg.iWindow = (Window) pRLWinPriv->pFrame->win->drawable.id;
            wmMsg.msg = WM_WM_NAME_EVENT;
            winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);

            winMWExtWMReshapeFrame((RootlessFrameID) pRLWinPriv,
                                   wBoundingShape(pRLWinPriv->pFrame->win));
        }
    }
    else {
        RECT rcNew;

        /* */
        if (dwExStyle & WS_EX_APPWINDOW) {
            winDebug("\tDecorate=>Bare\n");
            /* Setup a rectangle with the X window position and size */
            SetRect(&rcNew,
                    pRLWinPriv->pFrame->x,
                    pRLWinPriv->pFrame->y,
                    pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
                    pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
#if 0
            /* */
            AdjustWindowRectEx(&rcNew,
                               WS_POPUP | WS_CLIPCHILDREN,
                               FALSE, WS_EX_TOOLWINDOW);

            /* Calculate position deltas */
            iDx = pRLWinPriv->pFrame->x - rcNew.left;
            iDy = pRLWinPriv->pFrame->y - rcNew.top;

            /* Calculate new rectangle */
            rcNew.left += iDx;
            rcNew.right += iDx;
            rcNew.top += iDy;
            rcNew.bottom += iDy;
#endif

            /* Hide window temporary to remove from taskbar. */
            ShowWindow(pRLWinPriv->hWnd, SW_HIDE);

            /* Set the window extended style flags */
            SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

            /* Set the window standard style flags */
            SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE,
                             WS_POPUP | WS_CLIPCHILDREN);

            /* Position the Windows window */
            SetWindowPos(pRLWinPriv->hWnd, NULL,
                         rcNew.left, rcNew.top,
                         rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
                         showCmd);

            winMWExtWMReshapeFrame((RootlessFrameID) pRLWinPriv,
                                   wBoundingShape(pRLWinPriv->pFrame->win));
        }
    }
}
예제 #2
0
static int
ProcWindowsWMFrameDraw(ClientPtr client)
{
    REQUEST(xWindowsWMFrameDrawReq);
    WindowPtr pWin;
    win32RootlessWindowPtr pRLWinPriv;
    RECT rcNew;
    int nCmdShow, rc;
    RegionRec newShape;

    REQUEST_SIZE_MATCH(xWindowsWMFrameDrawReq);

#if CYGMULTIWINDOW_DEBUG
    ErrorF("ProcWindowsWMFrameDraw\n");
#endif
    rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
    if (rc != Success)
        return rc;
#if CYGMULTIWINDOW_DEBUG
    ErrorF("ProcWindowsWMFrameDraw - Window found\n");
#endif

    pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, TRUE);
    if (pRLWinPriv == 0)
        return BadWindow;

#if CYGMULTIWINDOW_DEBUG
    ErrorF("ProcWindowsWMFrameDraw - HWND %p 0x%08x 0x%08x\n",
           pRLWinPriv->hWnd, (int) stuff->frame_style,
           (int) stuff->frame_style_ex);
    ErrorF("ProcWindowsWMFrameDraw - %d %d %d %d\n",
           stuff->ix, stuff->iy, stuff->iw, stuff->ih);
#endif

    /* Store the origin, height, and width in a rectangle structure */
    SetRect(&rcNew, stuff->ix, stuff->iy,
            stuff->ix + stuff->iw, stuff->iy + stuff->ih);

    /*
     * Calculate the required size of the Windows window rectangle,
     * given the size of the Windows window client area.
     */
    AdjustWindowRectEx(&rcNew, stuff->frame_style, FALSE,
                       stuff->frame_style_ex);

    /* Set the window extended style flags */
    if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex)) {
        return BadValue;
    }

    /* Set the window standard style flags */
    if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style)) {
        return BadValue;
    }

    /* Flush the window style */
    if (!SetWindowPos(pRLWinPriv->hWnd, NULL,
                      rcNew.left, rcNew.top,
                      rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
                      SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE)) {
        return BadValue;
    }
    if (!IsWindowVisible(pRLWinPriv->hWnd))
        nCmdShow = SW_HIDE;
    else
        nCmdShow = SW_SHOWNA;

    ShowWindow(pRLWinPriv->hWnd, nCmdShow);

    if (wBoundingShape(pWin) != NULL) {
        /* wBoundingShape is relative to *inner* origin of window.
           Translate by borderWidth to get the outside-relative position. */

        RegionNull(&newShape);
        RegionCopy(&newShape, wBoundingShape(pWin));
        RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth);
        winMWExtWMReshapeFrame(pRLWinPriv, &newShape);
        RegionUninit(&newShape);
    }
#if CYGMULTIWINDOW_DEBUG
    ErrorF("ProcWindowsWMFrameDraw - done\n");
#endif

    return Success;
}