From dfbae2e5941b47f949c058405cc0b91496e35bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Tue, 25 Oct 2022 15:15:23 +0200 Subject: [PATCH] Do not define "ControlMask" macro. The name "ControlMask" is already defined in processthreadsapi.h OS=Win32. Instead use "ControlMask2". See issue #87 for more information. --- Xlib/X/X.xs | 4 ++-- pTk/mTk/generic/tkBind.c | 2 +- pTk/mTk/win/tkWinKey.c | 8 ++++---- pTk/mTk/win/tkWinPointer.c | 2 +- pTk/mTk/win/tkWinX.c | 4 ++-- pTk/mTk/xlib/X11/X.h | 5 ++++- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Xlib/X/X.xs b/Xlib/X/X.xs index b04418d2..aad91786 100644 --- a/Xlib/X/X.xs +++ b/Xlib/X/X.xs @@ -614,8 +614,8 @@ int arg; goto not_there; #endif if (strEQ(name, "ControlMask")) -#ifdef ControlMask - return ControlMask; +#ifdef ControlMask2 + return ControlMask2; #else goto not_there; #endif diff --git a/pTk/mTk/generic/tkBind.c b/pTk/mTk/generic/tkBind.c index 75b873b0..9f63237a 100644 --- a/pTk/mTk/generic/tkBind.c +++ b/pTk/mTk/generic/tkBind.c @@ -421,7 +421,7 @@ typedef struct { #define MULT_CLICKS 7 static ModInfo modArray[] = { - {"Control", ControlMask, 0}, + {"Control", ControlMask2, 0}, {"Shift", ShiftMask, 0}, {"Lock", LockMask, 0}, {"Meta", META_MASK, 0}, diff --git a/pTk/mTk/win/tkWinKey.c b/pTk/mTk/win/tkWinKey.c index 7f5a3385..a9588f5f 100644 --- a/pTk/mTk/win/tkWinKey.c +++ b/pTk/mTk/win/tkWinKey.c @@ -217,7 +217,7 @@ KeycodeToKeysym(keycode, state, noascii) memset(keys, 0, 256); if (state & ShiftMask) keys[VK_SHIFT] = 0x80; - if (state & ControlMask) + if (state & ControlMask2) keys[VK_CONTROL] = 0x80; if (state & Mod2Mask) keys[VK_MENU] = 0x80; @@ -395,8 +395,8 @@ TkpGetKeySym(dispPtr, eventPtr) * is no keysym defined, try without the modifiers. */ - if ((sym == NoSymbol) && ((state & ControlMask) || (state & Mod2Mask))) { - state &= ~(ControlMask | Mod2Mask); + if ((sym == NoSymbol) && ((state & ControlMask2) || (state & Mod2Mask))) { + state &= ~(ControlMask2 | Mod2Mask); sym = KeycodeToKeysym(eventPtr->xkey.keycode, state, 0); } if ((sym == NoSymbol) && (state & ShiftMask)) { @@ -578,7 +578,7 @@ TkpSetKeycodeAndState(tkwin, keySym, eventPtr) if (shift & 1) eventPtr->xkey.state |= ShiftMask; if (shift & 2) - eventPtr->xkey.state |= ControlMask; + eventPtr->xkey.state |= ControlMask2; if (shift & 4) eventPtr->xkey.state |= Mod2Mask; eventPtr->xkey.keycode = (KeyCode) (result & 0xff); diff --git a/pTk/mTk/win/tkWinPointer.c b/pTk/mTk/win/tkWinPointer.c index 5d504161..e66ff01b 100644 --- a/pTk/mTk/win/tkWinPointer.c +++ b/pTk/mTk/win/tkWinPointer.c @@ -60,7 +60,7 @@ TkWinGetModifierState() state |= ShiftMask; } if (GetKeyState(VK_CONTROL) & 0x8000) { - state |= ControlMask; + state |= ControlMask2; } if (GetKeyState(VK_MENU) & 0x8000) { state |= ALT_MASK; diff --git a/pTk/mTk/win/tkWinX.c b/pTk/mTk/win/tkWinX.c index a050a18f..02c49d09 100644 --- a/pTk/mTk/win/tkWinX.c +++ b/pTk/mTk/win/tkWinX.c @@ -1247,7 +1247,7 @@ GetState(message, wParam, lParam) mask = ShiftMask; break; case VK_CONTROL: - mask = ControlMask; + mask = ControlMask2; break; case VK_MENU: mask = ALT_MASK; @@ -1666,7 +1666,7 @@ TkWinResendEvent(wndproc, hwnd, eventPtr) if (eventPtr->xbutton.state & ShiftMask) { wparam |= MK_SHIFT; } - if (eventPtr->xbutton.state & ControlMask) { + if (eventPtr->xbutton.state & ControlMask2) { wparam |= MK_CONTROL; } lparam = MAKELPARAM((short) eventPtr->xbutton.x, diff --git a/pTk/mTk/xlib/X11/X.h b/pTk/mTk/xlib/X11/X.h index a1cf10c8..9f47ccba 100644 --- a/pTk/mTk/xlib/X11/X.h +++ b/pTk/mTk/xlib/X11/X.h @@ -179,7 +179,10 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -#define ControlMask (1<<2) + /* Use ControlMask2 due to conflict with ControlMask defined in processthreadsapi.h + for Win32, see https://github.com/eserte/perl-tk/issues/87 for more information + */ +#define ControlMask2 (1<<2) #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5)