randr: send RRResourceChangeNotify event

Send RRResourceChangeNotify event when provider, output or crtc was created or
destroyed. I.e. when the list of resources returned by RRGetScreenResources and
RRGetProviders changes.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Michal Srb <msrb@suse.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Michal Srb 2013-10-30 13:33:50 +02:00 committed by Keith Packard
parent 4b39ea8a91
commit a9ca93dcf9
5 changed files with 54 additions and 0 deletions

View File

@ -466,6 +466,9 @@ xf86platformAddDevice(int index)
/* attach unbound to 0 protocol screen */
AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
RRResourcesChanged(xf86Screens[0]->pScreen);
RRTellChanged(xf86Screens[0]->pScreen);
return 0;
}
@ -508,6 +511,8 @@ xf86platformRemoveDevice(int index)
xf86UnclaimPlatformSlot(&xf86_platform_devices[index], NULL);
xf86_remove_platform_device(index);
RRResourcesChanged(xf86Screens[0]->pScreen);
RRTellChanged(xf86Screens[0]->pScreen);
out:
return;

View File

@ -420,6 +420,32 @@ RRExtensionInit(void)
#endif
}
void
RRResourcesChanged(ScreenPtr pScreen)
{
rrScrPriv(pScreen);
pScrPriv->resourcesChanged = TRUE;
RRSetChanged(pScreen);
}
static void
RRDeliverResourceEvent(ClientPtr client, WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
rrScrPriv(pScreen);
xRRResourceChangeNotifyEvent re = {
.type = RRNotify + RREventBase,
.subCode = RRNotify_ResourceChange,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.window = pWin->drawable.id
};
WriteEventsToClient(client, 1, (xEvent *) &re);
}
static int
TellChanged(WindowPtr pWin, pointer value)
{
@ -480,6 +506,12 @@ TellChanged(WindowPtr pWin, pointer value)
RRDeliverProviderEvent(client, pWin, pSlaveScrPriv->provider);
}
}
if (pRREvent->mask & RRResourceChangeNotifyMask) {
if (pScrPriv->resourcesChanged) {
RRDeliverResourceEvent(client, pWin);
}
}
}
return WT_WALKCHILDREN;
}
@ -536,7 +568,11 @@ RRTellChanged(ScreenPtr pScreen)
}
pScrPriv->changed = FALSE;
mastersp->changed = FALSE;
WalkTree(master, TellChanged, (pointer) master);
mastersp->resourcesChanged = FALSE;
for (i = 0; i < pScrPriv->numOutputs; i++)
pScrPriv->outputs[i]->changed = FALSE;
for (i = 0; i < pScrPriv->numCrtcs; i++)

View File

@ -301,6 +301,7 @@ typedef struct _rrScrPriv {
Bool changed; /* some config changed */
Bool configChanged; /* configuration changed */
Bool layoutChanged; /* screen layout changed */
Bool resourcesChanged; /* screen resources change */
CARD16 minWidth, minHeight;
CARD16 maxWidth, maxHeight;
@ -486,6 +487,9 @@ extern _X_EXPORT int
extern _X_EXPORT void
RRDeliverScreenEvent(ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
extern _X_EXPORT void
RRResourcesChanged(ScreenPtr pScreen);
/* randr.c */
/* set a screen change on the primary screen */
extern _X_EXPORT void

View File

@ -102,6 +102,8 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
crtc->pScreen = pScreen;
pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
RRResourcesChanged(pScreen);
return crtc;
}
@ -669,6 +671,8 @@ RRCrtcDestroyResource(pointer value, XID pid)
break;
}
}
RRResourcesChanged(pScreen);
}
if (crtc->scanout_pixmap)

View File

@ -101,6 +101,9 @@ RROutputCreate(ScreenPtr pScreen,
return NULL;
pScrPriv->outputs[pScrPriv->numOutputs++] = output;
RRResourcesChanged(pScreen);
return output;
}
@ -355,6 +358,8 @@ RROutputDestroyResource(pointer value, XID pid)
break;
}
}
RRResourcesChanged(pScreen);
}
if (output->modes) {
for (m = 0; m < output->numModes; m++)