2 *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
3 *Copyright (C) 2009-2010 Jon TURNEY
5 *Permission is hereby granted, free of charge, to any person obtaining
6 *a copy of this software and associated documentation files (the
7 *"Software"), to deal in the Software without restriction, including
8 *without limitation the rights to use, copy, modify, merge, publish,
9 *distribute, sublicense, and/or sell copies of the Software, and to
10 *permit persons to whom the Software is furnished to do so, subject to
11 *the following conditions:
13 *The above copyright notice and this permission notice shall be
14 *included in all copies or substantial portions of the Software.
16 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
20 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *Except as contained in this notice, the name of the author(s)
25 *shall not be used in advertising or otherwise to promote the sale, use
26 *or other dealings in this Software without prior written authorization
29 * Authors: Harold L Hunt II
33 #ifdef HAVE_XWIN_CONFIG_H
34 #include <xwin-config.h>
37 #include "mivalidate.h" // for union _Validate used by windowstr.h
39 #ifndef RANDR_12_INTERFACE
40 #error X server must have RandR 1.2 interface
44 * Answer queries about the RandR features supported.
48 winRandRGetInfo(ScreenPtr pScreen
, Rotation
* pRotations
)
50 winDebug("winRandRGetInfo ()\n");
52 /* Don't support rotations */
53 *pRotations
= RR_Rotate_0
;
56 The screen doesn't have to be limited to the actual
57 monitor size (we can have scrollbars :-), so what is
60 RRScreenSetSizeRange(pScreen
, 0, 0, 4096, 4096);
69 winDoRandRScreenSetSize(ScreenPtr pScreen
,
71 CARD16 height
, CARD32 mmWidth
, CARD32 mmHeight
)
73 winScreenPriv(pScreen
);
74 winScreenInfo
*pScreenInfo
= pScreenPriv
->pScreenInfo
;
75 WindowPtr pRoot
= pScreen
->root
;
77 // Prevent screen updates while we change things around
78 SetRootClip(pScreen
, FALSE
);
80 /* Update the screen size as requested */
81 pScreenInfo
->dwWidth
= width
;
82 pScreenInfo
->dwHeight
= height
;
84 /* Reallocate the framebuffer used by the drawing engine */
85 (*pScreenPriv
->pwinFreeFB
) (pScreen
);
86 if (!(*pScreenPriv
->pwinAllocateFB
) (pScreen
)) {
87 ErrorF("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
90 pScreen
->width
= width
;
91 pScreen
->height
= height
;
92 pScreen
->mmWidth
= mmWidth
;
93 pScreen
->mmHeight
= mmHeight
;
95 /* Update the screen pixmap to point to the new framebuffer */
96 winUpdateFBPointer(pScreen
, pScreenInfo
->pfb
);
98 // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
99 // resize the root window
100 //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
101 // does this emit a ConfigureNotify??
103 // Restore the ability to update screen, now with new dimensions
104 SetRootClip(pScreen
, TRUE
);
106 // and arrange for it to be repainted
107 miPaintWindow(pRoot
, &pRoot
->borderClip
, PW_BACKGROUND
);
109 /* Indicate that a screen size change took place */
110 RRScreenSizeNotify(pScreen
);
114 * Respond to resize request
118 winRandRScreenSetSize(ScreenPtr pScreen
,
120 CARD16 height
, CARD32 mmWidth
, CARD32 mmHeight
)
122 winScreenPriv(pScreen
);
123 winScreenInfo
*pScreenInfo
= pScreenPriv
->pScreenInfo
;
125 winDebug("winRandRScreenSetSize ()\n");
128 It doesn't currently make sense to allow resize in fullscreen mode
129 (we'd actually have to list the supported resolutions)
131 if (pScreenInfo
->fFullScreen
) {
133 ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
138 Client resize requests aren't allowed in rootless modes, even if
139 the X screen is monitor or virtual desktop size, we'd need to
140 resize the native display size
143 #ifdef XWIN_MULTIWINDOWEXTWM
144 || pScreenInfo
->fMWExtWM
146 || pScreenInfo
->fRootless
147 #ifdef XWIN_MULTIWINDOW
148 || pScreenInfo
->fMultiWindow
152 ("winRandRScreenSetSize - resize not supported in rootless modes\n");
156 winDoRandRScreenSetSize(pScreen
, width
, height
, mmWidth
, mmHeight
);
158 /* Cause the native window for the screen to resize itself */
160 DWORD dwStyle
, dwExStyle
;
165 rcClient
.right
= width
;
166 rcClient
.bottom
= height
;
168 ErrorF("winRandRScreenSetSize new client area w: %d h: %d\n", width
,
171 /* Get the Windows window style and extended style */
172 dwExStyle
= GetWindowLongPtr(pScreenPriv
->hwndScreen
, GWL_EXSTYLE
);
173 dwStyle
= GetWindowLongPtr(pScreenPriv
->hwndScreen
, GWL_STYLE
);
176 * Calculate the window size needed for the given client area
177 * adjusting for any decorations it will have
179 AdjustWindowRectEx(&rcClient
, dwStyle
, FALSE
, dwExStyle
);
181 ErrorF("winRandRScreenSetSize new window area w: %ld h: %ld\n",
182 rcClient
.right
- rcClient
.left
, rcClient
.bottom
- rcClient
.top
);
184 SetWindowPos(pScreenPriv
->hwndScreen
, NULL
,
185 0, 0, rcClient
.right
- rcClient
.left
,
186 rcClient
.bottom
- rcClient
.top
, SWP_NOZORDER
| SWP_NOMOVE
);
193 * Initialize the RandR layer.
197 winRandRInit(ScreenPtr pScreen
)
199 rrScrPrivPtr pRRScrPriv
;
201 winDebug("winRandRInit ()\n");
203 if (!RRScreenInit(pScreen
)) {
204 ErrorF("winRandRInit () - RRScreenInit () failed\n");
208 /* Set some RandR function pointers */
209 pRRScrPriv
= rrGetScrPriv(pScreen
);
210 pRRScrPriv
->rrGetInfo
= winRandRGetInfo
;
211 pRRScrPriv
->rrSetConfig
= NULL
;
212 pRRScrPriv
->rrScreenSetSize
= winRandRScreenSetSize
;
213 pRRScrPriv
->rrCrtcSet
= NULL
;
214 pRRScrPriv
->rrCrtcSetGamma
= NULL
;