Xext: vidmode: simplify dispatcher

These dispatcher functions are much more complex than they're usually are
(just switch/case statement). Bring them in line with the standard scheme
used in the Xserver, so further steps become easier.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-04 13:06:27 +02:00
parent aa9a93461d
commit 4137323e87

View File

@ -447,6 +447,10 @@ ProcVidModeAddModeLine(ClientPtr client)
int dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeAddModeline");
ver = ClientMajorVersion(client);
@ -617,6 +621,10 @@ ProcVidModeDeleteModeLine(ClientPtr client)
int len, dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeDeleteModeline");
ver = ClientMajorVersion(client);
@ -741,6 +749,10 @@ ProcVidModeModModeLine(ClientPtr client)
int len, dotClock;
int ver;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
DEBUG_P("XF86VidModeModModeline");
ver = ClientMajorVersion(client);
@ -1008,6 +1020,10 @@ ProcVidModeSwitchMode(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1036,6 +1052,10 @@ ProcVidModeSwitchToMode(ClientPtr client)
DEBUG_P("XF86VidModeSwitchToMode");
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
ver = ClientMajorVersion(client);
if (ver < 2) {
@ -1140,6 +1160,10 @@ ProcVidModeLockModeSwitch(ClientPtr client)
DEBUG_P("XF86VidModeLockModeSwitch");
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1303,6 +1327,10 @@ ProcVidModeSetViewPort(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1401,6 +1429,10 @@ ProcVidModeSetGamma(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetGammaReq);
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
if (stuff->screen >= screenInfo.numScreens)
return BadValue;
pScreen = screenInfo.screens[stuff->screen];
@ -1468,6 +1500,10 @@ ProcVidModeSetGammaRamp(ClientPtr client)
ScreenPtr pScreen;
VidModePtr pVidMode;
/* limited to local-only connections */
if (!VidModeAllowNonLocal && !client->local)
return VidModeErrorBase + XF86VidModeClientNotLocal;
REQUEST(xXF86VidModeSetGammaRampReq);
REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
@ -1675,9 +1711,6 @@ ProcVidModeDispatch(ClientPtr client)
return ProcVidModeGetGammaRampSize(client);
case X_XF86VidModeGetPermissions:
return ProcVidModeGetPermissions(client);
default:
if (VidModeAllowNonLocal || client->local) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return ProcVidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
@ -1700,10 +1733,6 @@ ProcVidModeDispatch(ClientPtr client)
return BadRequest;
}
}
else
return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
static int _X_COLD
SProcVidModeGetModeLine(ClientPtr client)
@ -2065,9 +2094,6 @@ SProcVidModeDispatch(ClientPtr client)
return SProcVidModeGetGammaRampSize(client);
case X_XF86VidModeGetPermissions:
return SProcVidModeGetPermissions(client);
default:
if (VidModeAllowNonLocal || client->local) {
switch (stuff->data) {
case X_XF86VidModeAddModeLine:
return SProcVidModeAddModeLine(client);
case X_XF86VidModeDeleteModeLine:
@ -2090,10 +2116,6 @@ SProcVidModeDispatch(ClientPtr client)
return BadRequest;
}
}
else
return VidModeErrorBase + XF86VidModeClientNotLocal;
}
}
void
VidModeAddExtension(Bool allow_non_local)