void* vncRandRSetPreferredMode(void* out, void* m) { RRModePtr mode; RROutputPtr output; int width, height; mode = m; output = out; width = mode->mode.width; height = mode->mode.height; /* Already the preferred mode? */ if ((output->numModes >= 1) && (output->numPreferred == 1) && (output->modes[0] == mode)) return mode; /* Recreate the list, with the mode we want as preferred */ vncRandRSetModes(output, width, height); /* Sanity check */ if ((output->numModes >= 1) && (output->numPreferred == 1) && (output->modes[0]->mode.width == width) && (output->modes[0]->mode.height == height)) return output->modes[0]; /* Something went horribly wrong */ return NULL; }
static RRCrtcPtr vncRandRCrtcCreate(ScreenPtr pScreen) { RRCrtcPtr crtc; RROutputPtr output; char name[100]; /* First we create the CRTC... */ crtc = RRCrtcCreate(pScreen, NULL); /* We don't actually support gamma, but xrandr complains when it is missing */ RRCrtcGammaSetSize (crtc, 256); /* Then we create a dummy output for it... */ sprintf(name, "VNC-%d", vncRandRIndex); vncRandRIndex++; output = RROutputCreate(pScreen, name, strlen(name), NULL); RROutputSetCrtcs(output, &crtc, 1); RROutputSetConnection(output, RR_Disconnected); /* Make sure the CRTC has this output set */ vncRandRCrtcSet(pScreen, crtc, NULL, 0, 0, RR_Rotate_0, 1, &output); /* Populate a list of default modes */ vncRandRSetModes(output, -1, -1); return crtc; }
void* vncRandRCreateMode(void* out, int width, int height) { RROutputPtr output; output = out; /* Do we already have the mode? */ for (int i = 0; i < output->numModes; i++) { if ((output->modes[i]->mode.width == width) && (output->modes[i]->mode.height == height)) return output->modes[i]; } /* Just recreate the entire list */ vncRandRSetModes(output, width, height); /* Find the new mode */ for (int i = 0; i < output->numModes; i++) { if ((output->modes[i]->mode.width == width) && (output->modes[i]->mode.height == height)) return output->modes[i]; } /* Something went horribly wrong */ return NULL; }
/* Used to create a preferred mode from various places */ void *vncRandRCreatePreferredMode(void *out, int width, int height) { RROutputPtr output; output = out; /* Already the preferred mode? */ if ((output->numModes >= 1) && (output->numPreferred == 1) && (output->modes[0]->mode.width == width) && (output->modes[0]->mode.height == height)) return output->modes[0]; /* Recreate the list, with the mode we want as preferred */ vncRandRSetModes(output, width, height); if ((output->numModes >= 1) && (output->numPreferred == 1) && (output->modes[0]->mode.width == width) && (output->modes[0]->mode.height == height)) return output->modes[0]; return NULL; }