diff --git a/randr/rroutput.c b/randr/rroutput.c index 18003c92e..0af9c47ac 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -374,6 +374,8 @@ RROutputDestroyResource(void *value, XID pid) { RROutputPtr output = (RROutputPtr) value; ScreenPtr pScreen = output->pScreen; + ScreenPtr primary; + rrScrPrivPtr primarysp; int m; if (pScreen) { @@ -394,6 +396,15 @@ RROutputDestroyResource(void *value, XID pid) if (pScrPriv->primaryOutput == output) pScrPriv->primaryOutput = NULL; + if (pScreen->isGPU) { + primary = pScreen->current_primary; + if (primary) { + primarysp = rrGetScrPriv(primary); + if (primarysp->primaryOutput == output) + primarysp->primaryOutput = NULL; + } + } + for (i = 0; i < pScrPriv->numOutputs; i++) { if (pScrPriv->outputs[i] == output) { memmove(pScrPriv->outputs + i, pScrPriv->outputs + i + 1,