From b2a0de4f072fdcc0fb20a0853f7edaf714add9d9 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 22 Jun 2021 12:39:56 -0400 Subject: [PATCH] xfixes: Allow the client to upgrade the fixes protocol version If you say FixesQueryVersion twice we remember whatever the second version number was. With just libXfixes this isn't an issue because the request is hidden in extension setup, but libxcb-xfixes doesn't do that for you, which means the second one can _lower_ the requested fixes version, disabling requests that the client thought it had enabled. Paper over this by allowing the version number to be raised but not lowered. Also go ahead and delete the minor version number from the client state since xfixes doesn't have minor versions (yet, anyway). --- xfixes/xfixes.c | 14 ++++++++------ xfixes/xfixesint.h | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c index 4ea9171d9..3ba7314a7 100644 --- a/xfixes/xfixes.c +++ b/xfixes/xfixes.c @@ -61,6 +61,7 @@ static DevPrivateKeyRec XFixesClientPrivateKeyRec; static int ProcXFixesQueryVersion(ClientPtr client) { + int major, minor; XFixesClientPtr pXFixesClient = GetXFixesClient(client); xXFixesQueryVersionReply rep = { .type = X_Reply, @@ -75,16 +76,17 @@ ProcXFixesQueryVersion(ClientPtr client) if (version_compare(stuff->majorVersion, stuff->minorVersion, SERVER_XFIXES_MAJOR_VERSION, SERVER_XFIXES_MINOR_VERSION) < 0) { - rep.majorVersion = stuff->majorVersion; - rep.minorVersion = stuff->minorVersion; + major = max(pXFixesClient->major_version, stuff->majorVersion); + minor = stuff->minorVersion; } else { - rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION; - rep.minorVersion = SERVER_XFIXES_MINOR_VERSION; + major = SERVER_XFIXES_MAJOR_VERSION; + minor = SERVER_XFIXES_MINOR_VERSION; } - pXFixesClient->major_version = rep.majorVersion; - pXFixesClient->minor_version = rep.minorVersion; + pXFixesClient->major_version = major; + rep.majorVersion = min(stuff->majorVersion, major); + rep.minorVersion = minor; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h index f597354a0..cf9a8f9bd 100644 --- a/xfixes/xfixesint.h +++ b/xfixes/xfixesint.h @@ -64,7 +64,6 @@ extern int XFixesEventBase; typedef struct _XFixesClient { CARD32 major_version; - CARD32 minor_version; } XFixesClientRec, *XFixesClientPtr; #define GetXFixesClient(pClient) ((XFixesClientPtr)dixLookupPrivate(&(pClient)->devPrivates, XFixesClientPrivateKey))