xserver: Branch 'master' - 18 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Feb 24 20:37:50 UTC 2025
randr/randr.c | 38 -------
randr/randrstr_priv.h | 11 +-
randr/rrcrtc.c | 147 ++++++++++++------------------
randr/rrdispatch.c | 128 ++++++++++++++------------
randr/rrinfo.c | 15 +--
randr/rrlease.c | 4
randr/rrmode.c | 7 -
randr/rrmonitor.c | 59 +++++++-----
randr/rroutput.c | 28 -----
randr/rrproperty.c | 114 ++++++++++-------------
randr/rrprovider.c | 56 +++++------
randr/rrproviderproperty.c | 44 ++-------
randr/rrscreen.c | 43 +-------
randr/rrsdispatch.c | 217 +++++++++++++++++++++++----------------------
randr/rrxinerama.c | 32 ++----
15 files changed, 405 insertions(+), 538 deletions(-)
New commits:
commit 6fad884ce7c4767d2dd403ac8dfb8a6a107017ac
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 13:25:06 2024 +0200
randr: RRScreenInit(): drop unnecessary zero'ing
The whole struct is already allocated by calloc(), so no need to explicitly
zero-out individual fields.
Fixes: 479b2be4ba - Clear allocated RandR screen private structure
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/randr.c b/randr/randr.c
index b314f0411..56fb453d2 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -315,7 +315,6 @@ RRScreenInit(ScreenPtr pScreen)
/*
* Calling function best set these function vectors
*/
- pScrPriv->rrGetInfo = 0;
pScrPriv->maxWidth = pScrPriv->minWidth = pScreen->width;
pScrPriv->maxHeight = pScrPriv->minHeight = pScreen->height;
@@ -323,21 +322,11 @@ RRScreenInit(ScreenPtr pScreen)
pScrPriv->height = pScreen->height;
pScrPriv->mmWidth = pScreen->mmWidth;
pScrPriv->mmHeight = pScreen->mmHeight;
-#if RANDR_12_INTERFACE
- pScrPriv->rrScreenSetSize = NULL;
- pScrPriv->rrCrtcSet = NULL;
- pScrPriv->rrCrtcSetGamma = NULL;
-#endif
#if RANDR_10_INTERFACE
- pScrPriv->rrSetConfig = 0;
pScrPriv->rotations = RR_Rotate_0;
pScrPriv->reqWidth = pScreen->width;
pScrPriv->reqHeight = pScreen->height;
- pScrPriv->nSizes = 0;
- pScrPriv->pSizes = NULL;
pScrPriv->rotation = RR_Rotate_0;
- pScrPriv->rate = 0;
- pScrPriv->size = 0;
#endif
/*
@@ -352,10 +341,6 @@ RRScreenInit(ScreenPtr pScreen)
pScreen->ConstrainCursorHarder = RRConstrainCursorHarder;
pScreen->ReplaceScanoutPixmap = RRReplaceScanoutPixmap;
- pScrPriv->numOutputs = 0;
- pScrPriv->outputs = NULL;
- pScrPriv->numCrtcs = 0;
- pScrPriv->crtcs = NULL;
xorg_list_init(&pScrPriv->leases);
commit 73467faeb26b2fb628b7c6980c4573c27e0ee955
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 20:01:10 2024 +0200
randr: ProcRRQueryOutputProperty(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.
This also allows even further simplifications by using generic macros
for the request send path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 610f5bb8d..8df9790f1 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -495,14 +495,16 @@ ProcRRQueryOutputProperty(ClientPtr client)
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
- WriteToClient(client, sizeof(xRRQueryOutputPropertyReply), &rep);
if (prop->num_valid) {
memcpy(extra, prop->valid_values, prop->num_valid * sizeof(INT32));
- client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
- WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32),
- extra);
- free(extra);
+ if (client->swapped)
+ SwapLongs((CARD32*)extra, prop->num_valid);
}
+
+ WriteToClient(client, sizeof(xRRQueryOutputPropertyReply), &rep);
+ WriteToClient(client, prop->num_valid * sizeof(INT32), extra);
+ free(extra);
+
return Success;
}
commit e3001b71b31b2cf1327fbc86e6403bc3db044409
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:52:46 2024 +0200
randr: ProcRRListOutputProperties(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.
This also allows even further simplifications by using generic macros
for the request send path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 122f5ab64..610f5bb8d 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -416,7 +416,6 @@ int
ProcRRListOutputProperties(ClientPtr client)
{
REQUEST(xRRListOutputPropertiesReq);
- Atom *pAtoms = NULL;
int numProps = 0;
RROutputPtr output;
RRPropertyPtr prop;
@@ -427,9 +426,6 @@ ProcRRListOutputProperties(ClientPtr client)
for (prop = output->properties; prop; prop = prop->next)
numProps++;
- if (numProps)
- if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
- return BadAlloc;
xRRListOutputPropertiesReply rep = {
.type = X_Reply,
@@ -442,18 +438,25 @@ ProcRRListOutputProperties(ClientPtr client)
swapl(&rep.length);
swaps(&rep.nAtoms);
}
- WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
+ Atom* pAtoms = calloc(sizeof(Atom), numProps);
if (numProps) {
+ if (!pAtoms)
+ return BadAlloc;
+
/* Copy property name atoms to reply buffer */
Atom *temppAtoms = pAtoms;
for (prop = output->properties; prop; prop = prop->next)
*temppAtoms++ = prop->propertyName;
- client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
- WriteSwappedDataToClient(client, numProps * sizeof(Atom), pAtoms);
- free(pAtoms);
+ if (client->swapped)
+ SwapLongs(pAtoms, numProps);
}
+
+ WriteToClient(client, sizeof(xRRListOutputPropertiesReply), &rep);
+ WriteToClient(client, sizeof(Atom) * numProps, pAtoms);
+ free(pAtoms);
+
return Success;
}
commit d9863f7cb0f669e5c0943b6038a656ce34b8ea55
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:48:54 2024 +0200
randr: ProcRRGetCrtcGamma(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.
This also allows even further simplifications by using generic macros
for the request send path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 75ae0eea5..4eaded726 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1676,13 +1676,16 @@ ProcRRGetCrtcGamma(ClientPtr client)
swapl(&reply.length);
swaps(&reply.size);
}
- WriteToClient(client, sizeof(xRRGetCrtcGammaReply), &reply);
if (crtc->gammaSize) {
memcpy(extra, crtc->gammaRed, len);
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
- WriteSwappedDataToClient(client, len, extra);
- free(extra);
+ if (client->swapped)
+ SwapShorts((short*)extra, len/sizeof(CARD16));
}
+
+ WriteToClient(client, sizeof(xRRGetCrtcGammaReply), &reply);
+ WriteToClient(client, len, extra);
+ free(extra);
+
return Success;
}
commit 62b849799983d6154261c6662d5d8c40fafa67f4
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:30:03 2024 +0200
randr: ProcRRGetProviderProperty(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.
This also allows even further simplifications by using generic macros
for the request send path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index 45e9a63e6..23a105c02 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -685,24 +685,26 @@ ProcRRGetProviderProperty(ClientPtr client)
swapl(&reply.bytesAfter);
swapl(&reply.nItems);
}
- WriteToClient(client, sizeof(xGenericReply), &reply);
if (len) {
memcpy(extra, (char *) prop_value->data + ind, len);
switch (reply.format) {
case 32:
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
+ if (client->swapped)
+ SwapLongs((CARD32*) extra, len/sizeof(CARD32));
break;
case 16:
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
+ if (client->swapped)
+ SwapShorts((short*) extra, len/sizeof(CARD16));
break;
default:
- client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
break;
}
- WriteSwappedDataToClient(client, len, extra);
- free(extra);
}
+ WriteToClient(client, sizeof(xGenericReply), &reply);
+ WriteToClient(client, len, extra);
+ free(extra);
+
if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next;
RRDestroyProviderProperty(prop);
commit 8789be52a4ce4a285636f8c4efc2bd196fe571a2
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:11:13 2024 +0200
randr: ProcRRGetOutputProperty(): use SwapShort()/SwapLong()
Simplify reply payload preparation and sendout by using SwapShort()
and SwapLong() instead of WriteToClientSwapped() and callbacks.
This also allows even further simplifications by using generic macros
for the request send path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 315e5b275..122f5ab64 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -727,24 +727,26 @@ ProcRRGetOutputProperty(ClientPtr client)
swapl(&rep.bytesAfter);
swapl(&rep.nItems);
}
- WriteToClient(client, sizeof(rep), &rep);
if (len) {
memcpy(extra, (char *) prop_value->data + ind, len);
switch (rep.format) {
case 32:
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
+ if (client->swapped)
+ SwapLongs((CARD32*)extra, len / sizeof(CARD32));
break;
case 16:
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write;
+ if (client->swapped)
+ SwapShorts((short*)extra, len / sizeof(CARD16));
break;
default:
- client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
break;
}
- WriteSwappedDataToClient(client, len, extra);
- free(extra);
}
+ WriteToClient(client, sizeof(rep), &rep);
+ WriteToClient(client, len, extra);
+ free(extra);
+
if (stuff->delete && (rep.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next;
RRDestroyOutputProperty(prop);
commit 53d43bd8dcdc17fba6a42809ae67341c5310dc0e
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:06:40 2024 +0200
randr: ProcRRGetOutputProperty(): rename reply struct to "rep"
Harmonize it with all the other reply struct fields, so we can later
use generic macros for final preparation and writeout.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 668dee40c..315e5b275 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -643,16 +643,16 @@ ProcRRGetOutputProperty(ClientPtr client)
if (prop->propertyName == stuff->property)
break;
- xRRGetOutputPropertyReply reply = {
+ xRRGetOutputPropertyReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence
};
if (!prop) {
if (client->swapped) {
- swaps(&reply.sequenceNumber);
+ swaps(&rep.sequenceNumber);
}
- WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
+ WriteToClient(client, sizeof(rep), &rep);
return Success;
}
@@ -668,15 +668,15 @@ ProcRRGetOutputProperty(ClientPtr client)
if (((stuff->type != prop_value->type) && (stuff->type != AnyPropertyType))
) {
- reply.bytesAfter = prop_value->size;
- reply.format = prop_value->format;
- reply.propertyType = prop_value->type;
+ rep.bytesAfter = prop_value->size;
+ rep.format = prop_value->format;
+ rep.propertyType = prop_value->type;
if (client->swapped) {
- swaps(&reply.sequenceNumber);
- swapl(&reply.propertyType);
- swapl(&reply.bytesAfter);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.propertyType);
+ swapl(&rep.bytesAfter);
}
- WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
+ WriteToClient(client, sizeof(rep), &rep);
return Success;
}
@@ -701,14 +701,14 @@ ProcRRGetOutputProperty(ClientPtr client)
if (!extra)
return BadAlloc;
}
- reply.bytesAfter = n - (ind + len);
- reply.format = prop_value->format;
- reply.length = bytes_to_int32(len);
+ rep.bytesAfter = n - (ind + len);
+ rep.format = prop_value->format;
+ rep.length = bytes_to_int32(len);
if (prop_value->format)
- reply.nItems = len / (prop_value->format / 8);
- reply.propertyType = prop_value->type;
+ rep.nItems = len / (prop_value->format / 8);
+ rep.propertyType = prop_value->type;
- if (stuff->delete && (reply.bytesAfter == 0)) {
+ if (stuff->delete && (rep.bytesAfter == 0)) {
xRROutputPropertyNotifyEvent event = {
.type = RREventBase + RRNotify,
.subCode = RRNotify_OutputProperty,
@@ -721,16 +721,16 @@ ProcRRGetOutputProperty(ClientPtr client)
}
if (client->swapped) {
- swaps(&reply.sequenceNumber);
- swapl(&reply.length);
- swapl(&reply.propertyType);
- swapl(&reply.bytesAfter);
- swapl(&reply.nItems);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
+ swapl(&rep.propertyType);
+ swapl(&rep.bytesAfter);
+ swapl(&rep.nItems);
}
- WriteToClient(client, sizeof(xGenericReply), &reply);
+ WriteToClient(client, sizeof(rep), &rep);
if (len) {
memcpy(extra, (char *) prop_value->data + ind, len);
- switch (reply.format) {
+ switch (rep.format) {
case 32:
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
break;
@@ -745,7 +745,7 @@ ProcRRGetOutputProperty(ClientPtr client)
free(extra);
}
- if (stuff->delete && (reply.bytesAfter == 0)) { /* delete the Property */
+ if (stuff->delete && (rep.bytesAfter == 0)) { /* delete the Property */
*prev = prop->next;
RRDestroyOutputProperty(prop);
}
commit 05188ccec1cad52ebe78f67bebcbe85a7a1e27d5
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 19:25:46 2024 +0200
randr: RRCreateProviderProperty(): use calloc()
We can rely on everything being cleared. And usually even faster, as the
compiler can emit optimized instructions for clearing a whole block at once.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index 27444ea8a..45e9a63e6 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -107,16 +107,10 @@ RRCreateProviderProperty(Atom property)
{
RRPropertyPtr prop;
- prop = (RRPropertyPtr) malloc(sizeof(RRPropertyRec));
+ prop = (RRPropertyPtr) calloc(1, sizeof(RRPropertyRec));
if (!prop)
return NULL;
- prop->next = NULL;
prop->propertyName = property;
- prop->is_pending = FALSE;
- prop->range = FALSE;
- prop->immutable = FALSE;
- prop->num_valid = 0;
- prop->valid_values = NULL;
RRInitProviderPropertyValue(&prop->current);
RRInitProviderPropertyValue(&prop->pending);
return prop;
commit 3d3137513a64ab7045198fa8acdae7ec8effa2b9
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 18:23:15 2024 +0200
randr: RROutputCreate(): use calloc()
We can rely on everything being cleared. And usually even faster, as the
compiler can emit optimized instructions for clearing a whole block at once.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 0e414b27b..8d0f05498 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -83,7 +83,7 @@ RROutputCreate(ScreenPtr pScreen,
pScrPriv->outputs = outputs;
- output = malloc(sizeof(RROutputRec) + nameLength + 1);
+ output = calloc(1, sizeof(RROutputRec) + nameLength + 1);
if (!output)
return NULL;
output->id = FakeClientID(0);
@@ -94,22 +94,6 @@ RROutputCreate(ScreenPtr pScreen,
output->name[nameLength] = '\0';
output->connection = RR_UnknownConnection;
output->subpixelOrder = SubPixelUnknown;
- output->mmWidth = 0;
- output->mmHeight = 0;
- output->crtc = NULL;
- output->numCrtcs = 0;
- output->crtcs = NULL;
- output->numClones = 0;
- output->clones = NULL;
- output->numModes = 0;
- output->numPreferred = 0;
- output->modes = NULL;
- output->numUserModes = 0;
- output->userModes = NULL;
- output->properties = NULL;
- output->pendingProperties = FALSE;
- output->changed = FALSE;
- output->nonDesktop = FALSE;
output->devPrivate = devPrivate;
if (!AddResource(output->id, RROutputType, (void *) output))
commit 1bc6ca30a924e36893b0a604051762821163b66a
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 18:23:15 2024 +0200
randr: ProcRRGetMonitors(): collect reply payload in temporary buffer
Instead of arbitrary count of individual WriteToClient() calls on small
chunks, collect the whole payload in a buffer and write it out all at once.
This also makes possible to use generic macros for reply sending, as well
as further simplifications in the write-out path.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c
index db33d117c..661dee32e 100644
--- a/randr/rrmonitor.c
+++ b/randr/rrmonitor.c
@@ -604,11 +604,13 @@ ProcRRGetMonitors(ClientPtr client)
noutputs += monitors[m].numOutputs;
}
+ int payload_len = noutputs * sizeof(CARD32) + nmonitors * sizeof(xRRMonitorInfo);
+
xRRGetMonitorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.timestamp = RRMonitorTimestamp(screen),
- .length = noutputs + nmonitors * bytes_to_int32(sizeof(xRRMonitorInfo)),
+ .length = bytes_to_int32(payload_len),
.nmonitors = nmonitors,
.noutputs = noutputs,
};
@@ -622,9 +624,18 @@ ProcRRGetMonitors(ClientPtr client)
}
WriteToClient(client, sizeof(xRRGetMonitorsReply), &rep);
+ char *payload_buf = calloc(1, payload_len);
+ if (!payload_buf) {
+ RRMonitorFreeList(monitors, nmonitors);
+ return BadAlloc;
+ }
+
+ char *walk = payload_buf;
+
for (m = 0; m < nmonitors; m++) {
RRMonitorPtr monitor = &monitors[m];
- xRRMonitorInfo info = {
+ xRRMonitorInfo *info = (xRRMonitorInfo*) walk;
+ *info = (xRRMonitorInfo) {
.name = monitor->name,
.primary = monitor->primary,
.automatic = monitor->automatic,
@@ -637,26 +648,27 @@ ProcRRGetMonitors(ClientPtr client)
.heightInMillimeters = monitor->geometry.mmHeight,
};
if (client->swapped) {
- swapl(&info.name);
- swaps(&info.noutput);
- swaps(&info.x);
- swaps(&info.y);
- swaps(&info.width);
- swaps(&info.height);
- swapl(&info.widthInMillimeters);
- swapl(&info.heightInMillimeters);
+ swapl(&info->name);
+ swaps(&info->noutput);
+ swaps(&info->x);
+ swaps(&info->y);
+ swaps(&info->width);
+ swaps(&info->height);
+ swapl(&info->widthInMillimeters);
+ swapl(&info->heightInMillimeters);
}
- RROutput outputs[monitor->numOutputs];
- memcpy(outputs, monitor->outputs, monitor->numOutputs * sizeof (RROutput));
-
+ walk += sizeof(xRRMonitorInfo);
+ memcpy(walk, monitor->outputs, monitor->numOutputs * sizeof (RROutput));
if (client->swapped)
- SwapLongs(outputs, monitor->numOutputs);
+ SwapLongs((CARD32*)walk, monitor->numOutputs);
- WriteToClient(client, sizeof(xRRMonitorInfo), &info);
- WriteToClient(client, sizeof(outputs), outputs);
+ walk += monitor->numOutputs * sizeof (RROutput);
}
+ WriteToClient(client, payload_len, payload_buf);
+
+ free(payload_buf);
RRMonitorFreeList(monitors, nmonitors);
return Success;
commit 203f59c6d3a47b0cf4be6cff7ca9ef99c9933f00
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 17:48:36 2024 +0200
randr: ProcRRGetMonitors() use SwapLongs instead of callbacks
WriteSwappedDataToClient() calls a callback on each single field.
We can have it easier and more efficient by just using SwapLongs()
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c
index c77978e33..db33d117c 100644
--- a/randr/rrmonitor.c
+++ b/randr/rrmonitor.c
@@ -622,8 +622,6 @@ ProcRRGetMonitors(ClientPtr client)
}
WriteToClient(client, sizeof(xRRGetMonitorsReply), &rep);
- client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
-
for (m = 0; m < nmonitors; m++) {
RRMonitorPtr monitor = &monitors[m];
xRRMonitorInfo info = {
@@ -649,8 +647,14 @@ ProcRRGetMonitors(ClientPtr client)
swapl(&info.heightInMillimeters);
}
+ RROutput outputs[monitor->numOutputs];
+ memcpy(outputs, monitor->outputs, monitor->numOutputs * sizeof (RROutput));
+
+ if (client->swapped)
+ SwapLongs(outputs, monitor->numOutputs);
+
WriteToClient(client, sizeof(xRRMonitorInfo), &info);
- WriteSwappedDataToClient(client, monitor->numOutputs * sizeof (RROutput), monitor->outputs);
+ WriteToClient(client, sizeof(outputs), outputs);
}
RRMonitorFreeList(monitors, nmonitors);
commit c6f1b8a735d3c6ba80ca552b79e2dbe8a358ff40
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 17:33:15 2024 +0200
randr: ProcRRGetCrtcTransform(): split reply header and payload
Using struct initializer for the reply header and only allocating the
payload on heap. This allows using generic macros for reply preparation
and send-out later.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index c0127534a..75ae0eea5 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1752,8 +1752,6 @@ ProcRRSetCrtcTransform(ClientPtr client)
filter, nbytes, params, nparams);
}
-#define CrtcTransformExtra (SIZEOF(xRRGetCrtcTransformReply) - 32)
-
static int
transform_filter_length(RRTransformPtr transform)
{
@@ -1808,11 +1806,9 @@ int
ProcRRGetCrtcTransform(ClientPtr client)
{
REQUEST(xRRGetCrtcTransformReq);
- xRRGetCrtcTransformReply *reply;
RRCrtcPtr crtc;
int nextra;
RRTransformPtr current, pending;
- char *extra;
REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
@@ -1823,33 +1819,36 @@ ProcRRGetCrtcTransform(ClientPtr client)
nextra = (transform_filter_length(pending) +
transform_filter_length(current));
- reply = calloc(1, sizeof(xRRGetCrtcTransformReply) + nextra);
- if (!reply)
+ char *extra_buf = calloc(1, nextra);
+ if (!extra_buf)
return BadAlloc;
- extra = (char *) (reply + 1);
- reply->type = X_Reply;
- reply->sequenceNumber = client->sequence;
- reply->length = bytes_to_int32(CrtcTransformExtra + nextra);
+ char *extra = extra_buf;
- reply->hasTransforms = crtc->transforms;
+ xRRGetCrtcTransformReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(sizeof(xRRGetCrtcTransformReply) - sizeof(xReq)),
+ .hasTransforms = crtc->transforms,
+ };
- transform_encode(client, &reply->pendingTransform, &pending->transform);
+ transform_encode(client, &rep.pendingTransform, &pending->transform);
extra += transform_filter_encode(client, extra,
- &reply->pendingNbytesFilter,
- &reply->pendingNparamsFilter, pending);
+ &rep.pendingNbytesFilter,
+ &rep.pendingNparamsFilter, pending);
- transform_encode(client, &reply->currentTransform, ¤t->transform);
+ transform_encode(client, &rep.currentTransform, ¤t->transform);
extra += transform_filter_encode(client, extra,
- &reply->currentNbytesFilter,
- &reply->currentNparamsFilter, current);
+ &rep.currentNbytesFilter,
+ &rep.currentNparamsFilter, current);
if (client->swapped) {
- swaps(&reply->sequenceNumber);
- swapl(&reply->length);
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
}
- WriteToClient(client, sizeof(xRRGetCrtcTransformReply) + nextra, reply);
- free(reply);
+ WriteToClient(client, sizeof(xRRGetCrtcTransformReply), &rep);
+ WriteToClient(client, nextra, extra_buf);
+ free(extra_buf);
return Success;
}
commit 90abc95c85020a2d2e02246a297d26261dd06c33
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 17:05:28 2024 +0200
randr: ProcRRGetCrtcInfo(): use locally scoped variables
Improve readability by moving the variables into local scopes.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 4feccbb87..c0127534a 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1148,28 +1148,19 @@ ProcRRGetCrtcInfo(ClientPtr client)
RRCrtcPtr crtc;
CARD8 *extra = NULL;
unsigned long extraLen = 0;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- RRModePtr mode;
- RROutput *outputs;
- RROutput *possible;
- int i, j, k;
- int width, height;
- BoxRec panned_area;
- Bool leased;
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
VERIFY_RR_CRTC(stuff->crtc, crtc, DixReadAccess);
- leased = RRCrtcIsLeased(crtc);
+ Bool leased = RRCrtcIsLeased(crtc);
/* All crtcs must be associated with screens before client
* requests are processed
*/
- pScreen = crtc->pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
+ ScreenPtr pScreen = crtc->pScreen;
+ rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen);
- mode = crtc->mode;
+ RRModePtr mode = crtc->mode;
xRRGetCrtcInfoReply rep = {
.type = X_Reply,
@@ -1183,6 +1174,7 @@ ProcRRGetCrtcInfo(ClientPtr client)
rep.rotation = RR_Rotate_0;
rep.rotations = RR_Rotate_0;
} else {
+ BoxRec panned_area;
if (pScrPriv->rrGetPanning &&
pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) &&
(panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1))
@@ -1193,6 +1185,7 @@ ProcRRGetCrtcInfo(ClientPtr client)
rep.height = panned_area.y2 - panned_area.y1;
}
else {
+ int width, height;
RRCrtcGetScanoutSize(crtc, &width, &height);
rep.x = crtc->x;
rep.y = crtc->y;
@@ -1201,9 +1194,9 @@ ProcRRGetCrtcInfo(ClientPtr client)
}
rep.mode = mode ? mode->mode.id : 0;
rep.nOutput = crtc->numOutputs;
- for (i = 0; i < pScrPriv->numOutputs; i++) {
+ for (int i = 0; i < pScrPriv->numOutputs; i++) {
if (!RROutputIsLeased(pScrPriv->outputs[i])) {
- for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
+ for (int j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
if (pScrPriv->outputs[i]->crtcs[j] == crtc)
rep.nPossibleOutput++;
}
@@ -1218,18 +1211,19 @@ ProcRRGetCrtcInfo(ClientPtr client)
return BadAlloc;
}
- outputs = (RROutput *) extra;
- possible = (RROutput *) (outputs + rep.nOutput);
+ RROutput *outputs = (RROutput *) extra;
+ RROutput *possible = (RROutput *) (outputs + rep.nOutput);
- for (i = 0; i < crtc->numOutputs; i++) {
+ for (int i = 0; i < crtc->numOutputs; i++) {
outputs[i] = crtc->outputs[i]->id;
if (client->swapped)
swapl(&outputs[i]);
}
- k = 0;
- for (i = 0; i < pScrPriv->numOutputs; i++) {
+
+ int k = 0;
+ for (int i = 0; i < pScrPriv->numOutputs; i++) {
if (!RROutputIsLeased(pScrPriv->outputs[i])) {
- for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
+ for (int j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
if (pScrPriv->outputs[i]->crtcs[j] == crtc) {
possible[k] = pScrPriv->outputs[i]->id;
if (client->swapped)
commit 7eff742ef2138696c28ca6c234592ff6a24fe788
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 15:47:10 2024 +0200
randr: use struct initializer for reply structs
Improve readability, move the declarations to where they're needed first
and get rid of extra individual assignments. In some cases this should also
allow the compiler to produce a bit more efficient code.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 3974c350d..4feccbb87 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1022,18 +1022,16 @@ static void
RRModeGetScanoutSize(RRModePtr mode, PictTransformPtr transform,
int *width, int *height)
{
- BoxRec box;
-
if (mode == NULL) {
*width = 0;
*height = 0;
return;
}
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = mode->mode.width;
- box.y2 = mode->mode.height;
+ BoxRec box = {
+ .x2 = mode->mode.width,
+ .y2 = mode->mode.height,
+ };
pixman_transform_bounds(transform, &box);
*width = box.x2 - box.x1;
@@ -1147,10 +1145,9 @@ int
ProcRRGetCrtcInfo(ClientPtr client)
{
REQUEST(xRRGetCrtcInfoReq);
- xRRGetCrtcInfoReply rep;
RRCrtcPtr crtc;
CARD8 *extra = NULL;
- unsigned long extraLen;
+ unsigned long extraLen = 0;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
RRModePtr mode;
@@ -1174,22 +1171,17 @@ ProcRRGetCrtcInfo(ClientPtr client)
mode = crtc->mode;
- rep = (xRRGetCrtcInfoReply) {
+ xRRGetCrtcInfoReply rep = {
.type = X_Reply,
.status = RRSetConfigSuccess,
.sequenceNumber = client->sequence,
- .length = 0,
- .timestamp = pScrPriv->lastSetTime.milliseconds
+ .timestamp = pScrPriv->lastSetTime.milliseconds,
+ .rotation = crtc->rotation,
+ .rotations = crtc->rotations,
};
if (leased) {
- rep.x = rep.y = rep.width = rep.height = 0;
- rep.mode = 0;
rep.rotation = RR_Rotate_0;
rep.rotations = RR_Rotate_0;
- rep.nOutput = 0;
- rep.nPossibleOutput = 0;
- rep.length = 0;
- extraLen = 0;
} else {
if (pScrPriv->rrGetPanning &&
pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) &&
@@ -1208,23 +1200,18 @@ ProcRRGetCrtcInfo(ClientPtr client)
rep.height = height;
}
rep.mode = mode ? mode->mode.id : 0;
- rep.rotation = crtc->rotation;
- rep.rotations = crtc->rotations;
rep.nOutput = crtc->numOutputs;
- k = 0;
for (i = 0; i < pScrPriv->numOutputs; i++) {
if (!RROutputIsLeased(pScrPriv->outputs[i])) {
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
if (pScrPriv->outputs[i]->crtcs[j] == crtc)
- k++;
+ rep.nPossibleOutput++;
}
}
- rep.nPossibleOutput = k;
-
- rep.length = rep.nOutput + rep.nPossibleOutput;
+ extraLen = (rep.nOutput + rep.nPossibleOutput) * sizeof(CARD32);
+ rep.length = bytes_to_int32(extraLen);
- extraLen = rep.length << 2;
if (extraLen) {
extra = malloc(extraLen);
if (!extra)
@@ -1283,7 +1270,6 @@ int
ProcRRSetCrtcConfig(ClientPtr client)
{
REQUEST(xRRSetCrtcConfigReq);
- xRRSetCrtcConfigReply rep;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
RRCrtcPtr crtc;
@@ -1475,11 +1461,10 @@ ProcRRSetCrtcConfig(ClientPtr client)
sendReply:
free(outputs);
- rep = (xRRSetCrtcConfigReply) {
+ xRRSetCrtcConfigReply rep = {
.type = X_Reply,
.status = status,
.sequenceNumber = client->sequence,
- .length = 0,
.newTimestamp = pScrPriv->lastSetTime.milliseconds
};
@@ -1497,7 +1482,6 @@ int
ProcRRGetPanning(ClientPtr client)
{
REQUEST(xRRGetPanningReq);
- xRRGetPanningReply rep;
RRCrtcPtr crtc;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
@@ -1517,7 +1501,7 @@ ProcRRGetPanning(ClientPtr client)
if (!pScrPriv)
return RRErrorBase + BadRRCrtc;
- rep = (xRRGetPanningReply) {
+ xRRGetPanningReply rep = {
.type = X_Reply,
.status = RRSetConfigSuccess,
.sequenceNumber = client->sequence,
@@ -1641,7 +1625,6 @@ int
ProcRRGetCrtcGammaSize(ClientPtr client)
{
REQUEST(xRRGetCrtcGammaSizeReq);
- xRRGetCrtcGammaSizeReply reply;
RRCrtcPtr crtc;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
@@ -1651,10 +1634,9 @@ ProcRRGetCrtcGammaSize(ClientPtr client)
if (!RRCrtcGammaGet(crtc))
return RRErrorBase + BadRRCrtc;
- reply = (xRRGetCrtcGammaSizeReply) {
+ xRRGetCrtcGammaSizeReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.size = crtc->gammaSize
};
if (client->swapped) {
@@ -1670,7 +1652,6 @@ int
ProcRRGetCrtcGamma(ClientPtr client)
{
REQUEST(xRRGetCrtcGammaReq);
- xRRGetCrtcGammaReply reply;
RRCrtcPtr crtc;
unsigned long len;
char *extra = NULL;
@@ -1690,7 +1671,7 @@ ProcRRGetCrtcGamma(ClientPtr client)
return BadAlloc;
}
- reply = (xRRGetCrtcGammaReply) {
+ xRRGetCrtcGammaReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(len),
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 866c6f252..c51d510a7 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -42,7 +42,6 @@ ProcRRQueryVersion(ClientPtr client)
xRRQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0
};
REQUEST(xRRQueryVersionReq);
rrClientPriv(client);
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 24245b7b6..68861dd1c 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -250,19 +250,18 @@ RRRegisterSize(ScreenPtr pScreen,
{
rrScrPriv(pScreen);
int i;
- RRScreenSize tmp;
RRScreenSizePtr pNew;
if (!pScrPriv)
return 0;
- tmp.id = 0;
- tmp.width = width;
- tmp.height = height;
- tmp.mmWidth = mmWidth;
- tmp.mmHeight = mmHeight;
- tmp.pRates = 0;
- tmp.nRates = 0;
+ RRScreenSize tmp = {
+ .width = width,
+ .height = height,
+ .mmWidth = mmWidth,
+ .mmHeight = mmHeight,
+ };
+
for (i = 0; i < pScrPriv->nSizes; i++)
if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i]))
return &pScrPriv->pSizes[i];
diff --git a/randr/rrlease.c b/randr/rrlease.c
index b6083cd2a..e73307807 100644
--- a/randr/rrlease.c
+++ b/randr/rrlease.c
@@ -213,7 +213,6 @@ int
ProcRRCreateLease(ClientPtr client)
{
REQUEST(xRRCreateLeaseReq);
- xRRCreateLeaseReply rep;
WindowPtr window;
ScreenPtr screen;
rrScrPrivPtr scr_priv;
@@ -334,11 +333,10 @@ leaseReturned:
RRLeaseChangeState(lease, RRLeaseCreating, RRLeaseRunning);
- rep = (xRRCreateLeaseReply) {
+ xRRCreateLeaseReply rep = {
.type = X_Reply,
.nfd = 1,
.sequenceNumber = client->sequence,
- .length = 0,
};
if (client->swapped) {
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 20ff4525d..dbf4daed0 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -286,7 +286,6 @@ int
ProcRRCreateMode(ClientPtr client)
{
REQUEST(xRRCreateModeReq);
- xRRCreateModeReply rep;
WindowPtr pWin;
ScreenPtr pScreen;
xRRModeInfo *modeInfo;
@@ -314,12 +313,12 @@ ProcRRCreateMode(ClientPtr client)
if (!mode)
return error;
- rep = (xRRCreateModeReply) {
+ xRRCreateModeReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.mode = mode->mode.id
- };
+ };
+
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c
index b3712c0ca..c77978e33 100644
--- a/randr/rrmonitor.c
+++ b/randr/rrmonitor.c
@@ -581,11 +581,6 @@ int
ProcRRGetMonitors(ClientPtr client)
{
REQUEST(xRRGetMonitorsReq);
- xRRGetMonitorsReply rep = {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- };
WindowPtr window;
ScreenPtr screen;
int r;
@@ -604,17 +599,19 @@ ProcRRGetMonitors(ClientPtr client)
if (!RRMonitorMakeList(screen, get_active, &monitors, &nmonitors))
return BadAlloc;
- rep.timestamp = RRMonitorTimestamp(screen);
-
noutputs = 0;
for (m = 0; m < nmonitors; m++) {
- rep.length += SIZEOF(xRRMonitorInfo) >> 2;
- rep.length += monitors[m].numOutputs;
noutputs += monitors[m].numOutputs;
}
- rep.nmonitors = nmonitors;
- rep.noutputs = noutputs;
+ xRRGetMonitorsReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .timestamp = RRMonitorTimestamp(screen),
+ .length = noutputs + nmonitors * bytes_to_int32(sizeof(xRRMonitorInfo)),
+ .nmonitors = nmonitors,
+ .noutputs = noutputs,
+ };
if (client->swapped) {
swaps(&rep.sequenceNumber);
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 0b4639aa6..0e414b27b 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -481,15 +481,8 @@ ProcRRGetOutputInfo(ClientPtr client)
.sequenceNumber = client->sequence,
.length = bytes_to_int32(OutputInfoExtra),
.timestamp = pScrPriv->lastSetTime.milliseconds,
- .crtc = None,
- .mmWidth = 0,
- .mmHeight = 0,
.connection = RR_Disconnected,
.subpixelOrder = SubPixelUnknown,
- .nCrtcs = 0,
- .nModes = 0,
- .nPreferred = 0,
- .nClones = 0,
.nameLength = output->nameLength
};
extraLen = bytes_to_int32(rep.nameLength) << 2;
@@ -658,7 +651,6 @@ ProcRRGetOutputPrimary(ClientPtr client)
REQUEST(xRRGetOutputPrimaryReq);
WindowPtr pWin;
rrScrPrivPtr pScrPriv;
- xRRGetOutputPrimaryReply rep;
RROutputPtr primary = NULL;
int rc;
@@ -672,7 +664,7 @@ ProcRRGetOutputPrimary(ClientPtr client)
if (pScrPriv)
primary = pScrPriv->primaryOutput;
- rep = (xRRGetOutputPrimaryReply) {
+ xRRGetOutputPrimaryReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.output = primary ? primary->id : None
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index f97c3464f..668dee40c 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -417,7 +417,6 @@ ProcRRListOutputProperties(ClientPtr client)
{
REQUEST(xRRListOutputPropertiesReq);
Atom *pAtoms = NULL;
- xRRListOutputPropertiesReply rep;
int numProps = 0;
RROutputPtr output;
RRPropertyPtr prop;
@@ -432,7 +431,7 @@ ProcRRListOutputProperties(ClientPtr client)
if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc;
- rep = (xRRListOutputPropertiesReply) {
+ xRRListOutputPropertiesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(numProps * sizeof(Atom)),
@@ -462,7 +461,6 @@ int
ProcRRQueryOutputProperty(ClientPtr client)
{
REQUEST(xRRQueryOutputPropertyReq);
- xRRQueryOutputPropertyReply rep;
RROutputPtr output;
RRPropertyPtr prop;
char *extra = NULL;
@@ -481,7 +479,7 @@ ProcRRQueryOutputProperty(ClientPtr client)
return BadAlloc;
}
- rep = (xRRQueryOutputPropertyReply) {
+ xRRQueryOutputPropertyReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = prop->num_valid,
@@ -620,7 +618,6 @@ ProcRRGetOutputProperty(ClientPtr client)
RRPropertyValuePtr prop_value;
unsigned long n, len, ind;
RROutputPtr output;
- xRRGetOutputPropertyReply reply;
char *extra = NULL;
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
@@ -646,22 +643,14 @@ ProcRRGetOutputProperty(ClientPtr client)
if (prop->propertyName == stuff->property)
break;
- reply = (xRRGetOutputPropertyReply) {
+ xRRGetOutputPropertyReply reply = {
.type = X_Reply,
.sequenceNumber = client->sequence
};
+
if (!prop) {
- reply.nItems = 0;
- reply.length = 0;
- reply.bytesAfter = 0;
- reply.propertyType = None;
- reply.format = 0;
if (client->swapped) {
swaps(&reply.sequenceNumber);
- swapl(&reply.length);
- swapl(&reply.propertyType);
- swapl(&reply.bytesAfter);
- swapl(&reply.nItems);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return Success;
@@ -681,15 +670,11 @@ ProcRRGetOutputProperty(ClientPtr client)
) {
reply.bytesAfter = prop_value->size;
reply.format = prop_value->format;
- reply.length = 0;
- reply.nItems = 0;
reply.propertyType = prop_value->type;
if (client->swapped) {
swaps(&reply.sequenceNumber);
- swapl(&reply.length);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
- swapl(&reply.nItems);
}
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return Success;
@@ -721,8 +706,6 @@ ProcRRGetOutputProperty(ClientPtr client)
reply.length = bytes_to_int32(len);
if (prop_value->format)
reply.nItems = len / (prop_value->format / 8);
- else
- reply.nItems = 0;
reply.propertyType = prop_value->type;
if (stuff->delete && (reply.bytesAfter == 0)) {
diff --git a/randr/rrprovider.c b/randr/rrprovider.c
index 9c874aa37..a142ff617 100644
--- a/randr/rrprovider.c
+++ b/randr/rrprovider.c
@@ -56,7 +56,6 @@ int
ProcRRGetProviders (ClientPtr client)
{
REQUEST(xRRGetProvidersReq);
- xRRGetProvidersReply rep;
WindowPtr pWin;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
@@ -87,36 +86,36 @@ ProcRRGetProviders (ClientPtr client)
if (!pScrPriv)
{
- rep = (xRRGetProvidersReply) {
+ xRRGetProvidersReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.timestamp = currentTime.milliseconds,
- .nProviders = 0
};
+ WriteToClient(client, sizeof(rep), &rep);
+ return Success;
+ }
+
+ extraLen = total_providers * sizeof(CARD32);
+
+ xRRGetProvidersReply rep = {
+ .type = X_Reply,
+ .sequenceNumber = client->sequence,
+ .timestamp = pScrPriv->lastSetTime.milliseconds,
+ .nProviders = total_providers,
+ .length = bytes_to_int32(extraLen),
+ };
+
+ if (extraLen) {
+ extra = malloc(extraLen);
+ if (!extra)
+ return BadAlloc;
+ } else
extra = NULL;
- extraLen = 0;
- } else {
- rep = (xRRGetProvidersReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .timestamp = pScrPriv->lastSetTime.milliseconds,
- .nProviders = total_providers,
- .length = total_providers
- };
- extraLen = rep.length << 2;
- if (extraLen) {
- extra = malloc(extraLen);
- if (!extra)
- return BadAlloc;
- } else
- extra = NULL;
-
- providers = (RRProvider *)extra;
- ADD_PROVIDER(pScreen);
- xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) {
- ADD_PROVIDER(iter);
- }
+
+ providers = (RRProvider *)extra;
+ ADD_PROVIDER(pScreen);
+ xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) {
+ ADD_PROVIDER(iter);
}
if (client->swapped) {
@@ -138,7 +137,6 @@ int
ProcRRGetProviderInfo (ClientPtr client)
{
REQUEST(xRRGetProviderInfoReq);
- xRRGetProviderInfoReply rep;
rrScrPrivPtr pScrPriv, pScrProvPriv;
RRProviderPtr provider;
ScreenPtr pScreen;
@@ -158,17 +156,15 @@ ProcRRGetProviderInfo (ClientPtr client)
pScreen = provider->pScreen;
pScrPriv = rrGetScrPriv(pScreen);
- rep = (xRRGetProviderInfoReply) {
+ xRRGetProviderInfoReply rep = {
.type = X_Reply,
.status = RRSetConfigSuccess,
.sequenceNumber = client->sequence,
- .length = 0,
.capabilities = provider->capabilities,
.nameLength = provider->nameLength,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.nCrtcs = pScrPriv->numCrtcs,
.nOutputs = pScrPriv->numOutputs,
- .nAssociatedProviders = 0
};
/* count associated providers */
diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c
index 69f66ed27..27444ea8a 100644
--- a/randr/rrproviderproperty.c
+++ b/randr/rrproviderproperty.c
@@ -391,7 +391,6 @@ ProcRRListProviderProperties(ClientPtr client)
{
REQUEST(xRRListProviderPropertiesReq);
Atom *pAtoms = NULL, *temppAtoms;
- xRRListProviderPropertiesReply rep;
int numProps = 0;
RRProviderPtr provider;
RRPropertyPtr prop;
@@ -406,7 +405,7 @@ ProcRRListProviderProperties(ClientPtr client)
if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc;
- rep = (xRRListProviderPropertiesReply) {
+ xRRListProviderPropertiesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(numProps * sizeof(Atom)),
@@ -434,7 +433,6 @@ int
ProcRRQueryProviderProperty(ClientPtr client)
{
REQUEST(xRRQueryProviderPropertyReq);
- xRRQueryProviderPropertyReply rep;
RRProviderPtr provider;
RRPropertyPtr prop;
char *extra = NULL;
@@ -452,7 +450,8 @@ ProcRRQueryProviderProperty(ClientPtr client)
if (!extra)
return BadAlloc;
}
- rep = (xRRQueryProviderPropertyReply) {
+
+ xRRQueryProviderPropertyReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = prop->num_valid,
@@ -614,17 +613,8 @@ ProcRRGetProviderProperty(ClientPtr client)
break;
if (!prop) {
- reply.nItems = 0;
- reply.length = 0;
- reply.bytesAfter = 0;
- reply.propertyType = None;
- reply.format = 0;
if (client->swapped) {
swaps(&reply.sequenceNumber);
- swapl(&reply.length);
- swapl(&reply.propertyType);
- swapl(&reply.bytesAfter);
- swapl(&reply.nItems);
}
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success;
@@ -644,15 +634,11 @@ ProcRRGetProviderProperty(ClientPtr client)
) {
reply.bytesAfter = prop_value->size;
reply.format = prop_value->format;
- reply.length = 0;
- reply.nItems = 0;
reply.propertyType = prop_value->type;
if (client->swapped) {
swaps(&reply.sequenceNumber);
- swapl(&reply.length);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
- swapl(&reply.nItems);
}
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success;
@@ -684,8 +670,6 @@ ProcRRGetProviderProperty(ClientPtr client)
reply.length = bytes_to_int32(len);
if (prop_value->format)
reply.nItems = len / (prop_value->format / 8);
- else
- reply.nItems = 0;
reply.propertyType = prop_value->type;
if (stuff->delete && (reply.bytesAfter == 0)) {
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 1403a3cf4..184b30f32 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -76,8 +76,6 @@ RRSendConfigNotify(ScreenPtr pScreen)
xEvent event = {
.u.configureNotify.window = pWin->drawable.id,
.u.configureNotify.aboveSibling = None,
- .u.configureNotify.x = 0,
- .u.configureNotify.y = 0,
/* XXX xinerama stuff ? */
@@ -192,7 +190,6 @@ int
ProcRRGetScreenSizeRange(ClientPtr client)
{
REQUEST(xRRGetScreenSizeRangeReq);
- xRRGetScreenSizeRangeReply rep;
WindowPtr pWin;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
@@ -206,11 +203,9 @@ ProcRRGetScreenSizeRange(ClientPtr client)
pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen);
- rep = (xRRGetScreenSizeRangeReply) {
+ xRRGetScreenSizeRangeReply rep = {
.type = X_Reply,
- .pad = 0,
.sequenceNumber = client->sequence,
- .length = 0
};
if (pScrPriv) {
@@ -372,7 +367,6 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
rrScrPrivPtr pScrPriv;
int num_modes;
RRModePtr *modes;
- xRRGetScreenResourcesReply rep;
unsigned long extraLen;
CARD8 *extra;
RRCrtc *crtcs;
@@ -409,10 +403,10 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
}
pScrPriv = rrGetScrPriv(pScreen);
- rep = (xRRGetScreenResourcesReply) {
+
+ xRRGetScreenResourcesReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
.nCrtcs = total_crtcs,
@@ -491,8 +485,8 @@ rrGetScreenResources(ClientPtr client, Bool query)
WindowPtr pWin;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
+ CARD8 *extra = NULL;
+ unsigned long extraLen = 0;
int i, rc, has_primary = 0;
RRCrtc *crtcs;
RROutput *outputs;
@@ -518,16 +512,9 @@ rrGetScreenResources(ClientPtr client, Bool query)
rep = (xRRGetScreenResourcesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.timestamp = currentTime.milliseconds,
.configTimestamp = currentTime.milliseconds,
- .nCrtcs = 0,
- .nOutputs = 0,
- .nModes = 0,
- .nbytesNames = 0
};
- extra = NULL;
- extraLen = 0;
}
else {
RRModePtr *modes;
@@ -540,16 +527,13 @@ rrGetScreenResources(ClientPtr client, Bool query)
rep = (xRRGetScreenResourcesReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
.nCrtcs = pScrPriv->numCrtcs,
.nOutputs = pScrPriv->numOutputs,
.nModes = num_modes,
- .nbytesNames = 0
};
-
for (i = 0; i < num_modes; i++)
rep.nbytesNames += modes[i]->mode.nameLength;
@@ -762,8 +746,8 @@ ProcRRGetScreenInfo(ClientPtr client)
int rc;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
+ CARD8 *extra = NULL;
+ unsigned long extraLen = 0;
RROutputPtr output;
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
@@ -785,18 +769,11 @@ ProcRRGetScreenInfo(ClientPtr client)
.type = X_Reply,
.setOfRotations = RR_Rotate_0,
.sequenceNumber = client->sequence,
- .length = 0,
.root = pWin->drawable.pScreen->root->drawable.id,
.timestamp = currentTime.milliseconds,
.configTimestamp = currentTime.milliseconds,
- .nSizes = 0,
- .sizeID = 0,
.rotation = RR_Rotate_0,
- .rate = 0,
- .nrateEnts = 0
};
- extra = 0;
- extraLen = 0;
}
else {
int i, j;
@@ -815,7 +792,6 @@ ProcRRGetScreenInfo(ClientPtr client)
.type = X_Reply,
.setOfRotations = output->crtc->rotations,
.sequenceNumber = client->sequence,
- .length = 0,
.root = pWin->drawable.pScreen->root->drawable.id,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds,
@@ -905,7 +881,6 @@ int
ProcRRSetScreenConfig(ClientPtr client)
{
REQUEST(xRRSetScreenConfigReq);
- xRRSetScreenConfigReply rep;
DrawablePtr pDraw;
int rc;
ScreenPtr pScreen;
@@ -1110,12 +1085,10 @@ ProcRRSetScreenConfig(ClientPtr client)
free(pData);
- rep = (xRRSetScreenConfigReply) {
+ xRRSetScreenConfigReply rep = {
.type = X_Reply,
.status = status,
.sequenceNumber = client->sequence,
- .length = 0,
-
.newTimestamp = pScrPriv->lastSetTime.milliseconds,
.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds,
.root = pDraw->pScreen->root->drawable.id,
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index e2f489ae0..22c23a0e9 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -99,7 +99,6 @@ ProcRRXineramaQueryVersion(ClientPtr client)
xPanoramiXQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION,
.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION
};
@@ -120,7 +119,6 @@ ProcRRXineramaGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
WindowPtr pWin;
- xPanoramiXGetStateReply rep;
register int rc;
ScreenPtr pScreen;
rrScrPrivPtr pScrPriv;
@@ -138,11 +136,10 @@ ProcRRXineramaGetState(ClientPtr client)
active = TRUE;
}
- rep = (xPanoramiXGetStateReply) {
+ xPanoramiXGetStateReply rep = {
.type = X_Reply,
.state = active,
.sequenceNumber = client->sequence,
- .length = 0,
.window = stuff->window
};
if (client->swapped) {
@@ -171,7 +168,6 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
WindowPtr pWin;
- xPanoramiXGetScreenCountReply rep;
register int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
@@ -179,11 +175,10 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
if (rc != Success)
return rc;
- rep = (xPanoramiXGetScreenCountReply) {
+ xPanoramiXGetScreenCountReply rep = {
.type = X_Reply,
.ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen),
.sequenceNumber = client->sequence,
- .length = 0,
.window = stuff->window
};
if (client->swapped) {
@@ -201,7 +196,6 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
REQUEST(xPanoramiXGetScreenSizeReq);
WindowPtr pWin, pRoot;
ScreenPtr pScreen;
- xPanoramiXGetScreenSizeReply rep;
register int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
@@ -212,10 +206,9 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
pScreen = pWin->drawable.pScreen;
pRoot = pScreen->root;
- rep = (xPanoramiXGetScreenSizeReply) {
+ xPanoramiXGetScreenSizeReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
- .length = 0,
.width = pRoot->drawable.width,
.height = pRoot->drawable.height,
.window = stuff->window,
@@ -236,13 +229,11 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
int
ProcRRXineramaIsActive(ClientPtr client)
{
- xXineramaIsActiveReply rep;
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
- rep = (xXineramaIsActiveReply) {
+ xXineramaIsActiveReply rep = {
.type = X_Reply,
- .length = 0,
.sequenceNumber = client->sequence,
.state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN])
};
@@ -258,12 +249,12 @@ ProcRRXineramaIsActive(ClientPtr client)
static void
RRXineramaWriteMonitor(ClientPtr client, RRMonitorPtr monitor)
{
- xXineramaScreenInfo scratch;
-
- scratch.x_org = monitor->geometry.box.x1;
- scratch.y_org = monitor->geometry.box.y1;
- scratch.width = monitor->geometry.box.x2 - monitor->geometry.box.x1;
- scratch.height = monitor->geometry.box.y2 - monitor->geometry.box.y1;
+ xXineramaScreenInfo scratch = {
+ .x_org = monitor->geometry.box.x1,
+ .y_org = monitor->geometry.box.y1,
+ .width = monitor->geometry.box.x2 - monitor->geometry.box.x1,
+ .height = monitor->geometry.box.y2 - monitor->geometry.box.y1,
+ };
if (client->swapped) {
swaps(&scratch.x_org);
@@ -278,7 +269,6 @@ RRXineramaWriteMonitor(ClientPtr client, RRMonitorPtr monitor)
int
ProcRRXineramaQueryScreens(ClientPtr client)
{
- xXineramaQueryScreensReply rep;
ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN];
int m;
RRMonitorPtr monitors = NULL;
@@ -292,7 +282,7 @@ ProcRRXineramaQueryScreens(ClientPtr client)
return BadAlloc;
}
- rep = (xXineramaQueryScreensReply) {
+ xXineramaQueryScreensReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = bytes_to_int32(nmonitors * sz_XineramaScreenInfo),
commit 6d2c42d0c8fd814e60a04babef96efa86922224f
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 15:15:20 2024 +0200
randr: RRCrtcCreate(): drop unnecessary zero assigments
The struct is already zero'ed out by calloc(), so no need to additionally
clear individual fields.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 2fb92b053..3974c350d 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -77,16 +77,8 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
return NULL;
crtc->id = FakeClientID(0);
crtc->pScreen = pScreen;
- crtc->mode = NULL;
- crtc->x = 0;
- crtc->y = 0;
crtc->rotation = RR_Rotate_0;
crtc->rotations = RR_Rotate_0;
- crtc->outputs = NULL;
- crtc->numOutputs = 0;
- crtc->gammaSize = 0;
- crtc->gammaRed = crtc->gammaBlue = crtc->gammaGreen = NULL;
- crtc->changed = FALSE;
crtc->devPrivate = devPrivate;
RRTransformInit(&crtc->client_pending_transform);
RRTransformInit(&crtc->client_current_transform);
commit 058815bed1bac2d9fc6ce15e001132806fb9ab14
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 15:03:35 2024 +0200
randr: use explicit case statement instead of SProcRandrVector table
No need to go indirectly through a vector table, since everything's fixed
anyways. It's not a pretty robust programming style: any changes need great
care, in order to not mix up things.
Replacing this by direct switch/case statement, which is using the defines
from the xrandr protocol headers. Also adding a little bit more protection
against subtle programming errors and reducing cognitive load (source size)
on understanding the code by using a tiny macro for deducing define name and
function name from the request's name.
This approach actually uncovered some subtle bug that had been waiting in
the dark for over 15 years.
As collateral benefit, getting a tiny bit better performance.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/randr.c b/randr/randr.c
index 078514a3c..b314f0411 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -50,8 +50,6 @@ static int RRNScreens;
real->mem = priv->mem; \
}
-static int SProcRRDispatch(ClientPtr pClient);
-
int RREventBase;
int RRErrorBase;
RESTYPE RRClientType, RREventType; /* resource types for event masks */
@@ -736,13 +734,3 @@ RRVerticalRefresh(xRRModeInfo * mode)
refresh = 0xffff;
return (CARD16) refresh;
}
-
-static int _X_COLD
-SProcRRDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- if (stuff->data >= RRNumberRequests || !SProcRandrVector[stuff->data])
- return BadRequest;
- UpdateCurrentTimeIf();
- return (*SProcRandrVector[stuff->data]) (client);
-}
diff --git a/randr/randrstr_priv.h b/randr/randrstr_priv.h
index a125f293a..f50a8eb94 100644
--- a/randr/randrstr_priv.h
+++ b/randr/randrstr_priv.h
@@ -33,8 +33,6 @@
extern int RREventBase, RRErrorBase;
-extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
-
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
extern DevPrivateKeyRec RRClientPrivateKeyRec;
@@ -141,4 +139,6 @@ int ProcRRSelectInput(ClientPtr client);
int ProcRRDispatch(ClientPtr client);
+int SProcRRDispatch(ClientPtr client);
+
#endif /* _XSERVER_RANDRSTR_PRIV_H_ */
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 48f908fd1..c447c5d63 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -603,60 +603,69 @@ SProcRRFreeLease(ClientPtr client) {
return ProcRRFreeLease(client);
}
-int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = {
- SProcRRQueryVersion, /* 0 */
-/* we skip 1 to make old clients fail pretty immediately */
- NULL, /* 1 SProcRandrOldGetScreenInfo */
-/* V1.0 apps share the same set screen config request id */
- SProcRRSetScreenConfig, /* 2 */
- NULL, /* 3 SProcRandrOldScreenChangeSelectInput */
-/* 3 used to be ScreenChangeSelectInput; deprecated */
- SProcRRSelectInput, /* 4 */
- SProcRRGetScreenInfo, /* 5 */
-/* V1.2 additions */
- SProcRRGetScreenSizeRange, /* 6 */
- SProcRRSetScreenSize, /* 7 */
- SProcRRGetScreenResources, /* 8 */
- SProcRRGetOutputInfo, /* 9 */
- SProcRRListOutputProperties, /* 10 */
- SProcRRQueryOutputProperty, /* 11 */
- SProcRRConfigureOutputProperty, /* 12 */
- SProcRRChangeOutputProperty, /* 13 */
- SProcRRDeleteOutputProperty, /* 14 */
- SProcRRGetOutputProperty, /* 15 */
- SProcRRCreateMode, /* 16 */
- SProcRRDestroyMode, /* 17 */
- SProcRRAddOutputMode, /* 18 */
- SProcRRDeleteOutputMode, /* 19 */
- SProcRRGetCrtcInfo, /* 20 */
- SProcRRSetCrtcConfig, /* 21 */
- SProcRRGetCrtcGammaSize, /* 22 */
- SProcRRGetCrtcGamma, /* 23 */
- SProcRRSetCrtcGamma, /* 24 */
-/* V1.3 additions */
- SProcRRGetScreenResourcesCurrent, /* 25 */
- SProcRRSetCrtcTransform, /* 26 */
- SProcRRGetCrtcTransform, /* 27 */
- SProcRRGetPanning, /* 28 */
- SProcRRSetPanning, /* 29 */
- SProcRRSetOutputPrimary, /* 30 */
- SProcRRGetOutputPrimary, /* 31 */
-/* V1.4 additions */
- SProcRRGetProviders, /* 32 */
- SProcRRGetProviderInfo, /* 33 */
- SProcRRSetProviderOffloadSink, /* 34 */
- SProcRRSetProviderOutputSource, /* 35 */
- SProcRRListProviderProperties, /* 36 */
- SProcRRQueryProviderProperty, /* 37 */
- SProcRRConfigureProviderProperty, /* 38 */
- SProcRRChangeProviderProperty, /* 39 */
- SProcRRDeleteProviderProperty, /* 40 */
- SProcRRGetProviderProperty, /* 41 */
-/* V1.5 additions */
- SProcRRGetMonitors, /* 42 */
- SProcRRSetMonitor, /* 43 */
- SProcRRDeleteMonitor, /* 44 */
-/* V1.6 additions */
- SProcRRCreateLease, /* 45 */
- SProcRRFreeLease, /* 46 */
-};
+int
+SProcRRDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ UpdateCurrentTimeIf();
+
+ switch (stuff->data) {
+ case X_RRQueryVersion: return SProcRRQueryVersion(client);
+ case X_RRSetScreenConfig: return SProcRRSetScreenConfig(client);
+ case X_RRSelectInput: return SProcRRSelectInput(client);
+ case X_RRGetScreenInfo: return SProcRRGetScreenInfo(client);
+
+ /* V1.2 additions */
+ case X_RRGetScreenSizeRange: return SProcRRGetScreenSizeRange(client);
+ case X_RRSetScreenSize: return SProcRRSetScreenSize(client);
+ case X_RRGetScreenResources: return SProcRRGetScreenResources(client);
+ case X_RRGetOutputInfo: return SProcRRGetOutputInfo(client);
+ case X_RRListOutputProperties: return SProcRRListOutputProperties(client);
+ case X_RRQueryOutputProperty: return SProcRRQueryOutputProperty(client);
+ case X_RRConfigureOutputProperty: return SProcRRConfigureOutputProperty(client);
+ case X_RRChangeOutputProperty: return SProcRRChangeOutputProperty(client);
+ case X_RRDeleteOutputProperty: return SProcRRDeleteOutputProperty(client);
+ case X_RRGetOutputProperty: return SProcRRGetOutputProperty(client);
+ case X_RRCreateMode: return SProcRRCreateMode(client);
+ case X_RRDestroyMode: return SProcRRDestroyMode(client);
+ case X_RRAddOutputMode: return SProcRRAddOutputMode(client);
+ case X_RRDeleteOutputMode: return SProcRRDeleteOutputMode(client);
+ case X_RRGetCrtcInfo: return SProcRRGetCrtcInfo(client);
+ case X_RRSetCrtcConfig: return SProcRRSetCrtcConfig(client);
+ case X_RRGetCrtcGammaSize: return SProcRRGetCrtcGammaSize(client);
+ case X_RRGetCrtcGamma: return SProcRRGetCrtcGamma(client);
+ case X_RRSetCrtcGamma: return SProcRRSetCrtcGamma(client);
+
+ /* V1.3 additions */
+ case X_RRGetScreenResourcesCurrent: return SProcRRGetScreenResourcesCurrent(client);
+ case X_RRSetCrtcTransform: return SProcRRSetCrtcTransform(client);
+ case X_RRGetCrtcTransform: return SProcRRGetCrtcTransform(client);
+ case X_RRGetPanning: return SProcRRGetPanning(client);
+ case X_RRSetPanning: return SProcRRSetPanning(client);
+ case X_RRSetOutputPrimary: return SProcRRSetOutputPrimary(client);
+ case X_RRGetOutputPrimary: return SProcRRGetOutputPrimary(client);
+
+ /* V1.4 additions */
+ case X_RRGetProviders: return SProcRRGetProviders(client);
+ case X_RRGetProviderInfo: return SProcRRGetProviderInfo(client);
+ case X_RRSetProviderOffloadSink: return SProcRRSetProviderOffloadSink(client);
+ case X_RRSetProviderOutputSource: return SProcRRSetProviderOutputSource(client);
+ case X_RRListProviderProperties: return SProcRRListProviderProperties(client);
+ case X_RRQueryProviderProperty: return SProcRRQueryProviderProperty(client);
+ case X_RRConfigureProviderProperty: return SProcRRConfigureProviderProperty(client);
+ case X_RRChangeProviderProperty: return SProcRRChangeProviderProperty(client);
+ case X_RRDeleteProviderProperty: return SProcRRDeleteProviderProperty(client);
+ case X_RRGetProviderProperty: return SProcRRGetProviderProperty(client);
+
+ /* V1.5 additions */
+ case X_RRGetMonitors: return SProcRRGetMonitors(client);
+ case X_RRSetMonitor: return SProcRRSetMonitor(client);
+ case X_RRDeleteMonitor: return SProcRRDeleteMonitor(client);
+
+ /* V1.6 additions */
+ case X_RRCreateLease: return SProcRRCreateLease(client);
+ case X_RRFreeLease: return SProcRRFreeLease(client);
+ }
+
+ return BadRequest;
+}
commit 42677ae1e391ce723fb9b967071ddc0862c62ebd
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 14:22:00 2024 +0200
randr: use explicit case statement instead of ProcRandrVector table
No need to go indirectly through a vector table, since everything's fixed
anyways. It's not a pretty robust programming style: any changes need great
care, in order to not mix up things.
Replacing this by direct switch/case statement, which is using the defines
from the xrandr protocol headers. Also adding a little bit more protection
against subtle programming errors and reducing cognitive load (source size)
on understanding the code by using a tiny macro for deducing define name and
function name from the request's name.
This approach actually uncovered some subtle bug that had been waiting in the
dark for over 15 years (see commit b87314c8766a6f3e4bbc74758f9b0c53d2c4e044)
As collateral benefit, getting a tiny bit better performance.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/randr.c b/randr/randr.c
index 59d101ba7..078514a3c 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -50,7 +50,6 @@ static int RRNScreens;
real->mem = priv->mem; \
}
-static int ProcRRDispatch(ClientPtr pClient);
static int SProcRRDispatch(ClientPtr pClient);
int RREventBase;
@@ -738,16 +737,6 @@ RRVerticalRefresh(xRRModeInfo * mode)
return (CARD16) refresh;
}
-static int
-ProcRRDispatch(ClientPtr client)
-{
- REQUEST(xReq);
- if (stuff->data >= RRNumberRequests || !ProcRandrVector[stuff->data])
- return BadRequest;
- UpdateCurrentTimeIf();
- return (*ProcRandrVector[stuff->data]) (client);
-}
-
static int _X_COLD
SProcRRDispatch(ClientPtr client)
{
diff --git a/randr/randrstr_priv.h b/randr/randrstr_priv.h
index 7f802215f..a125f293a 100644
--- a/randr/randrstr_priv.h
+++ b/randr/randrstr_priv.h
@@ -33,7 +33,6 @@
extern int RREventBase, RRErrorBase;
-extern int (*ProcRandrVector[RRNumberRequests]) (ClientPtr);
extern int (*SProcRandrVector[RRNumberRequests]) (ClientPtr);
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
@@ -140,4 +139,6 @@ int ProcRRQueryVersion(ClientPtr client);
int ProcRRSelectInput(ClientPtr client);
+int ProcRRDispatch(ClientPtr client);
+
#endif /* _XSERVER_RANDRSTR_PRIV_H_ */
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 4381f52ca..866c6f252 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -211,60 +211,69 @@ ProcRRSelectInput(ClientPtr client)
return Success;
}
-int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = {
- ProcRRQueryVersion, /* 0 */
-/* we skip 1 to make old clients fail pretty immediately */
- NULL, /* 1 ProcRandrOldGetScreenInfo */
-/* V1.0 apps share the same set screen config request id */
- ProcRRSetScreenConfig, /* 2 */
- NULL, /* 3 ProcRandrOldScreenChangeSelectInput */
-/* 3 used to be ScreenChangeSelectInput; deprecated */
- ProcRRSelectInput, /* 4 */
- ProcRRGetScreenInfo, /* 5 */
-/* V1.2 additions */
- ProcRRGetScreenSizeRange, /* 6 */
- ProcRRSetScreenSize, /* 7 */
- ProcRRGetScreenResources, /* 8 */
- ProcRRGetOutputInfo, /* 9 */
- ProcRRListOutputProperties, /* 10 */
- ProcRRQueryOutputProperty, /* 11 */
- ProcRRConfigureOutputProperty, /* 12 */
- ProcRRChangeOutputProperty, /* 13 */
- ProcRRDeleteOutputProperty, /* 14 */
- ProcRRGetOutputProperty, /* 15 */
- ProcRRCreateMode, /* 16 */
- ProcRRDestroyMode, /* 17 */
- ProcRRAddOutputMode, /* 18 */
- ProcRRDeleteOutputMode, /* 19 */
- ProcRRGetCrtcInfo, /* 20 */
- ProcRRSetCrtcConfig, /* 21 */
- ProcRRGetCrtcGammaSize, /* 22 */
- ProcRRGetCrtcGamma, /* 23 */
- ProcRRSetCrtcGamma, /* 24 */
-/* V1.3 additions */
- ProcRRGetScreenResourcesCurrent, /* 25 */
- ProcRRSetCrtcTransform, /* 26 */
- ProcRRGetCrtcTransform, /* 27 */
- ProcRRGetPanning, /* 28 */
- ProcRRSetPanning, /* 29 */
- ProcRRSetOutputPrimary, /* 30 */
- ProcRRGetOutputPrimary, /* 31 */
-/* V1.4 additions */
- ProcRRGetProviders, /* 32 */
- ProcRRGetProviderInfo, /* 33 */
- ProcRRSetProviderOffloadSink, /* 34 */
- ProcRRSetProviderOutputSource, /* 35 */
- ProcRRListProviderProperties, /* 36 */
- ProcRRQueryProviderProperty, /* 37 */
- ProcRRConfigureProviderProperty, /* 38 */
- ProcRRChangeProviderProperty, /* 39 */
- ProcRRDeleteProviderProperty, /* 40 */
- ProcRRGetProviderProperty, /* 41 */
-/* V1.5 additions */
- ProcRRGetMonitors, /* 42 */
- ProcRRSetMonitor, /* 43 */
- ProcRRDeleteMonitor, /* 44 */
-/* V1.6 additions */
- ProcRRCreateLease, /* 45 */
- ProcRRFreeLease, /* 46 */
-};
+int
+ProcRRDispatch(ClientPtr client)
+{
+ REQUEST(xReq);
+ UpdateCurrentTimeIf();
+
+ switch (stuff->data) {
+ case X_RRQueryVersion: return ProcRRQueryVersion(client);
+ case X_RRSetScreenConfig: return ProcRRSetScreenConfig(client);
+ case X_RRSelectInput: return ProcRRSelectInput(client);
+ case X_RRGetScreenInfo: return ProcRRGetScreenInfo(client);
+
+ /* V1.2 additions */
+ case X_RRGetScreenSizeRange: return ProcRRGetScreenSizeRange(client);
+ case X_RRSetScreenSize: return ProcRRSetScreenSize(client);
+ case X_RRGetScreenResources: return ProcRRGetScreenResources(client);
+ case X_RRGetOutputInfo: return ProcRRGetOutputInfo(client);
+ case X_RRListOutputProperties: return ProcRRListOutputProperties(client);
+ case X_RRQueryOutputProperty: return ProcRRQueryOutputProperty(client);
+ case X_RRConfigureOutputProperty: return ProcRRConfigureOutputProperty(client);
+ case X_RRChangeOutputProperty: return ProcRRChangeOutputProperty(client);
+ case X_RRDeleteOutputProperty: return ProcRRDeleteOutputProperty(client);
+ case X_RRGetOutputProperty: return ProcRRGetOutputProperty(client);
+ case X_RRCreateMode: return ProcRRCreateMode(client);
+ case X_RRDestroyMode: return ProcRRDestroyMode(client);
+ case X_RRAddOutputMode: return ProcRRAddOutputMode(client);
+ case X_RRDeleteOutputMode: return ProcRRDeleteOutputMode(client);
+ case X_RRGetCrtcInfo: return ProcRRGetCrtcInfo(client);
+ case X_RRSetCrtcConfig: return ProcRRSetCrtcConfig(client);
+ case X_RRGetCrtcGammaSize: return ProcRRGetCrtcGammaSize(client);
+ case X_RRGetCrtcGamma: return ProcRRGetCrtcGamma(client);
+ case X_RRSetCrtcGamma: return ProcRRSetCrtcGamma(client);
+
+ /* V1.3 additions */
+ case X_RRGetScreenResourcesCurrent: return ProcRRGetScreenResourcesCurrent(client);
+ case X_RRSetCrtcTransform: return ProcRRSetCrtcTransform(client);
+ case X_RRGetCrtcTransform: return ProcRRGetCrtcTransform(client);
+ case X_RRGetPanning: return ProcRRGetPanning(client);
+ case X_RRSetPanning: return ProcRRSetPanning(client);
+ case X_RRSetOutputPrimary: return ProcRRSetOutputPrimary(client);
+ case X_RRGetOutputPrimary: return ProcRRGetOutputPrimary(client);
+
+ /* V1.4 additions */
+ case X_RRGetProviders: return ProcRRGetProviders(client);
+ case X_RRGetProviderInfo: return ProcRRGetProviderInfo(client);
+ case X_RRSetProviderOffloadSink: return ProcRRSetProviderOffloadSink(client);
+ case X_RRSetProviderOutputSource: return ProcRRSetProviderOutputSource(client);
+ case X_RRListProviderProperties: return ProcRRListProviderProperties(client);
+ case X_RRQueryProviderProperty: return ProcRRQueryProviderProperty(client);
+ case X_RRConfigureProviderProperty: return ProcRRConfigureProviderProperty(client);
+ case X_RRChangeProviderProperty: return ProcRRChangeProviderProperty(client);
+ case X_RRDeleteProviderProperty: return ProcRRDeleteProviderProperty(client);
+ case X_RRGetProviderProperty: return ProcRRGetProviderProperty(client);
+
+ /* V1.5 additions */
+ case X_RRGetMonitors: return ProcRRGetMonitors(client);
+ case X_RRSetMonitor: return ProcRRSetMonitor(client);
+ case X_RRDeleteMonitor: return ProcRRDeleteMonitor(client);
+
+ /* V1.6 additions */
+ case X_RRCreateLease: return ProcRRCreateLease(client);
+ case X_RRFreeLease: return ProcRRFreeLease(client);
+ }
+
+ return BadRequest;
+}
commit ed172244034f31d8e7e7eec2283bd825a48bb94e
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date: Mon Jul 29 15:01:08 2024 +0200
randr: let SProc*'s call their Proc*'s directly
No need to go indirectly through an vector table. It's much clearer and
easier to understand when calling them directly. And a tiny bit performance
improvement as collateral benefit.
Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
diff --git a/randr/randrstr_priv.h b/randr/randrstr_priv.h
index 4864f5272..7f802215f 100644
--- a/randr/randrstr_priv.h
+++ b/randr/randrstr_priv.h
@@ -136,4 +136,8 @@ int ProcRRCreateLease(ClientPtr client);
int ProcRRFreeLease(ClientPtr client);
+int ProcRRQueryVersion(ClientPtr client);
+
+int ProcRRSelectInput(ClientPtr client);
+
#endif /* _XSERVER_RANDRSTR_PRIV_H_ */
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 615e89312..4381f52ca 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -36,7 +36,7 @@ RRClientKnowsRates(ClientPtr pClient)
1, 1) >= 0;
}
-static int
+int
ProcRRQueryVersion(ClientPtr client)
{
xRRQueryVersionReply rep = {
@@ -72,7 +72,7 @@ ProcRRQueryVersion(ClientPtr client)
return Success;
}
-static int
+int
ProcRRSelectInput(ClientPtr client)
{
REQUEST(xRRSelectInputReq);
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 6de8775b0..48f908fd1 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -30,7 +30,7 @@ SProcRRQueryVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryVersionReq);
swapl(&stuff->majorVersion);
swapl(&stuff->minorVersion);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRQueryVersion(client);
}
static int _X_COLD
@@ -40,7 +40,7 @@ SProcRRGetScreenInfo(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
swapl(&stuff->window);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetScreenInfo(client);
}
static int _X_COLD
@@ -60,7 +60,7 @@ SProcRRSetScreenConfig(ClientPtr client)
swapl(&stuff->timestamp);
swaps(&stuff->sizeID);
swaps(&stuff->rotation);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetScreenConfig(client);
}
static int _X_COLD
@@ -71,7 +71,7 @@ SProcRRSelectInput(ClientPtr client)
REQUEST_SIZE_MATCH(xRRSelectInputReq);
swapl(&stuff->window);
swaps(&stuff->enable);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSelectInput(client);
}
static int _X_COLD
@@ -81,7 +81,7 @@ SProcRRGetScreenSizeRange(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetScreenSizeRangeReq);
swapl(&stuff->window);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetScreenSizeRange(client);
}
static int _X_COLD
@@ -95,7 +95,7 @@ SProcRRSetScreenSize(ClientPtr client)
swaps(&stuff->height);
swapl(&stuff->widthInMillimeters);
swapl(&stuff->heightInMillimeters);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetScreenSize(client);
}
static int _X_COLD
@@ -105,7 +105,7 @@ SProcRRGetScreenResources(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
swapl(&stuff->window);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetScreenResources(client);
}
static int _X_COLD
@@ -116,7 +116,7 @@ SProcRRGetScreenResourcesCurrent(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetScreenResourcesCurrentReq);
swaps(&stuff->length);
swapl(&stuff->window);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetScreenResourcesCurrent(client);
}
static int _X_COLD
@@ -127,7 +127,7 @@ SProcRRGetOutputInfo(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
swapl(&stuff->output);
swapl(&stuff->configTimestamp);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetScreenResources(client);
}
static int _X_COLD
@@ -137,7 +137,7 @@ SProcRRListOutputProperties(ClientPtr client)
REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
swapl(&stuff->output);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRListOutputProperties(client);
}
static int _X_COLD
@@ -148,7 +148,7 @@ SProcRRQueryOutputProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
swapl(&stuff->output);
swapl(&stuff->property);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRQueryOutputProperty(client);
}
static int _X_COLD
@@ -160,7 +160,7 @@ SProcRRConfigureOutputProperty(ClientPtr client)
swapl(&stuff->output);
swapl(&stuff->property);
SwapRestL(stuff);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRConfigureOutputProperty(client);
}
static int _X_COLD
@@ -186,7 +186,7 @@ SProcRRChangeOutputProperty(ClientPtr client)
client->errorValue = stuff->format;
return BadValue;
}
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRChangeOutputProperty(client);
}
static int _X_COLD
@@ -197,7 +197,7 @@ SProcRRDeleteOutputProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteOutputPropertyReq);
swapl(&stuff->output);
swapl(&stuff->property);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRDeleteOutputProperty(client);
}
static int _X_COLD
@@ -211,7 +211,7 @@ SProcRRGetOutputProperty(ClientPtr client)
swapl(&stuff->type);
swapl(&stuff->longOffset);
swapl(&stuff->longLength);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetOutputProperty(client);
}
static int _X_COLD
@@ -237,7 +237,7 @@ SProcRRCreateMode(ClientPtr client)
swaps(&modeinfo->vTotal);
swaps(&modeinfo->nameLength);
swapl(&modeinfo->modeFlags);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRCreateMode(client);
}
static int _X_COLD
@@ -247,7 +247,7 @@ SProcRRDestroyMode(ClientPtr client)
REQUEST_SIZE_MATCH(xRRDestroyModeReq);
swapl(&stuff->mode);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRDestroyMode(client);
}
static int _X_COLD
@@ -258,7 +258,7 @@ SProcRRAddOutputMode(ClientPtr client)
REQUEST_SIZE_MATCH(xRRAddOutputModeReq);
swapl(&stuff->output);
swapl(&stuff->mode);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRAddOutputMode(client);
}
static int _X_COLD
@@ -269,7 +269,7 @@ SProcRRDeleteOutputMode(ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteOutputModeReq);
swapl(&stuff->output);
swapl(&stuff->mode);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRDeleteOutputMode(client);
}
static int _X_COLD
@@ -280,7 +280,7 @@ SProcRRGetCrtcInfo(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetCrtcInfoReq);
swapl(&stuff->crtc);
swapl(&stuff->configTimestamp);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetCrtcInfo(client);
}
static int _X_COLD
@@ -297,7 +297,7 @@ SProcRRSetCrtcConfig(ClientPtr client)
swapl(&stuff->mode);
swaps(&stuff->rotation);
SwapRestL(stuff);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetCrtcConfig(client);
}
static int _X_COLD
@@ -307,7 +307,7 @@ SProcRRGetCrtcGammaSize(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
swapl(&stuff->crtc);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetCrtcGammaSize(client);
}
static int _X_COLD
@@ -317,7 +317,7 @@ SProcRRGetCrtcGamma(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetCrtcGammaReq);
swapl(&stuff->crtc);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetCrtcGamma(client);
}
static int _X_COLD
@@ -329,7 +329,7 @@ SProcRRSetCrtcGamma(ClientPtr client)
swapl(&stuff->crtc);
swaps(&stuff->size);
SwapRestS(stuff);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetCrtcGamma(client);
}
static int _X_COLD
@@ -353,7 +353,7 @@ SProcRRSetCrtcTransform(ClientPtr client)
return BadLength;
SwapLongs(params, nparams);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetCrtcTransform(client);
}
static int _X_COLD
@@ -363,7 +363,7 @@ SProcRRGetCrtcTransform(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetCrtcTransformReq);
swapl(&stuff->crtc);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetCrtcTransform(client);
}
static int _X_COLD
@@ -373,7 +373,7 @@ SProcRRGetPanning(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetPanningReq);
swapl(&stuff->crtc);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRGetPanning(client);
}
static int _X_COLD
@@ -396,7 +396,7 @@ SProcRRSetPanning(ClientPtr client)
swaps(&stuff->border_top);
swaps(&stuff->border_right);
swaps(&stuff->border_bottom);
- return (*ProcRandrVector[stuff->randrReqType]) (client);
+ return ProcRRSetPanning(client);
}
static int _X_COLD
@@ -407,7 +407,7 @@ SProcRRSetOutputPrimary(ClientPtr client)
REQUEST_SIZE_MATCH(xRRSetOutputPrimaryReq);
swapl(&stuff->window);
swapl(&stuff->output);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRSetOutputPrimary(client);
}
static int _X_COLD
@@ -417,7 +417,7 @@ SProcRRGetOutputPrimary(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetOutputPrimaryReq);
swapl(&stuff->window);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRGetOutputPrimary(client);
}
static int _X_COLD
@@ -427,7 +427,7 @@ SProcRRGetProviders(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetProvidersReq);
swapl(&stuff->window);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRGetProviders(client);
}
static int _X_COLD
@@ -438,7 +438,7 @@ SProcRRGetProviderInfo(ClientPtr client)
REQUEST_SIZE_MATCH(xRRGetProviderInfoReq);
swapl(&stuff->provider);
swapl(&stuff->configTimestamp);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRGetProviderInfo(client);
}
static int _X_COLD
@@ -450,7 +450,7 @@ SProcRRSetProviderOffloadSink(ClientPtr client)
swapl(&stuff->provider);
swapl(&stuff->sink_provider);
swapl(&stuff->configTimestamp);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRSetProviderOffloadSink(client);
}
static int _X_COLD
@@ -462,7 +462,7 @@ SProcRRSetProviderOutputSource(ClientPtr client)
swapl(&stuff->provider);
swapl(&stuff->source_provider);
swapl(&stuff->configTimestamp);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRSetProviderOutputSource(client);
}
static int _X_COLD
@@ -472,7 +472,7 @@ SProcRRListProviderProperties(ClientPtr client)
REQUEST_SIZE_MATCH(xRRListProviderPropertiesReq);
swapl(&stuff->provider);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRListProviderProperties(client);
}
static int _X_COLD
@@ -483,7 +483,7 @@ SProcRRQueryProviderProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xRRQueryProviderPropertyReq);
swapl(&stuff->provider);
swapl(&stuff->property);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRQueryProviderProperty(client);
}
static int _X_COLD
@@ -496,7 +496,7 @@ SProcRRConfigureProviderProperty(ClientPtr client)
swapl(&stuff->property);
/* TODO: no way to specify format? */
SwapRestL(stuff);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRConfigureProviderProperty(client);
}
static int _X_COLD
@@ -519,7 +519,7 @@ SProcRRChangeProviderProperty(ClientPtr client)
SwapRestL(stuff);
break;
}
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRChangeProviderProperty(client);
}
static int _X_COLD
@@ -530,7 +530,7 @@ SProcRRDeleteProviderProperty(ClientPtr client)
REQUEST_SIZE_MATCH(xRRDeleteProviderPropertyReq);
swapl(&stuff->provider);
swapl(&stuff->property);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRDeleteProviderProperty(client);
}
static int _X_COLD
@@ -544,7 +544,7 @@ SProcRRGetProviderProperty(ClientPtr client)
swapl(&stuff->type);
swapl(&stuff->longOffset);
swapl(&stuff->longLength);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRGetProviderProperty(client);
}
static int _X_COLD
@@ -553,7 +553,7 @@ SProcRRGetMonitors(ClientPtr client) {
REQUEST_SIZE_MATCH(xRRGetMonitorsReq);
swapl(&stuff->window);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRGetMonitors(client);
}
static int _X_COLD
@@ -569,7 +569,7 @@ SProcRRSetMonitor(ClientPtr client) {
swaps(&stuff->monitor.width);
swaps(&stuff->monitor.height);
SwapRestL(stuff);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRSetMonitor(client);
}
static int _X_COLD
@@ -579,7 +579,7 @@ SProcRRDeleteMonitor(ClientPtr client) {
REQUEST_SIZE_MATCH(xRRDeleteMonitorReq);
swapl(&stuff->window);
swapl(&stuff->name);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRDeleteMonitor(client);
}
static int _X_COLD
@@ -591,7 +591,7 @@ SProcRRCreateLease(ClientPtr client) {
swaps(&stuff->nCrtcs);
swaps(&stuff->nOutputs);
SwapRestL(stuff);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRCreateLease(client);
}
static int _X_COLD
@@ -600,7 +600,7 @@ SProcRRFreeLease(ClientPtr client) {
REQUEST_SIZE_MATCH(xRRFreeLeaseReq);
swapl(&stuff->lid);
- return ProcRandrVector[stuff->randrReqType] (client);
+ return ProcRRFreeLease(client);
}
int (*SProcRandrVector[RRNumberRequests]) (ClientPtr) = {
More information about the xorg-commit
mailing list