| File: | randr/randr.c |
| Location: | line 558, column 9 |
| Description: | Value stored to 'master' is never read |
| 1 | /* |
| 2 | * Copyright © 2000 Compaq Computer Corporation |
| 3 | * Copyright © 2002 Hewlett-Packard Company |
| 4 | * Copyright © 2006 Intel Corporation |
| 5 | * |
| 6 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 7 | * documentation for any purpose is hereby granted without fee, provided that |
| 8 | * the above copyright notice appear in all copies and that both that copyright |
| 9 | * notice and this permission notice appear in supporting documentation, and |
| 10 | * that the name of the copyright holders not be used in advertising or |
| 11 | * publicity pertaining to distribution of the software without specific, |
| 12 | * written prior permission. The copyright holders make no representations |
| 13 | * about the suitability of this software for any purpose. It is provided "as |
| 14 | * is" without express or implied warranty. |
| 15 | * |
| 16 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 17 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 18 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 19 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 20 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 21 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 22 | * OF THIS SOFTWARE. |
| 23 | * |
| 24 | * Author: Jim Gettys, Hewlett-Packard Company, Inc. |
| 25 | * Keith Packard, Intel Corporation |
| 26 | */ |
| 27 | |
| 28 | #ifdef HAVE_DIX_CONFIG_H1 |
| 29 | #include <dix-config.h> |
| 30 | #endif |
| 31 | |
| 32 | #include "randrstr.h" |
| 33 | #include "extinit.h" |
| 34 | |
| 35 | /* From render.h */ |
| 36 | #ifndef SubPixelUnknown0 |
| 37 | #define SubPixelUnknown0 0 |
| 38 | #endif |
| 39 | |
| 40 | #define RR_VALIDATE |
| 41 | static int RRNScreens; |
| 42 | |
| 43 | #define wrap(priv,real,mem,func){ priv->mem = real->mem; real->mem = func; } {\ |
| 44 | priv->mem = real->mem; \ |
| 45 | real->mem = func; \ |
| 46 | } |
| 47 | |
| 48 | #define unwrap(priv,real,mem){ real->mem = priv->mem; } {\ |
| 49 | real->mem = priv->mem; \ |
| 50 | } |
| 51 | |
| 52 | static int ProcRRDispatch(ClientPtr pClient); |
| 53 | static int SProcRRDispatch(ClientPtr pClient); |
| 54 | |
| 55 | int RREventBase; |
| 56 | int RRErrorBase; |
| 57 | RESTYPE RRClientType, RREventType; /* resource types for event masks */ |
| 58 | DevPrivateKeyRec RRClientPrivateKeyRec; |
| 59 | |
| 60 | DevPrivateKeyRec rrPrivKeyRec; |
| 61 | |
| 62 | static void |
| 63 | RRClientCallback(CallbackListPtr *list, void *closure, void *data) |
| 64 | { |
| 65 | NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; |
| 66 | ClientPtr pClient = clientinfo->client; |
| 67 | |
| 68 | rrClientPriv(pClient)RRClientPtr pRRClient = ((RRClientPtr)dixLookupPrivate(&( pClient)->devPrivates, (&RRClientPrivateKeyRec))); |
| 69 | RRTimesPtr pTimes = (RRTimesPtr) (pRRClient + 1); |
| 70 | int i; |
| 71 | |
| 72 | pRRClient->major_version = 0; |
| 73 | pRRClient->minor_version = 0; |
| 74 | for (i = 0; i < screenInfo.numScreens; i++) { |
| 75 | ScreenPtr pScreen = screenInfo.screens[i]; |
| 76 | |
| 77 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 78 | |
| 79 | if (pScrPriv) { |
| 80 | pTimes[i].setTime = pScrPriv->lastSetTime; |
| 81 | pTimes[i].configTime = pScrPriv->lastConfigTime; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | static Bool |
| 87 | RRCloseScreen(ScreenPtr pScreen) |
| 88 | { |
| 89 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 90 | int j; |
| 91 | |
| 92 | unwrap(pScrPriv, pScreen, CloseScreen){ pScreen->CloseScreen = pScrPriv->CloseScreen; }; |
| 93 | for (j = pScrPriv->numCrtcs - 1; j >= 0; j--) |
| 94 | RRCrtcDestroy(pScrPriv->crtcs[j]); |
| 95 | for (j = pScrPriv->numOutputs - 1; j >= 0; j--) |
| 96 | RROutputDestroy(pScrPriv->outputs[j]); |
| 97 | |
| 98 | if (pScrPriv->provider) |
| 99 | RRProviderDestroy(pScrPriv->provider); |
| 100 | |
| 101 | RRMonitorClose(pScreen); |
| 102 | |
| 103 | free(pScrPriv->crtcs); |
| 104 | free(pScrPriv->outputs); |
| 105 | free(pScrPriv); |
| 106 | RRNScreens -= 1; /* ok, one fewer screen with RandR running */ |
| 107 | return (*pScreen->CloseScreen) (pScreen); |
| 108 | } |
| 109 | |
| 110 | static void |
| 111 | SRRScreenChangeNotifyEvent(xRRScreenChangeNotifyEvent * from, |
| 112 | xRRScreenChangeNotifyEvent * to) |
| 113 | { |
| 114 | to->type = from->type; |
| 115 | to->rotation = from->rotation; |
| 116 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 117 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 118 | cpswapl(from->configTimestamp, to->configTimestamp)do { if (sizeof((from->configTimestamp)) != 4 || sizeof((to ->configTimestamp)) != 4) wrong_size(); (to->configTimestamp ) = lswapl((from->configTimestamp)); } while (0); |
| 119 | cpswapl(from->root, to->root)do { if (sizeof((from->root)) != 4 || sizeof((to->root) ) != 4) wrong_size(); (to->root) = lswapl((from->root)) ; } while (0); |
| 120 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 121 | cpswaps(from->sizeID, to->sizeID)do { if (sizeof((from->sizeID)) != 2 || sizeof((to->sizeID )) != 2) wrong_size(); (to->sizeID) = lswaps((from->sizeID )); } while (0); |
| 122 | cpswaps(from->subpixelOrder, to->subpixelOrder)do { if (sizeof((from->subpixelOrder)) != 2 || sizeof((to-> subpixelOrder)) != 2) wrong_size(); (to->subpixelOrder) = lswaps ((from->subpixelOrder)); } while (0); |
| 123 | cpswaps(from->widthInPixels, to->widthInPixels)do { if (sizeof((from->widthInPixels)) != 2 || sizeof((to-> widthInPixels)) != 2) wrong_size(); (to->widthInPixels) = lswaps ((from->widthInPixels)); } while (0); |
| 124 | cpswaps(from->heightInPixels, to->heightInPixels)do { if (sizeof((from->heightInPixels)) != 2 || sizeof((to ->heightInPixels)) != 2) wrong_size(); (to->heightInPixels ) = lswaps((from->heightInPixels)); } while (0); |
| 125 | cpswaps(from->widthInMillimeters, to->widthInMillimeters)do { if (sizeof((from->widthInMillimeters)) != 2 || sizeof ((to->widthInMillimeters)) != 2) wrong_size(); (to->widthInMillimeters ) = lswaps((from->widthInMillimeters)); } while (0); |
| 126 | cpswaps(from->heightInMillimeters, to->heightInMillimeters)do { if (sizeof((from->heightInMillimeters)) != 2 || sizeof ((to->heightInMillimeters)) != 2) wrong_size(); (to->heightInMillimeters ) = lswaps((from->heightInMillimeters)); } while (0); |
| 127 | } |
| 128 | |
| 129 | static void |
| 130 | SRRCrtcChangeNotifyEvent(xRRCrtcChangeNotifyEvent * from, |
| 131 | xRRCrtcChangeNotifyEvent * to) |
| 132 | { |
| 133 | to->type = from->type; |
| 134 | to->subCode = from->subCode; |
| 135 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 136 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 137 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 138 | cpswapl(from->crtc, to->crtc)do { if (sizeof((from->crtc)) != 4 || sizeof((to->crtc) ) != 4) wrong_size(); (to->crtc) = lswapl((from->crtc)) ; } while (0); |
| 139 | cpswapl(from->mode, to->mode)do { if (sizeof((from->mode)) != 4 || sizeof((to->mode) ) != 4) wrong_size(); (to->mode) = lswapl((from->mode)) ; } while (0); |
| 140 | cpswaps(from->rotation, to->rotation)do { if (sizeof((from->rotation)) != 2 || sizeof((to->rotation )) != 2) wrong_size(); (to->rotation) = lswaps((from->rotation )); } while (0); |
| 141 | /* pad1 */ |
| 142 | cpswaps(from->x, to->x)do { if (sizeof((from->x)) != 2 || sizeof((to->x)) != 2 ) wrong_size(); (to->x) = lswaps((from->x)); } while (0 ); |
| 143 | cpswaps(from->y, to->y)do { if (sizeof((from->y)) != 2 || sizeof((to->y)) != 2 ) wrong_size(); (to->y) = lswaps((from->y)); } while (0 ); |
| 144 | cpswaps(from->width, to->width)do { if (sizeof((from->width)) != 2 || sizeof((to->width )) != 2) wrong_size(); (to->width) = lswaps((from->width )); } while (0); |
| 145 | cpswaps(from->height, to->height)do { if (sizeof((from->height)) != 2 || sizeof((to->height )) != 2) wrong_size(); (to->height) = lswaps((from->height )); } while (0); |
| 146 | } |
| 147 | |
| 148 | static void |
| 149 | SRROutputChangeNotifyEvent(xRROutputChangeNotifyEvent * from, |
| 150 | xRROutputChangeNotifyEvent * to) |
| 151 | { |
| 152 | to->type = from->type; |
| 153 | to->subCode = from->subCode; |
| 154 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 155 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 156 | cpswapl(from->configTimestamp, to->configTimestamp)do { if (sizeof((from->configTimestamp)) != 4 || sizeof((to ->configTimestamp)) != 4) wrong_size(); (to->configTimestamp ) = lswapl((from->configTimestamp)); } while (0); |
| 157 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 158 | cpswapl(from->output, to->output)do { if (sizeof((from->output)) != 4 || sizeof((to->output )) != 4) wrong_size(); (to->output) = lswapl((from->output )); } while (0); |
| 159 | cpswapl(from->crtc, to->crtc)do { if (sizeof((from->crtc)) != 4 || sizeof((to->crtc) ) != 4) wrong_size(); (to->crtc) = lswapl((from->crtc)) ; } while (0); |
| 160 | cpswapl(from->mode, to->mode)do { if (sizeof((from->mode)) != 4 || sizeof((to->mode) ) != 4) wrong_size(); (to->mode) = lswapl((from->mode)) ; } while (0); |
| 161 | cpswaps(from->rotation, to->rotation)do { if (sizeof((from->rotation)) != 2 || sizeof((to->rotation )) != 2) wrong_size(); (to->rotation) = lswaps((from->rotation )); } while (0); |
| 162 | to->connection = from->connection; |
| 163 | to->subpixelOrder = from->subpixelOrder; |
| 164 | } |
| 165 | |
| 166 | static void |
| 167 | SRROutputPropertyNotifyEvent(xRROutputPropertyNotifyEvent * from, |
| 168 | xRROutputPropertyNotifyEvent * to) |
| 169 | { |
| 170 | to->type = from->type; |
| 171 | to->subCode = from->subCode; |
| 172 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 173 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 174 | cpswapl(from->output, to->output)do { if (sizeof((from->output)) != 4 || sizeof((to->output )) != 4) wrong_size(); (to->output) = lswapl((from->output )); } while (0); |
| 175 | cpswapl(from->atom, to->atom)do { if (sizeof((from->atom)) != 4 || sizeof((to->atom) ) != 4) wrong_size(); (to->atom) = lswapl((from->atom)) ; } while (0); |
| 176 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 177 | to->state = from->state; |
| 178 | /* pad1 */ |
| 179 | /* pad2 */ |
| 180 | /* pad3 */ |
| 181 | /* pad4 */ |
| 182 | } |
| 183 | |
| 184 | static void |
| 185 | SRRProviderChangeNotifyEvent(xRRProviderChangeNotifyEvent * from, |
| 186 | xRRProviderChangeNotifyEvent * to) |
| 187 | { |
| 188 | to->type = from->type; |
| 189 | to->subCode = from->subCode; |
| 190 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 191 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 192 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 193 | cpswapl(from->provider, to->provider)do { if (sizeof((from->provider)) != 4 || sizeof((to->provider )) != 4) wrong_size(); (to->provider) = lswapl((from->provider )); } while (0); |
| 194 | } |
| 195 | |
| 196 | static void |
| 197 | SRRProviderPropertyNotifyEvent(xRRProviderPropertyNotifyEvent * from, |
| 198 | xRRProviderPropertyNotifyEvent * to) |
| 199 | { |
| 200 | to->type = from->type; |
| 201 | to->subCode = from->subCode; |
| 202 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 203 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 204 | cpswapl(from->provider, to->provider)do { if (sizeof((from->provider)) != 4 || sizeof((to->provider )) != 4) wrong_size(); (to->provider) = lswapl((from->provider )); } while (0); |
| 205 | cpswapl(from->atom, to->atom)do { if (sizeof((from->atom)) != 4 || sizeof((to->atom) ) != 4) wrong_size(); (to->atom) = lswapl((from->atom)) ; } while (0); |
| 206 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 207 | to->state = from->state; |
| 208 | /* pad1 */ |
| 209 | /* pad2 */ |
| 210 | /* pad3 */ |
| 211 | /* pad4 */ |
| 212 | } |
| 213 | |
| 214 | static void |
| 215 | SRRResourceChangeNotifyEvent(xRRResourceChangeNotifyEvent * from, |
| 216 | xRRResourceChangeNotifyEvent * to) |
| 217 | { |
| 218 | to->type = from->type; |
| 219 | to->subCode = from->subCode; |
| 220 | cpswaps(from->sequenceNumber, to->sequenceNumber)do { if (sizeof((from->sequenceNumber)) != 2 || sizeof((to ->sequenceNumber)) != 2) wrong_size(); (to->sequenceNumber ) = lswaps((from->sequenceNumber)); } while (0); |
| 221 | cpswapl(from->timestamp, to->timestamp)do { if (sizeof((from->timestamp)) != 4 || sizeof((to-> timestamp)) != 4) wrong_size(); (to->timestamp) = lswapl(( from->timestamp)); } while (0); |
| 222 | cpswapl(from->window, to->window)do { if (sizeof((from->window)) != 4 || sizeof((to->window )) != 4) wrong_size(); (to->window) = lswapl((from->window )); } while (0); |
| 223 | } |
| 224 | |
| 225 | static void |
| 226 | SRRNotifyEvent(xEvent *from, xEvent *to) |
| 227 | { |
| 228 | switch (from->u.u.detail) { |
| 229 | case RRNotify_CrtcChange0: |
| 230 | SRRCrtcChangeNotifyEvent((xRRCrtcChangeNotifyEvent *) from, |
| 231 | (xRRCrtcChangeNotifyEvent *) to); |
| 232 | break; |
| 233 | case RRNotify_OutputChange1: |
| 234 | SRROutputChangeNotifyEvent((xRROutputChangeNotifyEvent *) from, |
| 235 | (xRROutputChangeNotifyEvent *) to); |
| 236 | break; |
| 237 | case RRNotify_OutputProperty2: |
| 238 | SRROutputPropertyNotifyEvent((xRROutputPropertyNotifyEvent *) from, |
| 239 | (xRROutputPropertyNotifyEvent *) to); |
| 240 | break; |
| 241 | case RRNotify_ProviderChange3: |
| 242 | SRRProviderChangeNotifyEvent((xRRProviderChangeNotifyEvent *) from, |
| 243 | (xRRProviderChangeNotifyEvent *) to); |
| 244 | break; |
| 245 | case RRNotify_ProviderProperty4: |
| 246 | SRRProviderPropertyNotifyEvent((xRRProviderPropertyNotifyEvent *) from, |
| 247 | (xRRProviderPropertyNotifyEvent *) to); |
| 248 | break; |
| 249 | case RRNotify_ResourceChange5: |
| 250 | SRRResourceChangeNotifyEvent((xRRResourceChangeNotifyEvent *) from, |
| 251 | (xRRResourceChangeNotifyEvent *) to); |
| 252 | default: |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | static int RRGeneration; |
| 258 | |
| 259 | Bool |
| 260 | RRInit(void) |
| 261 | { |
| 262 | if (RRGeneration != serverGeneration) { |
| 263 | if (!RRModeInit()) |
| 264 | return FALSE0; |
| 265 | if (!RRCrtcInit()) |
| 266 | return FALSE0; |
| 267 | if (!RROutputInit()) |
| 268 | return FALSE0; |
| 269 | if (!RRProviderInit()) |
| 270 | return FALSE0; |
| 271 | RRGeneration = serverGeneration; |
| 272 | } |
| 273 | if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0)) |
| 274 | return FALSE0; |
| 275 | |
| 276 | return TRUE1; |
| 277 | } |
| 278 | |
| 279 | Bool |
| 280 | RRScreenInit(ScreenPtr pScreen) |
| 281 | { |
| 282 | rrScrPrivPtr pScrPriv; |
| 283 | |
| 284 | if (!RRInit()) |
| 285 | return FALSE0; |
| 286 | |
| 287 | pScrPriv = (rrScrPrivPtr) calloc(1, sizeof(rrScrPrivRec)); |
| 288 | if (!pScrPriv) |
| 289 | return FALSE0; |
| 290 | |
| 291 | SetRRScreen(pScreen, pScrPriv)dixSetPrivate(&(pScreen)->devPrivates, (&rrPrivKeyRec ), pScrPriv); |
| 292 | |
| 293 | /* |
| 294 | * Calling function best set these function vectors |
| 295 | */ |
| 296 | pScrPriv->rrGetInfo = 0; |
| 297 | pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width; |
| 298 | pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height; |
| 299 | |
| 300 | pScrPriv->width = pScreen->width; |
| 301 | pScrPriv->height = pScreen->height; |
| 302 | pScrPriv->mmWidth = pScreen->mmWidth; |
| 303 | pScrPriv->mmHeight = pScreen->mmHeight; |
| 304 | #if RANDR_12_INTERFACE1 |
| 305 | pScrPriv->rrScreenSetSize = NULL((void*)0); |
| 306 | pScrPriv->rrCrtcSet = NULL((void*)0); |
| 307 | pScrPriv->rrCrtcSetGamma = NULL((void*)0); |
| 308 | #endif |
| 309 | #if RANDR_10_INTERFACE1 |
| 310 | pScrPriv->rrSetConfig = 0; |
| 311 | pScrPriv->rotations = RR_Rotate_01; |
| 312 | pScrPriv->reqWidth = pScreen->width; |
| 313 | pScrPriv->reqHeight = pScreen->height; |
| 314 | pScrPriv->nSizes = 0; |
| 315 | pScrPriv->pSizes = NULL((void*)0); |
| 316 | pScrPriv->rotation = RR_Rotate_01; |
| 317 | pScrPriv->rate = 0; |
| 318 | pScrPriv->size = 0; |
| 319 | #endif |
| 320 | |
| 321 | /* |
| 322 | * This value doesn't really matter -- any client must call |
| 323 | * GetScreenInfo before reading it which will automatically update |
| 324 | * the time |
| 325 | */ |
| 326 | pScrPriv->lastSetTime = currentTime; |
| 327 | pScrPriv->lastConfigTime = currentTime; |
| 328 | |
| 329 | wrap(pScrPriv, pScreen, CloseScreen, RRCloseScreen){ pScrPriv->CloseScreen = pScreen->CloseScreen; pScreen ->CloseScreen = RRCloseScreen; }; |
| 330 | |
| 331 | pScreen->ConstrainCursorHarder = RRConstrainCursorHarder; |
| 332 | pScreen->ReplaceScanoutPixmap = RRReplaceScanoutPixmap; |
| 333 | pScrPriv->numOutputs = 0; |
| 334 | pScrPriv->outputs = NULL((void*)0); |
| 335 | pScrPriv->numCrtcs = 0; |
| 336 | pScrPriv->crtcs = NULL((void*)0); |
| 337 | |
| 338 | RRMonitorInit(pScreen); |
| 339 | |
| 340 | RRNScreens += 1; /* keep count of screens that implement randr */ |
| 341 | return TRUE1; |
| 342 | } |
| 343 | |
| 344 | /*ARGSUSED*/ static int |
| 345 | RRFreeClient(void *data, XID id) |
| 346 | { |
| 347 | RREventPtr pRREvent; |
| 348 | WindowPtr pWin; |
| 349 | RREventPtr *pHead, pCur, pPrev; |
| 350 | |
| 351 | pRREvent = (RREventPtr) data; |
| 352 | pWin = pRREvent->window; |
| 353 | dixLookupResourceByType((void **) &pHead, pWin->drawable.id, |
| 354 | RREventType, serverClient, DixDestroyAccess(1<<2)); |
| 355 | if (pHead) { |
| 356 | pPrev = 0; |
| 357 | for (pCur = *pHead; pCur && pCur != pRREvent; pCur = pCur->next) |
| 358 | pPrev = pCur; |
| 359 | if (pCur) { |
| 360 | if (pPrev) |
| 361 | pPrev->next = pRREvent->next; |
| 362 | else |
| 363 | *pHead = pRREvent->next; |
| 364 | } |
| 365 | } |
| 366 | free((void *) pRREvent); |
| 367 | return 1; |
| 368 | } |
| 369 | |
| 370 | /*ARGSUSED*/ static int |
| 371 | RRFreeEvents(void *data, XID id) |
| 372 | { |
| 373 | RREventPtr *pHead, pCur, pNext; |
| 374 | |
| 375 | pHead = (RREventPtr *) data; |
| 376 | for (pCur = *pHead; pCur; pCur = pNext) { |
| 377 | pNext = pCur->next; |
| 378 | FreeResource(pCur->clientResource, RRClientType); |
| 379 | free((void *) pCur); |
| 380 | } |
| 381 | free((void *) pHead); |
| 382 | return 1; |
| 383 | } |
| 384 | |
| 385 | void |
| 386 | RRExtensionInit(void) |
| 387 | { |
| 388 | ExtensionEntry *extEntry; |
| 389 | |
| 390 | if (RRNScreens == 0) |
| 391 | return; |
| 392 | |
| 393 | if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT, |
| 394 | sizeof(RRClientRec) + |
| 395 | screenInfo.numScreens * sizeof(RRTimesRec))) |
| 396 | return; |
| 397 | if (!AddCallback(&ClientStateCallback, RRClientCallback, 0)) |
| 398 | return; |
| 399 | |
| 400 | RRClientType = CreateNewResourceType(RRFreeClient, "RandRClient"); |
| 401 | if (!RRClientType) |
| 402 | return; |
| 403 | RREventType = CreateNewResourceType(RRFreeEvents, "RandREvent"); |
| 404 | if (!RREventType) |
| 405 | return; |
| 406 | extEntry = AddExtension(RANDR_NAME"RANDR", RRNumberEvents2, RRNumberErrors4, |
| 407 | ProcRRDispatch, SProcRRDispatch, |
| 408 | NULL((void*)0), StandardMinorOpcode); |
| 409 | if (!extEntry) |
| 410 | return; |
| 411 | RRErrorBase = extEntry->errorBase; |
| 412 | RREventBase = extEntry->eventBase; |
| 413 | EventSwapVector[RREventBase + RRScreenChangeNotify0] = (EventSwapPtr) |
| 414 | SRRScreenChangeNotifyEvent; |
| 415 | EventSwapVector[RREventBase + RRNotify1] = (EventSwapPtr) |
| 416 | SRRNotifyEvent; |
| 417 | |
| 418 | RRModeInitErrorValue(); |
| 419 | RRCrtcInitErrorValue(); |
| 420 | RROutputInitErrorValue(); |
| 421 | RRProviderInitErrorValue(); |
| 422 | #ifdef PANORAMIX1 |
| 423 | RRXineramaExtensionInit(); |
| 424 | #endif |
| 425 | } |
| 426 | |
| 427 | void |
| 428 | RRResourcesChanged(ScreenPtr pScreen) |
| 429 | { |
| 430 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 431 | pScrPriv->resourcesChanged = TRUE1; |
| 432 | |
| 433 | RRSetChanged(pScreen); |
| 434 | } |
| 435 | |
| 436 | static void |
| 437 | RRDeliverResourceEvent(ClientPtr client, WindowPtr pWin) |
| 438 | { |
| 439 | ScreenPtr pScreen = pWin->drawable.pScreen; |
| 440 | |
| 441 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 442 | |
| 443 | xRRResourceChangeNotifyEvent re = { |
| 444 | .type = RRNotify1 + RREventBase, |
| 445 | .subCode = RRNotify_ResourceChange5, |
| 446 | .timestamp = pScrPriv->lastSetTime.milliseconds, |
| 447 | .window = pWin->drawable.id |
| 448 | }; |
| 449 | |
| 450 | WriteEventsToClient(client, 1, (xEvent *) &re); |
| 451 | } |
| 452 | |
| 453 | static int |
| 454 | TellChanged(WindowPtr pWin, void *value) |
| 455 | { |
| 456 | RREventPtr *pHead, pRREvent; |
| 457 | ClientPtr client; |
| 458 | ScreenPtr pScreen = pWin->drawable.pScreen; |
| 459 | ScreenPtr iter; |
| 460 | rrScrPrivPtr pSlaveScrPriv; |
| 461 | |
| 462 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 463 | int i; |
| 464 | |
| 465 | dixLookupResourceByType((void **) &pHead, pWin->drawable.id, |
| 466 | RREventType, serverClient, DixReadAccess(1<<0)); |
| 467 | if (!pHead) |
| 468 | return WT_WALKCHILDREN1; |
| 469 | |
| 470 | for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next) { |
| 471 | client = pRREvent->client; |
| 472 | if (client == serverClient || client->clientGone) |
| 473 | continue; |
| 474 | |
| 475 | if (pRREvent->mask & RRScreenChangeNotifyMask(1L << 0)) |
| 476 | RRDeliverScreenEvent(client, pWin, pScreen); |
| 477 | |
| 478 | if (pRREvent->mask & RRCrtcChangeNotifyMask(1L << 1)) { |
| 479 | for (i = 0; i < pScrPriv->numCrtcs; i++) { |
| 480 | RRCrtcPtr crtc = pScrPriv->crtcs[i]; |
| 481 | |
| 482 | if (crtc->changed) |
| 483 | RRDeliverCrtcEvent(client, pWin, crtc); |
| 484 | } |
| 485 | |
| 486 | xorg_list_for_each_entry(iter, &pScreen->output_slave_list, output_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& pScreen->output_slave_list)->next) - __builtin_offsetof (typeof(*iter), output_head)); &iter->output_head != ( &pScreen->output_slave_list); iter = (typeof(*iter) *) ((char *)(iter->output_head.next) - __builtin_offsetof(typeof (*iter), output_head))) { |
| 487 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 488 | for (i = 0; i < pSlaveScrPriv->numCrtcs; i++) { |
| 489 | RRCrtcPtr crtc = pSlaveScrPriv->crtcs[i]; |
| 490 | |
| 491 | if (crtc->changed) |
| 492 | RRDeliverCrtcEvent(client, pWin, crtc); |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | if (pRREvent->mask & RROutputChangeNotifyMask(1L << 2)) { |
| 498 | for (i = 0; i < pScrPriv->numOutputs; i++) { |
| 499 | RROutputPtr output = pScrPriv->outputs[i]; |
| 500 | |
| 501 | if (output->changed) |
| 502 | RRDeliverOutputEvent(client, pWin, output); |
| 503 | } |
| 504 | |
| 505 | xorg_list_for_each_entry(iter, &pScreen->output_slave_list, output_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& pScreen->output_slave_list)->next) - __builtin_offsetof (typeof(*iter), output_head)); &iter->output_head != ( &pScreen->output_slave_list); iter = (typeof(*iter) *) ((char *)(iter->output_head.next) - __builtin_offsetof(typeof (*iter), output_head))) { |
| 506 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 507 | for (i = 0; i < pSlaveScrPriv->numOutputs; i++) { |
| 508 | RROutputPtr output = pSlaveScrPriv->outputs[i]; |
| 509 | |
| 510 | if (output->changed) |
| 511 | RRDeliverOutputEvent(client, pWin, output); |
| 512 | } |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | if (pRREvent->mask & RRProviderChangeNotifyMask(1L << 4)) { |
| 517 | xorg_list_for_each_entry(iter, &pScreen->output_slave_list, output_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& pScreen->output_slave_list)->next) - __builtin_offsetof (typeof(*iter), output_head)); &iter->output_head != ( &pScreen->output_slave_list); iter = (typeof(*iter) *) ((char *)(iter->output_head.next) - __builtin_offsetof(typeof (*iter), output_head))) { |
| 518 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 519 | if (pSlaveScrPriv->provider->changed) |
| 520 | RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider); |
| 521 | } |
| 522 | xorg_list_for_each_entry(iter, &pScreen->offload_slave_list, offload_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& pScreen->offload_slave_list)->next) - __builtin_offsetof (typeof(*iter), offload_head)); &iter->offload_head != (&pScreen->offload_slave_list); iter = (typeof(*iter) *)((char *)(iter->offload_head.next) - __builtin_offsetof (typeof(*iter), offload_head))) { |
| 523 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 524 | if (pSlaveScrPriv->provider->changed) |
| 525 | RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider); |
| 526 | } |
| 527 | xorg_list_for_each_entry(iter, &pScreen->unattached_list, unattached_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& pScreen->unattached_list)->next) - __builtin_offsetof(typeof (*iter), unattached_head)); &iter->unattached_head != ( &pScreen->unattached_list); iter = (typeof(*iter) *)(( char *)(iter->unattached_head.next) - __builtin_offsetof(typeof (*iter), unattached_head))) { |
| 528 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 529 | if (pSlaveScrPriv->provider->changed) |
| 530 | RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | if (pRREvent->mask & RRResourceChangeNotifyMask(1L << 6)) { |
| 535 | if (pScrPriv->resourcesChanged) { |
| 536 | RRDeliverResourceEvent(client, pWin); |
| 537 | } |
| 538 | } |
| 539 | } |
| 540 | return WT_WALKCHILDREN1; |
| 541 | } |
| 542 | |
| 543 | void |
| 544 | RRSetChanged(ScreenPtr pScreen) |
| 545 | { |
| 546 | /* set changed bits on the master screen only */ |
| 547 | ScreenPtr master; |
| 548 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 549 | rrScrPrivPtr mastersp; |
| 550 | |
| 551 | if (pScreen->isGPU) { |
| 552 | master = pScreen->current_master; |
| 553 | if (!master) |
| 554 | return; |
| 555 | mastersp = rrGetScrPriv(master)((rrScrPrivPtr)dixLookupPrivate(&(master)->devPrivates , (&rrPrivKeyRec))); |
| 556 | } |
| 557 | else { |
| 558 | master = pScreen; |
Value stored to 'master' is never read | |
| 559 | mastersp = pScrPriv; |
| 560 | } |
| 561 | |
| 562 | mastersp->changed = TRUE1; |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | * Something changed; send events and adjust pointer position |
| 567 | */ |
| 568 | void |
| 569 | RRTellChanged(ScreenPtr pScreen) |
| 570 | { |
| 571 | ScreenPtr master; |
| 572 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 573 | rrScrPrivPtr mastersp; |
| 574 | int i; |
| 575 | ScreenPtr iter; |
| 576 | rrScrPrivPtr pSlaveScrPriv; |
| 577 | |
| 578 | if (pScreen->isGPU) { |
| 579 | master = pScreen->current_master; |
| 580 | mastersp = rrGetScrPriv(master)((rrScrPrivPtr)dixLookupPrivate(&(master)->devPrivates , (&rrPrivKeyRec))); |
| 581 | } |
| 582 | else { |
| 583 | master = pScreen; |
| 584 | mastersp = pScrPriv; |
| 585 | } |
| 586 | |
| 587 | if (mastersp->changed) { |
| 588 | UpdateCurrentTimeIf(); |
| 589 | if (mastersp->configChanged) { |
| 590 | mastersp->lastConfigTime = currentTime; |
| 591 | mastersp->configChanged = FALSE0; |
| 592 | } |
| 593 | pScrPriv->changed = FALSE0; |
| 594 | mastersp->changed = FALSE0; |
| 595 | |
| 596 | WalkTree(master, TellChanged, (void *) master); |
| 597 | |
| 598 | mastersp->resourcesChanged = FALSE0; |
| 599 | |
| 600 | for (i = 0; i < pScrPriv->numOutputs; i++) |
| 601 | pScrPriv->outputs[i]->changed = FALSE0; |
| 602 | for (i = 0; i < pScrPriv->numCrtcs; i++) |
| 603 | pScrPriv->crtcs[i]->changed = FALSE0; |
| 604 | |
| 605 | xorg_list_for_each_entry(iter, &master->output_slave_list, output_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& master->output_slave_list)->next) - __builtin_offsetof( typeof(*iter), output_head)); &iter->output_head != (& master->output_slave_list); iter = (typeof(*iter) *)((char *)(iter->output_head.next) - __builtin_offsetof(typeof(*iter ), output_head))) { |
| 606 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 607 | pSlaveScrPriv->provider->changed = FALSE0; |
| 608 | for (i = 0; i < pSlaveScrPriv->numOutputs; i++) |
| 609 | pSlaveScrPriv->outputs[i]->changed = FALSE0; |
| 610 | for (i = 0; i < pSlaveScrPriv->numCrtcs; i++) |
| 611 | pSlaveScrPriv->crtcs[i]->changed = FALSE0; |
| 612 | } |
| 613 | xorg_list_for_each_entry(iter, &master->offload_slave_list, offload_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& master->offload_slave_list)->next) - __builtin_offsetof (typeof(*iter), offload_head)); &iter->offload_head != (&master->offload_slave_list); iter = (typeof(*iter) * )((char *)(iter->offload_head.next) - __builtin_offsetof(typeof (*iter), offload_head))) { |
| 614 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 615 | pSlaveScrPriv->provider->changed = FALSE0; |
| 616 | } |
| 617 | xorg_list_for_each_entry(iter, &master->unattached_list, unattached_head)for (iter = ((void*)0), iter = (typeof(*iter) *)((char *)((& master->unattached_list)->next) - __builtin_offsetof(typeof (*iter), unattached_head)); &iter->unattached_head != ( &master->unattached_list); iter = (typeof(*iter) *)((char *)(iter->unattached_head.next) - __builtin_offsetof(typeof (*iter), unattached_head))) { |
| 618 | pSlaveScrPriv = rrGetScrPriv(iter)((rrScrPrivPtr)dixLookupPrivate(&(iter)->devPrivates, ( &rrPrivKeyRec))); |
| 619 | pSlaveScrPriv->provider->changed = FALSE0; |
| 620 | } |
| 621 | |
| 622 | if (mastersp->layoutChanged) { |
| 623 | pScrPriv->layoutChanged = FALSE0; |
| 624 | RRPointerScreenConfigured(master); |
| 625 | RRSendConfigNotify(master); |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | /* |
| 631 | * Return the first output which is connected to an active CRTC |
| 632 | * Used in emulating 1.0 behaviour |
| 633 | */ |
| 634 | RROutputPtr |
| 635 | RRFirstOutput(ScreenPtr pScreen) |
| 636 | { |
| 637 | rrScrPriv(pScreen)rrScrPrivPtr pScrPriv = ((rrScrPrivPtr)dixLookupPrivate(& (pScreen)->devPrivates, (&rrPrivKeyRec))); |
| 638 | RROutputPtr output; |
| 639 | int i, j; |
| 640 | |
| 641 | if (!pScrPriv) |
| 642 | return NULL((void*)0); |
| 643 | |
| 644 | if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) |
| 645 | return pScrPriv->primaryOutput; |
| 646 | |
| 647 | for (i = 0; i < pScrPriv->numCrtcs; i++) { |
| 648 | RRCrtcPtr crtc = pScrPriv->crtcs[i]; |
| 649 | |
| 650 | for (j = 0; j < pScrPriv->numOutputs; j++) { |
| 651 | output = pScrPriv->outputs[j]; |
| 652 | if (output->crtc == crtc) |
| 653 | return output; |
| 654 | } |
| 655 | } |
| 656 | return NULL((void*)0); |
| 657 | } |
| 658 | |
| 659 | CARD16 |
| 660 | RRVerticalRefresh(xRRModeInfo * mode) |
| 661 | { |
| 662 | CARD32 refresh; |
| 663 | CARD32 dots = mode->hTotal * mode->vTotal; |
| 664 | |
| 665 | if (!dots) |
| 666 | return 0; |
| 667 | refresh = (mode->dotClock + dots / 2) / dots; |
| 668 | if (refresh > 0xffff) |
| 669 | refresh = 0xffff; |
| 670 | return (CARD16) refresh; |
| 671 | } |
| 672 | |
| 673 | static int |
| 674 | ProcRRDispatch(ClientPtr client) |
| 675 | { |
| 676 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; |
| 677 | if (stuff->data >= RRNumberRequests45 || !ProcRandrVector[stuff->data]) |
| 678 | return BadRequest1; |
| 679 | UpdateCurrentTimeIf(); |
| 680 | return (*ProcRandrVector[stuff->data]) (client); |
| 681 | } |
| 682 | |
| 683 | static int |
| 684 | SProcRRDispatch(ClientPtr client) |
| 685 | { |
| 686 | REQUEST(xReq)xReq *stuff = (xReq *)client->requestBuffer; |
| 687 | if (stuff->data >= RRNumberRequests45 || !SProcRandrVector[stuff->data]) |
| 688 | return BadRequest1; |
| 689 | UpdateCurrentTimeIf(); |
| 690 | return (*SProcRandrVector[stuff->data]) (client); |
| 691 | } |