#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
#include "win.h"
#include "mivalidate.h" // for union _Validate used by windowstr.h
#ifndef RANDR_12_INTERFACE
#error X server must have RandR 1.2 interface
#endif
static Bool
winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
{
winDebug ("winRandRGetInfo ()\n");
*pRotations = RR_Rotate_0;
RRScreenSetSizeRange(pScreen, 0, 0, 4096, 4096);
return TRUE;
}
static void
xf86SetRootClip (ScreenPtr pScreen, Bool enable)
{
WindowPtr pWin = pScreen->root;
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
Bool anyMarked = FALSE;
WindowPtr pLayerWin;
BoxRec box;
if (WasViewable)
{
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
{
(void) (*pScreen->MarkOverlappedWindows)(pChild,
pChild,
&pLayerWin);
}
(*pScreen->MarkWindow) (pWin);
anyMarked = TRUE;
if (pWin->valdata)
{
if (HasBorder (pWin))
{
RegionPtr borderVisible;
borderVisible = REGION_CREATE(pScreen, NullBox, 1);
REGION_SUBTRACT(pScreen, borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
pWin->valdata->before.resized = TRUE;
}
}
if (enable)
{
box.x1 = 0;
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
REGION_INIT (pScreen, &pWin->winSize, &box, 1);
REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
if (WasViewable)
REGION_RESET(pScreen, &pWin->borderClip, &box);
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
else
{
REGION_EMPTY(pScreen, &pWin->borderClip);
REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
if (WasViewable)
{
if (pWin->firstChild)
{
anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
pWin->firstChild,
(WindowPtr *)NULL);
}
else
{
(*pScreen->MarkWindow) (pWin);
anyMarked = TRUE;
}
if (anyMarked)
(*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
}
if (WasViewable)
{
if (anyMarked)
(*pScreen->HandleExposures)(pWin);
if (anyMarked && pScreen->PostValidateTree)
(*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
}
if (pWin->realized)
WindowsRestructured ();
FlushAllOutput ();
}
void
winDoRandRScreenSetSize (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
CARD32 mmWidth,
CARD32 mmHeight)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
WindowPtr pRoot = pScreen->root;
xf86SetRootClip(pScreen, FALSE);
pScreenInfo->dwWidth = width;
pScreenInfo->dwHeight = height;
(*pScreenPriv->pwinFreeFB)(pScreen);
if (!(*pScreenPriv->pwinAllocateFB)(pScreen))
{
ErrorF ("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
}
pScreen->width = width;
pScreen->height = height;
pScreen->mmWidth = mmWidth;
pScreen->mmHeight = mmHeight;
winUpdateFBPointer(pScreen, pScreenInfo->pfb);
xf86SetRootClip(pScreen, TRUE);
miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
RRScreenSizeNotify(pScreen);
}
static
Bool
winRandRScreenSetSize (ScreenPtr pScreen,
CARD16 width,
CARD16 height,
CARD16 pixWidth,
CARD16 pixHeight,
CARD32 mmWidth,
CARD32 mmHeight)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
winDebug ("winRandRScreenSetSize ()\n");
if (pScreenInfo->fFullScreen)
{
ErrorF ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
return FALSE;
}
if (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
|| pScreenInfo->fMWExtWM
#endif
|| pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
|| pScreenInfo->fMultiWindow
#endif
)
{
ErrorF ("winRandRScreenSetSize - resize not supported in rootless modes\n");
return FALSE;
}
winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
{
DWORD dwStyle, dwExStyle;
RECT rcClient;
rcClient.left = 0;
rcClient.top = 0;
rcClient.right = width;
rcClient.bottom = height;
ErrorF ("winRandRScreenSetSize new client area w: %d h: %d\n", width, height);
dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
ErrorF ("winRandRScreenSetSize new window area w: %ld h: %ld\n", rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
SetWindowPos(pScreenPriv->hwndScreen, NULL,
0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
SWP_NOZORDER | SWP_NOMOVE);
}
return TRUE;
}
Bool
winRandRInit (ScreenPtr pScreen)
{
rrScrPrivPtr pRRScrPriv;
winDebug ("winRandRInit ()\n");
if (!RRScreenInit (pScreen))
{
ErrorF ("winRandRInit () - RRScreenInit () failed\n");
return FALSE;
}
pRRScrPriv = rrGetScrPriv (pScreen);
pRRScrPriv->rrGetInfo = winRandRGetInfo;
pRRScrPriv->rrSetConfig = NULL;
pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
pRRScrPriv->rrCrtcSet = NULL;
pRRScrPriv->rrCrtcSetGamma = NULL;
return TRUE;
}