winrandr.c revision 05b261ec
1/*
2 *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
3 *
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
11 *
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
14 *
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 *Except as contained in this notice, the name of Harold L Hunt II
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from Harold L Hunt II.
27 *
28 * Authors:	Harold L Hunt II
29 */
30
31#ifdef HAVE_XWIN_CONFIG_H
32#include <xwin-config.h>
33#endif
34#include "win.h"
35
36
37/*
38 * Local prototypes
39 */
40
41static Bool
42winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations);
43
44static Bool
45winRandRSetConfig (ScreenPtr		pScreen,
46		   Rotation		rotateKind,
47		   int			rate,
48		   RRScreenSizePtr	pSize);
49
50Bool
51winRandRInit (ScreenPtr pScreen);
52
53
54/*
55 * Answer queries about the RandR features supported.
56 */
57
58static Bool
59winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
60{
61  winScreenPriv(pScreen);
62  winScreenInfo			*pScreenInfo = pScreenPriv->pScreenInfo;
63  int				n;
64  Rotation			rotateKind;
65  RRScreenSizePtr		pSize;
66
67  winDebug ("winRandRGetInfo ()\n");
68
69  /* Don't support rotations, yet */
70  *pRotations = RR_Rotate_0;
71
72  /* Bail if no depth has a visual associated with it */
73  for (n = 0; n < pScreen->numDepths; n++)
74    if (pScreen->allowedDepths[n].numVids)
75      break;
76  if (n == pScreen->numDepths)
77    return FALSE;
78
79  /* Only one allowed rotation for now */
80  rotateKind = RR_Rotate_0;
81
82  /*
83   * Register supported sizes.  This can be called many times, but
84   * we only support one size for now.
85   */
86  pSize = RRRegisterSize (pScreen,
87			  pScreenInfo->dwWidth,
88			  pScreenInfo->dwHeight,
89			  pScreenInfo->dwWidth_mm,
90			  pScreenInfo->dwHeight_mm);
91
92  /* Tell RandR what the current config is */
93  RRSetCurrentConfig (pScreen,
94		      rotateKind,
95		      0, /* refresh rate, not needed */
96		      pSize);
97
98  return TRUE;
99}
100
101
102/*
103 * Respond to resize/rotate request from either X Server or X client app
104 */
105
106static Bool
107winRandRSetConfig (ScreenPtr		pScreen,
108		   Rotation		rotateKind,
109		   int			rate,
110		   RRScreenSizePtr	pSize)
111{
112  winDebug ("winRandRSetConfig ()\n");
113
114  return TRUE;
115}
116
117
118/*
119 * Initialize the RandR layer.
120 */
121
122Bool
123winRandRInit (ScreenPtr pScreen)
124{
125  rrScrPrivPtr		pRRScrPriv;
126
127  winDebug ("winRandRInit ()\n");
128
129  if (!RRScreenInit (pScreen))
130    {
131      ErrorF ("winRandRInit () - RRScreenInit () failed\n");
132      return FALSE;
133    }
134
135  /* Set some RandR function pointers */
136  pRRScrPriv = rrGetScrPriv (pScreen);
137  pRRScrPriv->rrGetInfo = winRandRGetInfo;
138  pRRScrPriv->rrSetConfig = winRandRSetConfig;
139
140  return TRUE;
141}
142