From c505cb05e89e61c208b36a80490702463cad8c94 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 28 Jan 2020 20:50:42 +0000 Subject: Restore %A for KeyRelease on Linux --- unix/tkUnixKey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 1bfbf26..003b090 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -126,11 +126,11 @@ TkpGetString( } /* - * Only do this for KeyPress events, otherwise + * Only do this for KeyPress and KeyRelease events, otherwise * further Xlib function behavior might be undefined. */ - if (eventPtr->type != KeyPress) { + if (event.type != KeyPress && event.type != KeyRelease)) { len = 0; Tcl_DStringSetLength(dsPtr, len); goto done; -- cgit v0.12 From c4a0a7813cf3c3b6c7a4bcf197069e33752335b8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 28 Jan 2020 20:56:08 +0000 Subject: Add test bind-16.35.1 checking %A with --- tests/bind.test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/bind.test b/tests/bind.test index 7cb515d..c4a6b3a 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -2049,6 +2049,32 @@ test bind-16.35 {ExpandPercents procedure} -constraints { } -cleanup { destroy .t.f } -result {a A { } {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} \u00e9} +test bind-16.35.1 {ExpandPercents procedure} -constraints { + nonPortable +} -setup { + frame .t.f -class Test -width 150 -height 100 + pack .t.f + focus -force .t.f + update + set x {} +} -body { + bind .t.f {lappend x "%A"} + event generate .t.f + event generate .t.f -state 1 + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f -state 1 + event generate .t.f -state 1 + event generate .t.f + event generate .t.f + event generate .t.f + set x +} -cleanup { + destroy .t.f +} -result {a A { } {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} \u00e9} test bind-16.36 {ExpandPercents procedure} -setup { frame .t.f -class Test -width 150 -height 100 pack .t.f -- cgit v0.12 From 1f43eeb07112067fb845368883c8157d1275707a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 28 Jan 2020 21:02:58 +0000 Subject: Oops. Forgot to change the test content correctly. --- tests/bind.test | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/bind.test b/tests/bind.test index c4a6b3a..7a91999 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -2059,18 +2059,18 @@ test bind-16.35.1 {ExpandPercents procedure} -constraints { set x {} } -body { bind .t.f {lappend x "%A"} - event generate .t.f - event generate .t.f -state 1 - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f -state 1 - event generate .t.f -state 1 - event generate .t.f - event generate .t.f - event generate .t.f + event generate .t.f + event generate .t.f -state 1 + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f + event generate .t.f -state 1 + event generate .t.f -state 1 + event generate .t.f + event generate .t.f + event generate .t.f set x } -cleanup { destroy .t.f -- cgit v0.12 From a2c62965116d35647559acb442acb9a078d453fe Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 28 Jan 2020 21:04:41 +0000 Subject: Today is not a good day. event->type rather than event.type --- unix/tkUnixKey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 003b090..95ce2c3 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -130,7 +130,7 @@ TkpGetString( * further Xlib function behavior might be undefined. */ - if (event.type != KeyPress && event.type != KeyRelease)) { + if (event->type != KeyPress && event->type != KeyRelease)) { len = 0; Tcl_DStringSetLength(dsPtr, len); goto done; -- cgit v0.12 From 233af73726814665b09dc4fc4c814ab9663fbf57 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 28 Jan 2020 21:05:28 +0000 Subject: Sigh... --- unix/tkUnixKey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 95ce2c3..acad81f 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -130,7 +130,7 @@ TkpGetString( * further Xlib function behavior might be undefined. */ - if (event->type != KeyPress && event->type != KeyRelease)) { + if (eventPtr->type != KeyPress && eventPtr->type != KeyRelease)) { len = 0; Tcl_DStringSetLength(dsPtr, len); goto done; -- cgit v0.12 From bfbc68c61c61cd01da46a91806f7bd3b6bba4e2d Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 11 Feb 2020 20:28:30 +0000 Subject: Let branch build --- unix/tkUnixKey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index acad81f..21fa81a 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -130,7 +130,7 @@ TkpGetString( * further Xlib function behavior might be undefined. */ - if (eventPtr->type != KeyPress && eventPtr->type != KeyRelease)) { + if (eventPtr->type != KeyPress && eventPtr->type != KeyRelease) { len = 0; Tcl_DStringSetLength(dsPtr, len); goto done; -- cgit v0.12 From 0bf2c0e761b6fa6e2b292a78207699b09f73afac Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 11 Feb 2020 20:53:17 +0000 Subject: Revert the 6 previous commits, returning therefore to the state at [eaad647e]. --- tests/bind.test | 26 -------------------------- unix/tkUnixKey.c | 4 ++-- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/tests/bind.test b/tests/bind.test index 7a91999..7cb515d 100644 --- a/tests/bind.test +++ b/tests/bind.test @@ -2049,32 +2049,6 @@ test bind-16.35 {ExpandPercents procedure} -constraints { } -cleanup { destroy .t.f } -result {a A { } {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} \u00e9} -test bind-16.35.1 {ExpandPercents procedure} -constraints { - nonPortable -} -setup { - frame .t.f -class Test -width 150 -height 100 - pack .t.f - focus -force .t.f - update - set x {} -} -body { - bind .t.f {lappend x "%A"} - event generate .t.f - event generate .t.f -state 1 - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f - event generate .t.f -state 1 - event generate .t.f -state 1 - event generate .t.f - event generate .t.f - event generate .t.f - set x -} -cleanup { - destroy .t.f -} -result {a A { } {\r} {{}} {{}} { } {\$} \\\{ {{}} {{}} \u00e9} test bind-16.36 {ExpandPercents procedure} -setup { frame .t.f -class Test -width 150 -height 100 pack .t.f diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 21fa81a..1bfbf26 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -126,11 +126,11 @@ TkpGetString( } /* - * Only do this for KeyPress and KeyRelease events, otherwise + * Only do this for KeyPress events, otherwise * further Xlib function behavior might be undefined. */ - if (eventPtr->type != KeyPress && eventPtr->type != KeyRelease) { + if (eventPtr->type != KeyPress) { len = 0; Tcl_DStringSetLength(dsPtr, len); goto done; -- cgit v0.12 From ed0fcbe0584190b51ccafd4d06d6b893e7ecba67 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 11 Feb 2020 21:07:55 +0000 Subject: Document that the %A substitution is not valid on Linux, making the manual match the code. --- doc/bind.n | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/bind.n b/doc/bind.n index 1ecae86..fc0b490 100644 --- a/doc/bind.n +++ b/doc/bind.n @@ -517,10 +517,11 @@ coordinates of the window relative to its parent window. .IP \fB%A\fR 5 Substitutes the UNICODE character corresponding to the event, or the empty string if the event does not correspond to a UNICODE character -(e.g. the shift key was pressed). \fBXmbLookupString\fR (or +(e.g. the shift key was pressed). On Linux, \fBXmbLookupString\fR (or \fBXLookupString\fR when input method support is turned off) does all the work of translating from the event to a UNICODE character. -Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. +On Linux, valid only for \fBKeyPress\fR event. On Windows and macOS, +valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. .IP \fB%B\fR 5 The \fIborder_width\fR field from the event. Valid only for \fBConfigure\fR, \fBConfigureRequest\fR, and \fBCreate\fR events. -- cgit v0.12 From 6f68bdb000e2b8a850631d74f818ceb9159bcf51 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 11 Feb 2020 21:40:29 +0000 Subject: Simplify the code slightly: we did already bail out earlier when (eventPtr->type != KeyPress) --- unix/tkUnixKey.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 1bfbf26..045d291 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -138,8 +138,7 @@ TkpGetString( #ifdef TK_USE_INPUT_METHODS if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM) - && (winPtr->inputContext != NULL) - && (eventPtr->type == KeyPress)) { + && (winPtr->inputContext != NULL)) { Status status; #if X_HAVE_UTF8_STRING @@ -194,8 +193,7 @@ TkpGetString( { /* * Fall back to convert a keyboard event to a UTF-8 string using - * XLookupString. This is used when input methods are turned off and - * for KeyRelease events. + * XLookupString. This is used when input methods are turned off. * * Note: XLookupString() normally returns a single ISO Latin 1 or * ASCII control character. -- cgit v0.12 From 431ba75b41a1c335fecd8b60c38477cf770e0976 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 16 Feb 2020 16:50:34 +0000 Subject: Be more exact in the bind.n man page --- doc/bind.n | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/bind.n b/doc/bind.n index fc0b490..0d48f72 100644 --- a/doc/bind.n +++ b/doc/bind.n @@ -517,10 +517,10 @@ coordinates of the window relative to its parent window. .IP \fB%A\fR 5 Substitutes the UNICODE character corresponding to the event, or the empty string if the event does not correspond to a UNICODE character -(e.g. the shift key was pressed). On Linux, \fBXmbLookupString\fR (or +(e.g. the shift key was pressed). On X11, \fBXmbLookupString\fR (or \fBXLookupString\fR when input method support is turned off) does all the work of translating from the event to a UNICODE character. -On Linux, valid only for \fBKeyPress\fR event. On Windows and macOS, +On X11, valid only for \fBKeyPress\fR event. On Windows and macOS/aqua, valid only for \fBKeyPress\fR and \fBKeyRelease\fR events. .IP \fB%B\fR 5 The \fIborder_width\fR field from the event. Valid only for -- cgit v0.12