diff --git a/dix/property.c b/dix/property.c index 501c54698..77a067896 100644 --- a/dix/property.c +++ b/dix/property.c @@ -61,6 +61,11 @@ SOFTWARE. #include "swaprep.h" #include "xace.h" +#ifdef PANORAMIX +#include "Xext/panoramiX.h" +#include "Xext/panoramiXsrv.h" +#endif + /***************************************************************** * Property Stuff * @@ -109,6 +114,46 @@ dixLookupProperty(PropertyPtr *result, WindowPtr pWin, Atom propertyName, return rc; } +static void +setVRRMode(WindowPtr pWin, WindowVRRMode mode) +{ + SetWindowVRRModeProcPtr proc = pWin->drawable.pScreen->SetWindowVRRMode; + if (proc != NULL) + proc(pWin, mode); +} + +static void +notifyVRRMode(ClientPtr pClient, WindowPtr pWindow, int state, PropertyPtr pProp) +{ + const char *pName = NameForAtom(pProp->propertyName); + if (pName == NULL || strcmp(pName, "_VARIABLE_REFRESH") || pProp->format != 32 || pProp->size != 1) + return; + + WindowVRRMode mode = (WindowVRRMode)(state == PropertyNewValue ? (*((uint32_t*)pProp->data)) : 0); + +#ifdef PANORAMIX + if (!noPanoramiXExtension) { + PanoramiXRes *win; + int rc, j; + + rc = dixLookupResourceByType((void **) &win, pWindow->drawable.id, XRT_WINDOW, + pClient, DixWriteAccess); + if (rc != Success) + goto no_panoramix; + + FOR_NSCREENS_BACKWARD(j) { + WindowPtr pWin; + rc = dixLookupWindow(&pWin, win->info[j].id, pClient, DixSetPropAccess); + if (rc == Success) + setVRRMode(pWin, mode); + } + } + return; +no_panoramix: +#endif + setVRRMode(pWindow, mode); +} + CallbackListPtr PropertyStateCallback; static void @@ -189,6 +234,7 @@ ProcRotateProperties(ClientPtr client) for (i = 0; i < stuff->nAtoms; i++) { j = (i + delta) % stuff->nAtoms; deliverPropertyNotifyEvent(pWin, PropertyNewValue, props[i]); + notifyVRRMode(client, pWin, PropertyNewValue, props[i]); /* Preserve name and devPrivates */ props[j]->type = saved[i].type; @@ -368,8 +414,10 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property, else return rc; - if (sendevent) + if (sendevent) { deliverPropertyNotifyEvent(pWin, PropertyNewValue, pProp); + notifyVRRMode(pClient, pWin, PropertyNewValue, pProp); + } return Success; } @@ -399,6 +447,7 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName) } deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp); + notifyVRRMode(client, pWin, PropertyDelete, pProp); free(pProp->data); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); } @@ -535,7 +584,10 @@ ProcGetProperty(ClientPtr client) }; if (stuff->delete && (reply.bytesAfter == 0)) + { deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp); + notifyVRRMode(client, pWin, PropertyDelete, pProp); + } WriteReplyToClient(client, sizeof(xGenericReply), &reply); if (len) { diff --git a/include/meson.build b/include/meson.build index b6b1c82d6..c95fdfb0f 100644 --- a/include/meson.build +++ b/include/meson.build @@ -324,6 +324,7 @@ conf_data.set('SYSCONS_SUPPORT', supports_syscons ? '1' : false) conf_data.set('WSCONS_SUPPORT', supports_wscons ? '1' : false) conf_data.set('XSERVER_LIBPCIACCESS', get_option('pciaccess') ? '1' : false) conf_data.set('XSERVER_PLATFORM_BUS', build_udev_kms ? '1' : false) +conf_data.set('XSERVER_SCREEN_VRR', '1') configure_file(output : 'dix-config.h', configuration : conf_data) diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 98f47bf51..f2e501aa3 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -90,6 +90,11 @@ typedef struct _ScreenSaverStuff { Bool /*force */ ); } ScreenSaverStuffRec; +typedef enum { + WINDOW_VRR_DISABLED = 0, + WINDOW_VRR_ENABLED, +} WindowVRRMode; + /* * There is a typedef for each screen function pointer so that code that * needs to declare a screen function pointer (e.g. in a screen private @@ -177,6 +182,8 @@ typedef void (*ClipNotifyProcPtr) (WindowPtr /*pWindow */ , int /*dx */ , int /*dy */ ); +typedef void (*SetWindowVRRModeProcPtr) (WindowPtr pWindow, WindowVRRMode mode); + /* pixmap will exist only for the duration of the current rendering operation */ #define CREATE_PIXMAP_USAGE_SCRATCH 1 /* pixmap will be the backing pixmap for a redirected window */ @@ -545,6 +552,7 @@ typedef struct _Screen { ClipNotifyProcPtr ClipNotify; RestackWindowProcPtr RestackWindow; PaintWindowProcPtr PaintWindow; + SetWindowVRRModeProcPtr SetWindowVRRMode; /* Pixmap procedures */