From 724d3a3d5d735482583b7f00b31fc586afc2bacd Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 8 Dec 2025 14:42:15 +0100 Subject: [PATCH] use stdbool instead of Xorg's "Bool" type No need for carrying around almost half a century old baggage, since C standard has an official bool type. Signed-off-by: Enrico Weigelt, metux IT consult --- shared/vmmouse_client.c | 24 ++++++++++--------- shared/vmmouse_client.h | 4 +++- src/vmmouse.c | 51 +++++++++++++++++++++-------------------- src/xf86OSmouse.h | 28 +++++++++++----------- tools/vmmouse_iopl.c | 14 +++++------ 5 files changed, 64 insertions(+), 57 deletions(-) diff --git a/shared/vmmouse_client.c b/shared/vmmouse_client.c index c5d529e..37c7151 100644 --- a/shared/vmmouse_client.c +++ b/shared/vmmouse_client.c @@ -39,6 +39,8 @@ #include "config.h" #endif +#include + #include "vmmouse_client.h" #include "vmmouse_proto.h" @@ -56,7 +58,7 @@ *---------------------------------------------------------------------------- */ -static Bool +static bool VMMouseClientVMCheck(void) { VMMouseProtoCmd vmpc; @@ -70,10 +72,10 @@ VMMouseClientVMCheck(void) * eax should contain version */ if (vmpc.out.vEbx != VMMOUSE_PROTO_MAGIC || vmpc.out.vEax == 0xffffffff) { - return FALSE; + return false; } - return TRUE; + return true; } @@ -87,8 +89,8 @@ VMMouseClientVMCheck(void) * if we're enabled before attempting to disable the VMMouse). * * Results: - * TRUE if we successfully disable the VMMouse communication mode, - * FALSE if something went wrong. + * true if we successfully disable the VMMouse communication mode, + * false if something went wrong. * * Side effects: * Disables the absolute positioning mode. @@ -129,7 +131,7 @@ VMMouseClient_Disable(void) * and return the result, but conceivably we could do more. * * Results: - * TRUE if the enable succeeds, FALSE otherwise. + * true if the enable succeeds, false otherwise. * * Side effects: * Causes host-side state change. @@ -137,7 +139,7 @@ VMMouseClient_Disable(void) *---------------------------------------------------------------------- */ -Bool +bool VMMouseClient_Enable(void) { uint32_t status; @@ -150,7 +152,7 @@ VMMouseClient_Enable(void) { */ if (!VMMouseClientVMCheck()) { - return FALSE; + return false; } VMwareLog(("VMMouseClientVMCheck succeeded, checking VMMOUSE version\n")); @@ -175,7 +177,7 @@ VMMouseClient_Enable(void) { status = vmpc.out.vEax; if ((status & 0x0000ffff) == 0) { VMwareLog(("VMMouseClient_Enable: no data on port.")); - return FALSE; + return false; } /* @@ -188,7 +190,7 @@ VMMouseClient_Enable(void) { data = vmpc.out.vEax; if (data!= VMMOUSE_VERSION_ID) { VMwareLog(("VMMouseClient_Enable: data was not VERSION_ID")); - return FALSE; + return false; } /* @@ -203,7 +205,7 @@ VMMouseClient_Enable(void) { */ VMwareLog(("VMMouseClient_Enable: go go go!\n")); - return TRUE; + return true; } diff --git a/shared/vmmouse_client.h b/shared/vmmouse_client.h index 1de51e5..ee3fee3 100644 --- a/shared/vmmouse_client.h +++ b/shared/vmmouse_client.h @@ -39,6 +39,8 @@ #ifndef _VMMOUSE_CLIENT_H_ #define _VMMOUSE_CLIENT_H_ +#include + #include "xorg-server.h" #include "xf86_OSproc.h" @@ -56,7 +58,7 @@ typedef struct _VMMOUSE_INPUT_DATA { /* * Public Functions */ -Bool VMMouseClient_Enable(void); +bool VMMouseClient_Enable(void); void VMMouseClient_Disable(void); unsigned int VMMouseClient_GetInput(PVMMOUSE_INPUT_DATA pvmmouseInput); void VMMouseClient_RequestRelative(void); diff --git a/src/vmmouse.c b/src/vmmouse.c index 6466a00..a64e8f7 100644 --- a/src/vmmouse.c +++ b/src/vmmouse.c @@ -48,6 +48,7 @@ #endif #include +#include #include #include @@ -121,7 +122,7 @@ static void MouseCommonOptions(InputInfoPtr pInfo); static void GetVMMouseMotionEvent(InputInfoPtr pInfo); static void VMMousePostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy, int dz, int dw); static void VMMouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy); -static Bool VMMouseDeviceControl(DeviceIntPtr device, int mode); +static bool VMMouseDeviceControl(DeviceIntPtr device, int mode); static int VMMouseControlProc(InputInfoPtr pInfo, xDeviceCtl * control); static void VMMouseReadInput(InputInfoPtr pInfo); static int VMMouseSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode); @@ -132,10 +133,10 @@ static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl); *****************************************************************************/ typedef struct { int screenNum; - Bool vmmouseAvailable; + bool vmmouseAvailable; VMMOUSE_INPUT_DATA vmmousePrevInput; - Bool isCurrRelative; - Bool absoluteRequested; + bool isCurrRelative; + bool absoluteRequested; } VMMousePrivRec, *VMMousePrivPtr; InputDriverRec VMMOUSE = { @@ -209,7 +210,7 @@ VMMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) /* Enable hardware access. */ if (!xorgHWAccess) { if (xf86EnableIO()) - xorgHWAccess = TRUE; + xorgHWAccess = true; else { rc = BadValue; goto error; @@ -233,8 +234,8 @@ VMMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) goto error; } - mPriv->absoluteRequested = FALSE; - mPriv->vmmouseAvailable = TRUE; + mPriv->absoluteRequested = false; + mPriv->vmmouseAvailable = true; /* Settup the pInfo */ pInfo->type_name = XI_MOUSE; @@ -345,7 +346,7 @@ VMMouseDoPostEvent(InputInfoPtr pInfo, int buttons, int dx, int dy) VMMousePrivPtr mPriv; int truebuttons; int id, change; - Bool mouseMoved = FALSE; + bool mouseMoved = false; pMse = pInfo->private; mPriv = (VMMousePrivPtr)pMse->mousePriv; @@ -610,8 +611,8 @@ VMMouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) * DEVICE_OFF and DEVICE_CLOSE phase * * Results: - * TRUE, if sucessful - * FALSE, if failed + * true, if sucessful + * false, if failed * * Side effects: * Absolute pointing device is enabled during DEVICE_ON @@ -621,7 +622,7 @@ VMMouseUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) *---------------------------------------------------------------------- */ -static Bool +static bool VMMouseDeviceControl(DeviceIntPtr device, int mode) { InputInfoPtr pInfo; @@ -637,7 +638,7 @@ VMMouseDeviceControl(DeviceIntPtr device, int mode) switch (mode){ case DEVICE_INIT: - device->public.on = FALSE; + device->public.on = false; /* * [KAZU-241097] We don't know exactly how many buttons the * device has, so setup the map with the maximum number. @@ -704,11 +705,11 @@ VMMouseDeviceControl(DeviceIntPtr device, int mode) */ if (!VMMouseClient_Enable()) { xf86Msg(X_ERROR, "VMWARE(0): vmmouse enable failed\n"); - mPriv->vmmouseAvailable = FALSE; - device->public.on = FALSE; - return FALSE; + mPriv->vmmouseAvailable = false; + device->public.on = false; + return false; } else { - mPriv->vmmouseAvailable = TRUE; + mPriv->vmmouseAvailable = true; xf86Msg(X_INFO, "VMWARE(0): vmmouse enabled\n"); } } @@ -717,7 +718,7 @@ VMMouseDeviceControl(DeviceIntPtr device, int mode) } } pMse->lastButtons = 0; - device->public.on = TRUE; + device->public.on = true; FlushButtons(pMse); break; case DEVICE_OFF: @@ -728,8 +729,8 @@ VMMouseDeviceControl(DeviceIntPtr device, int mode) VMMousePrivPtr mPriv = (VMMousePrivPtr)pMse->mousePriv; if( mPriv->vmmouseAvailable ) { VMMouseClient_Disable(); - mPriv->vmmouseAvailable = FALSE; - mPriv->absoluteRequested = FALSE; + mPriv->vmmouseAvailable = false; + mPriv->absoluteRequested = false; } xf86RemoveEnabledDevice(pInfo); @@ -740,7 +741,7 @@ VMMouseDeviceControl(DeviceIntPtr device, int mode) xf86CloseSerial(pInfo->fd); pInfo->fd = -1; } - device->public.on = FALSE; + device->public.on = false; usleep(300000); break; @@ -793,7 +794,7 @@ VMMouseReadInput(InputInfoPtr pInfo) * position. */ VMMouseClient_RequestAbsolute(); - mPriv->absoluteRequested = TRUE; + mPriv->absoluteRequested = true; LogMessageVerbSigSafe(X_INFO, -1, "VMWARE(0): vmmouse enable absolute mode\n"); } @@ -944,7 +945,7 @@ VMMouseSwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) * This function was called by Xserver to convert valuators to X and Y * * Results: - * TRUE + * true * * Side effects: * X and Y was converted according to current Screen dimension @@ -984,7 +985,7 @@ VMMouseUnplug(pointer p) * integrate the module infto the XFree86 loader architecutre. * * Results: - * TRUE + * true * * Side effects: * Regular mouse module was loaded as a submodule. In case @@ -1000,10 +1001,10 @@ VMMousePlug(pointer module, int *errmaj, int *errmin) { - static Bool Initialised = FALSE; + static bool Initialised = false; if (!Initialised) - Initialised = TRUE; + Initialised = true; xf86Msg(X_INFO, "VMWARE(0): VMMOUSE module was loaded\n"); xf86AddInputDriver(&VMMOUSE, module, 0); diff --git a/src/xf86OSmouse.h b/src/xf86OSmouse.h index 09b8525..b99c3e4 100644 --- a/src/xf86OSmouse.h +++ b/src/xf86OSmouse.h @@ -30,6 +30,8 @@ #ifndef _XF86OSMOUSE_H_ #define _XF86OSMOUSE_H_ +#include + #include "xf86Xinput.h" /* Mouse interface classes */ @@ -77,8 +79,8 @@ struct _MouseDevRec; typedef int (*GetInterfaceTypesProc)(void); typedef const char **(*BuiltinNamesProc)(void); -typedef Bool (*CheckProtocolProc)(const char *protocol); -typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol, +typedef bool (*CheckProtocolProc)(const char *protocol); +typedef bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol, int flags); typedef const char *(*DefaultProtocolProc)(void); typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara); @@ -116,7 +118,7 @@ typedef struct { * directly in the main "mouse" driver. * * CheckProtocol: Checks if the protocol name given is supported by the - * OS. It should return TRUE for both "builtin" protocols and + * OS. It should return true for both "builtin" protocols and * protocols of type MSE_MISC that are supported by the OS. * * PreInit: The PreInit function for protocols that are builtin. This @@ -191,9 +193,9 @@ extern OSMouseInfoPtr xf86OSMouseInit(int flags); */ typedef void (*checkMovementsProc)(InputInfoPtr,int, int); -typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool); -typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char); -typedef Bool (*dataGoodProc)(struct _MouseDevRec *); +typedef void (*autoProbeProc)(InputInfoPtr, bool, bool); +typedef bool (*collectDataProc)(struct _MouseDevRec *, unsigned char); +typedef bool (*dataGoodProc)(struct _MouseDevRec *); typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons, int dx, int dy, int dz, int dw); @@ -219,11 +221,11 @@ typedef struct _MouseDevRec { int den; int buttons; /* # of buttons */ int emulateState; /* automata state for 2 button mode */ - Bool emulate3Buttons; - Bool emulate3ButtonsSoft; + bool emulate3Buttons; + bool emulate3ButtonsSoft; int emulate3Timeout;/* Timeout for 3 button emulation */ - Bool chordMiddle; - Bool flipXY; + bool chordMiddle; + bool flipXY; int invX; int invY; int mouseFlags; /* Flags to Clear after opening @@ -245,9 +247,9 @@ typedef struct _MouseDevRec { InputInfoPtr pInfo; int origProtocolID; const char * origProtocol; - Bool emulate3Pending;/* timer waiting */ + bool emulate3Pending;/* timer waiting */ CARD32 emulate3Expires;/* time to fire emulation code */ - Bool emulateWheel; + bool emulateWheel; int wheelInertia; int wheelButton; int negativeX; /* Button values. Unlike the Z and */ @@ -256,7 +258,7 @@ typedef struct _MouseDevRec { int positiveY; int wheelYDistance; int wheelXDistance; - Bool autoProbe; + bool autoProbe; checkMovementsProc checkMovements; autoProbeProc autoProbeMouse; collectDataProc collectData; diff --git a/tools/vmmouse_iopl.c b/tools/vmmouse_iopl.c index af13251..9d02934 100644 --- a/tools/vmmouse_iopl.c +++ b/tools/vmmouse_iopl.c @@ -57,9 +57,9 @@ /***************************************************************************/ /* I/O Permissions section */ /***************************************************************************/ -static Bool ExtendedEnabled = false; +static bool ExtendedEnabled = false; -Bool +bool xf86EnableIO() { if (ExtendedEnabled) @@ -92,7 +92,7 @@ xf86DisableIO() #include static int IoFd = -1; -Bool +bool xf86EnableIO() { if (IoFd >= 0) @@ -118,12 +118,12 @@ xf86DisableIO() #elif defined(VMMOUSE_OS_GENERIC) -static Bool ExtendedEnabled = false; +static bool ExtendedEnabled = false; extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); extern int iopl(int __level); -Bool xf86EnableIO(void) +bool xf86EnableIO(void) { if (ExtendedEnabled) return true; @@ -182,9 +182,9 @@ xf86DisableIO(void) #include #endif -static Bool ExtendedEnabled = false; +static bool ExtendedEnabled = false; -Bool +bool xf86EnableIO(void) { if (ExtendedEnabled)