Xext: shape: fix mismatching event swap prototypes

Instead of hard typecasts on event proc assignment, better accept the
expected parameter types and do the typecast inside the functions.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2026-10-15 16:33:53 +02:00 • committed by Enrico Weigelt
commit 4fb08174d7
4 changed files with 46 additions and 20 deletions

28
Xext/shape/byteswap.c Normal file
View file

@ -0,0 +1,28 @@
/* SPDX-License-Identifier: X11 OR MIT OR AGPL-3.0-or-later
*
* Copyright © 2026 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#include <dix-config.h>
#include <X11/Xproto.h>
#include <X11/extensions/shapeproto.h>
#include "include/misc.h"
#include "shape_intern.h"
void ShapeSwapNotifyEvent(xEvent *_from, xEvent *_to)
{
xShapeNotifyEvent *from = (xShapeNotifyEvent*)_from;
xShapeNotifyEvent *to = (xShapeNotifyEvent*)_to;
*to = *from;
swapl(&to->window);
swaps(&to->sequenceNumber);
swaps(&to->x);
swaps(&to->y);
swaps(&to->width);
swaps(&to->height);
swapl(&to->time);
}

View file

@ -1,4 +1,5 @@
srcs_shape = [
'byteswap.c',
'shape.c',
]

View file

@ -56,6 +56,8 @@ in this Software without prior written authorization from The Open Group.
#include "gcstruct.h"
#include "protocol-versions.h"
#include "shape_intern.h"
Bool noShapeExtension = FALSE;
typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */
@ -63,10 +65,6 @@ typedef RegionPtr (*CreateDftPtr) (WindowPtr /* pWin */
static DevPrivateKeyRec ShapeWindowPrivateKeyRec;
static void SShapeNotifyEvent(xShapeNotifyEvent * /* from */ ,
xShapeNotifyEvent * /* to */
);
/* SendShapeNotify, CreateBoundingShape and CreateClipShape are used
* externally by the Xfixes extension and are now defined in window.h
*/
@ -961,21 +959,6 @@ ProcShapeDispatch(ClientPtr client)
}
}
static void _X_COLD
SShapeNotifyEvent(xShapeNotifyEvent * from, xShapeNotifyEvent * to)
{
to->type = from->type;
to->kind = from->kind;
cpswapl(from->window, to->window);
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswaps(from->x, to->x);
cpswaps(from->y, to->y);
cpswaps(from->width, to->width);
cpswaps(from->height, to->height);
cpswapl(from->time, to->time);
to->shaped = from->shaped;
}
static void
ShapeWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWin)
{
@ -1019,6 +1002,6 @@ ShapeExtensionInit(void)
ProcShapeDispatch, ProcShapeDispatch,
NULL, StandardMinorOpcode))) {
ShapeEventBase = extEntry->eventBase;
EventSwapVector[ShapeEventBase] = (EventSwapPtr) SShapeNotifyEvent;
EventSwapVector[ShapeEventBase] = ShapeSwapNotifyEvent;
}
}

14
Xext/shape/shape_intern.h Normal file
View file

@ -0,0 +1,14 @@
/* SPDX-License-Identifier: X11 OR MIT OR AGPL-3.0-or-later
*
* @brief only to be used internally by shape extension
*
* Copyright © 2026 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#ifndef __XLIBRE_SHAPE_INTERN_H
#define __XLIBRE_SHAPE_INTERN_H
#include <X11/Xproto.h>
void ShapeSwapNotifyEvent(xEvent *_from, xEvent *_to);
#endif /* __XLIBRE_SHAPE_INTERN_H */