Tk Source Code

View Ticket
Login
Ticket UUID: 593eb0227cfa97adb9c7485dcc59a6e0bab93ded
Title: X.h: define ControlMask and None as macros, even on Win32
Type: Patch Version: 8.6.10
Submitter: chrstphrchvz Created on: 2023-11-06 01:47:56
Subsystem: 85. Win Build Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-11-10 13:11:35
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2023-11-10 13:11:35
Description:

I proposed backporting the fix for [9e31fd9449] to Perl/Tk: https://github.com/eserte/perl-tk/pull/89

But Perl/Tk still contains some code which expects ControlMask and None to be defined as macros, so others have proposed this additional change:

--- xlib/X11/X.h.orig
+++ xlib/X11/X.h
@@ -75,6 +75,8 @@ typedef unsigned long KeyCode;	/* In order to use IME, the Macintosh needs
 
 #ifndef _WIN32
 #   define None              0L      /* See bug [9e31fd9449] and below */
+#else
+#   define None              None    /* uses the enum below */
 #endif
 
 #define ParentRelative       1L	/* background pixmap in CreateWindow
@@ -183,6 +185,8 @@ are reserved in the protocol for errors and replies. */
 #define LockMask		(1<<1)
 #ifndef _WIN32
 #   define ControlMask		(1<<2) /* See bug [9e31fd9449] and below */
+#else
+#   define ControlMask          ControlMask /* uses the enum below */
 #endif
 #define Mod1Mask		(1<<3)
 #define Mod2Mask		(1<<4)

Does Tcl/Tk also find this approach preferable?

User Comments: jan.nijtmans added on 2023-11-10 13:11:35:

> Should I add this comment ?

Sure, go ahead! (I only saw your comment after merging it up to Tk 8.7)


jan.nijtmans added on 2023-11-10 13:08:55:

Fixed [bc8c792fe4d50902|here], as suggested.

Thanks!


oehhar added on 2023-11-10 12:37:35:

Jan, I think it would be great to have a big comment above the introduced lines by [bc8c792f] why this obvious non-functioning is there.

Maybe something like:

/* Pert-Tk expects None and ControlMask to be a macro see ticket [593eb0227c] */

Should I add this comment ?

Thank you, Harald