Tk Source Code

View Ticket
Login
Ticket UUID: 6bdf1a7ec35114f7475ed9f1efb9d74ba6f831a5
Title: Bind mechanism vs. GNOME
Type: Bug Version: 9
Submitter: chw Created on: 2024-12-08 06:47:57
Subsystem: 69. Events Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2024-12-10 11:31:16
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2024-12-10 11:31:16
Description:
The GNOME keyboard infrastructure badly interacts with Tk 9.x when
multiple keyboard maps can be chosen by GNOME menu and the currently
selected map asserts the modifier masks 0x2000 and/or 0x4000. These
masks happen to be the modifiers for Button6 and Button7 in Tk.
On my laptop I have this situation:

                      German -> 0x0000
German (eliminate dead keys) -> 0x2000
                English (US) -> 0x4000
                English (UK) -> 0x0000
                      French -> 0X2000

The effect can be observed with the widget demo, whose links to the
various demos in the front page cannot be activated when certain
keyboard maps are selected.

Other desktop environments (KDE?, XFCE?...) are possibly affected, too.

The following patch moves the Button6 and Button7 modifiers out of the
way (but experts, I'm very unsure that this is the correct solution,
so please review it).

Index: generic/tkInt.h
==================================================================
--- generic/tkInt.h
+++ generic/tkInt.h
@@ -1035,14 +1035,22 @@
 #ifndef Button9
 # define Button9 9
 #endif
 
 #ifndef Button6Mask
+#if !(defined(_WIN32) && !defined(MAC_OSX_TK))
+# define Button6Mask (AnyModifier<<6)
+#else 
 # define Button6Mask (1<<13)
+#endif
 #endif
 #ifndef Button7Mask
+#if !(defined(_WIN32) && !defined(MAC_OSX_TK))
+# define Button7Mask (AnyModifier<<7)
+#else
 # define Button7Mask (1<<14)
+#endif
 #endif
 #ifndef Button8Mask
 # define Button8Mask (AnyModifier<<4)
 #endif
 #ifndef Button9Mask
User Comments: jan.nijtmans added on 2024-12-10 11:31:16:

I'm OK with that. Thanks!


chw added on 2024-12-08 22:37:31:
OK, Jan, but then what about being somewhat more consequent
and make it like so (proof of concept):

/*
 * The Button<B>Mask modifieres for <B> in {6 7 8 9}
 * are internally used by Tk. They must be above the
 * AnyModifier bit since anything below is reserved
 * for the X protocol.
 */

#define Button6Mask (AnyModifier<<6)
#define Button7Mask (AnyModifier<<7)
#define Button8Mask (AnyModifier<<8)
#define Button9Mask (AnyModifier<<9)

jan.nijtmans added on 2024-12-08 22:12:16:

Thanks for noting this!

Your solution is fine: the "Button6Mask" and "Button7Mask" defines are only used internally in Tk. It's purpose is to be able to move the bits to somewhere else, if the necessity arises.

Fixed[4166cb483d55085b|here]. This will be in Tk 9.0.1.