sna: Validate rrPrimaryOutput belongs to our Screen

If the randr->rrPrimaryOutput is set to an output on a slave, we have to
reject it in favour of one of our own.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2017-10-12 17:55:03 +01:00
parent a384b462a3
commit d287d46d5c
1 changed files with 7 additions and 5 deletions

View File

@ -7852,12 +7852,14 @@ sna_covering_crtc(struct sna *sna, const BoxRec *box, xf86CrtcPtr desired)
__FUNCTION__, box->x1, box->y1, box->x2, box->y2));
if (desired == NULL) {
rrScrPrivPtr rr = rrGetScrPriv(xf86ScrnToScreen(sna->scrn));
if (rr && rr->primaryOutput) {
ScreenPtr screen = xf86ScrnToScreen(sna->scrn);
rrScrPrivPtr rr = rrGetScrPriv(screen);
if (rr && rr->primaryOutput && rr->primaryOutput->pScreen == screen) {
xf86OutputPtr output = rr->primaryOutput->devPrivate;
DBG(("%s: have PrimaryOutput? %d marking as desired\n", __FUNCTION__, output->crtc != NULL));
desired = output->crtc;
}
assert(!desired || desired->pScreen == screen);
}
if (desired && to_sna_crtc(desired) && to_sna_crtc(desired)->bo) {
BoxRec cover_box;
@ -7895,8 +7897,9 @@ sna_covering_crtc(struct sna *sna, const BoxRec *box, xf86CrtcPtr desired)
return crtc;
}
if (!sna_box_intersect(&cover_box, &crtc->bounds, box))
continue;
coverage = 0;
if (sna_box_intersect(&cover_box, &crtc->bounds, box))
coverage = sna_box_area(&cover_box);
DBG(("%s: box instersects (%d, %d), (%d, %d) of crtc %d\n",
__FUNCTION__,
@ -7904,7 +7907,6 @@ sna_covering_crtc(struct sna *sna, const BoxRec *box, xf86CrtcPtr desired)
cover_box.x2, cover_box.y2,
c));
coverage = sna_box_area(&cover_box);
DBG(("%s: box covers %d of crtc %d\n",
__FUNCTION__, coverage, c));
if (coverage > best_coverage) {