|
2026-10-19
| ||
| 17:13 | Merge main. Main contains the earlier check-ins of this branch in its history, but not the fix for [a4fa3ad2d6] and test unixEmbed-5.4, which the merge removed; restore them. Merging this branch into main now brings the fix. check-in: 11bfb379 user: serhiy.storchaka tags: x11-embed-focus-return | |
|
2026-10-09
| ||
| 08:46 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: 1472aeed user: serhiy.storchaka | |
| 08:37 | unixEmbed tests [a4fa3ad2d6]: make the focus tests independent of the previous tests. Restart the child process in the cleanup of unixEmbed-5.4 before destroying the container, so that its focused entry is not redrawn after the container is destroyed (which killed it with an X error, see [f1fe739a4f]) and its focus state does not affect the following tests. Move the pointer away in the setup of unixEmbed-5.1 to 5.4, 7.1 and 7.2, as in 8.1: without a window manager the child got the focus implicitly if its main window appeared under the pointer (see [0c3bb74e37]). check-in: f98ef68b user: serhiy.storchaka tags: x11-embed-focus-return | |
|
2026-10-08
| ||
| 21:25 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: 9ceb6770 user: jan.nijtmans | |
| 21:02 | • Ticket [a4fa3ad2]: 3 changes artifact: 622dce6e user: serhiy.storchaka | |
| 20:20 | • Ticket [a4fa3ad2]: 3 changes artifact: c7777a6c user: jan.nijtmans | |
| 20:00 | Fix [a4fa3ad2d6]: event misbehavior with certain widgets when embedding closed check-in: 75525b88 user: jan.nijtmans tags: mistake | |
| 19:58 | Fix [a4fa3ad2d6]: event misbehavior with certain widgets when embedding closed check-in: cb8992a3 user: jan.nijtmans tags: mistake | |
| 19:52 | Fix [a4fa3ad2d6]: event misbehavior with certain widgets when embedding check-in: 1dea0b97 user: jan.nijtmans tags: x11-embed-focus-return | |
|
2026-09-25
| ||
| 21:54 | • Ticket [1474465f] Debian 8 focus test failures status still Open with 3 other changes artifact: 77702d9c user: serhiy.storchaka | |
|
2026-09-22
| ||
| 06:29 | • Ticket [a53a902a] overrideredirect on linux/mac prevents certain binds from working status still Open with 3 other changes artifact: cba42443 user: serhiy.storchaka | |
| 06:29 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: e535267d user: serhiy.storchaka | |
| 06:29 | • Ticket [220892ff] focus changes forgotten during grab status still Open with 3 other changes artifact: efd5838c user: serhiy.storchaka | |
| 06:22 | Add a test for [a4fa3ad2d6], with a testxfocus command which returns the Tk window with the X input focus and can set it as a window manager does check-in: 63c88e8a user: serhiy.storchaka tags: x11-embed-focus-return | |
|
2026-09-19
| ||
| 16:22 | • Closed ticket [480158ff]: initial focus fails in child interp plus 5 other changes artifact: e7835143 user: serhiy.storchaka | |
| 15:03 | • Closed ticket [936195ff]: Reset focus to embedded windows (bug fix) plus 5 other changes artifact: 3590101a user: serhiy.storchaka | |
| 13:00 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: 8f640ab2 user: serhiy.storchaka | |
| 12:59 |
Fix [a4fa3ad2d6]: event misbehavior with certain widgets when embedding
After the embedded application claimed the focus, the window manager set the X focus back to the container's toplevel, and Tk ignored that FocusIn (NotifyInferior), so key events went to the container until a Leave/Enter cycle. Pass the X focus on to the embedded application again. check-in: eb2b41d5 user: serhiy.storchaka tags: x11-embed-focus-return | |
|
2020-08-18
| ||
| 19:10 | • Ticket [a4fa3ad2] event misbehavior with certain widgets when embedding status still Open with 3 other changes artifact: ea8b096d user: fvogel | |
|
2019-02-08
| ||
| 16:41 | • Ticket [a4fa3ad2]: 3 changes artifact: 84b649d4 user: marc_culler | |
|
2017-04-20
| ||
| 21:10 | • Ticket [a4fa3ad2]: 3 changes artifact: 343a2fc9 user: bll | |
| 18:36 | • Ticket [a4fa3ad2]: 3 changes artifact: 60ce336f user: bll | |
| 17:23 | • Ticket [a4fa3ad2]: 3 changes artifact: 93c397b1 user: bll | |
| 15:28 | • New ticket [a4fa3ad2]. artifact: 85f4ad30 user: boombox120 | |
| Ticket UUID: | a4fa3ad2d64141fd1f7f07032f3030f317cb9d0c | |||
| Title: | event misbehavior with certain widgets when embedding | |||
| Type: | Bug | Version: | 8.6.6 | |
| Submitter: | boombox120 | Created on: | 2017-04-20 15:28:43 | |
| Subsystem: | 69. Events | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Open | Last Modified: | 2026-10-09 08:46:47 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
Below I show the src code for two programs. tk_parent.tcl - this creates a toplevel window for use in embedding the child program and for comparison creates an entry widget. tk_child.tcl - this is called by tk_parent.tcl and creates an entry widget. When tk_parent.tcl is started and the child window appears you can't type anything into the tk_child's entry widget. If you left click in the entry widget and then move the focus in/out of tk_child the entry widget works. I didn't include it in the programs below but when bind <FocusIn> and <FocusOut> to various windows I find that when I click the entry window the first time I get <FocusOut> events for the top window and the entry window. After that it starts working properly. It looks like the same thing is true for the text widget and perhaps others. ----- tk_parent.tcl ------------ #!/bin/wish toplevel .top -container true set top2_window_id [ winfo id .top ] update entry .e1 pack .e1 set ret [ exec ./tk_child.tcl -use $top2_window_id & ] ----- tk_child.tcl ------------ #!/bin/wish entry .e1 pack .e1 | |||
| User Comments: |
serhiy.storchaka added on 2026-10-09 08:46:47:
This was a hard one: the failures were difficult to reproduce, and making the tests independent exposed further bugs. Two new tickets:
The failures here are caused by [f1fe739a4f]: test unixEmbed-5.4 leaves the focus in the embedded entry, and when the container is destroyed in its cleanup, the blinking insertion cursor makes the entry redraw into a pixmap for a window which no longer exists. The resulting X error kills the child process, so the following tests fail with "broken pipe". It depends on timing: I could only reproduce it by running 8 test suites in parallel (9 failures in 24 runs). Running only unixEmbed.test, 24 copies in parallel, reproduces it less often (21 failures in 720 runs). The unixEmbed tests in branch x11-embed-focus-return are now independent of these fixes and of the previous tests. unixEmbed-5.4 restarts the child process in its cleanup. This alone made unixEmbed-7.1 fail in every full test suite run, but not when unixEmbed.test ran alone: textTag.test leaves the pointer over the place where the new child's main window appears, and textWind.test withdraws the main window, so that the X focus reverts to the root window. The child then got the focus implicitly ([0c3bb74e37]), and the key in unixEmbed-7.1 was not redirected to the container. The focus tests now move the pointer away first. Since x11-embed-focus-return is now an ancestor of main (through the merge of spinbox-paste-focus), it needs to be merged with --baseline or cherry-picked, otherwise its changes are lost. jan.nijtmans added on 2026-10-08 21:25:11: I cannot explain, but you can see the failed run here: https://github.com/nijtmans/tk/actions/runs/37835555887/job/113511546477 serhiy.storchaka added on 2026-10-08 21:02:14: I cannot reproduce these failures on X11: with branch x11-embed-focus-return, unixEmbed.test passes alone (6 runs, with and without a window manager) and in two full test suite runs, all under Xvfb; unixEmbed-5.4 runs and passes. The "broken pipe" errors mean that the child process used by the tests had exited, probably already during unixEmbed-5.4 or 6.1. Jan, how did you run the tests: on which X server and window manager, the whole test suite or only unixEmbed.test? Is there an error message from the child process before the first failure? jan.nijtmans added on 2026-10-08 20:20:50: I'm seeing those test failures on X11 in the fix branch, although I cannot explain it:
==== unixEmbed-6.1 EmbedGeometryRequest procedure, window changes size FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
pack .f1
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
update
bind .t1 <Configure> {lappend x {configure .t1 %w %h}}
set x {}
.t1 configure -width 300 -height 120
update
list $x [winfo geom .t1]
}
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
update
bind .t1 <Configure> {lappend x {configure .t1 %w %h}}
set x {}
..."
("uplevel" body line 5)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-6.1 FAILED
==== unixEmbed-6.2 EmbedGeometryRequest procedure, window changes size FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
place .f1 -width 200 -height 200
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
update
bind .t1 <Configure> {lappend x {configure .t1 %w %h}}
set x {}
.t1 configure -width 300 -height 120
update
list $x [winfo geom .t1]
}
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 4)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-6.2 FAILED
==== unixEmbed-7.1 TkpRedirectKeyEvent procedure, forward keystroke FAILED
==== Contents of test case:
deleteWindows
frame .f1 -container 1 -width 200 -height 50
pack .f1
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
}
focus -force .
bind . <Key> {lappend x {key %A %E}}
set x {}
set y [childTkProcess eval {
update
bind .t1 <Key> {lappend y {key %A}}
set y {}
event generate .t1 <Key> -keysym a
set y
}]
update
list $x $y
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 5)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-7.1 FAILED
==== unixEmbed-7.2 TkpRedirectKeyEvent procedure, don't forward keystroke width FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
pack .f1
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1
}
update
focus -force .f1
update
bind . <Key> {lappend x {key %A}}
set x {}
set y [childTkProcess eval {
update
bind .t1 <Key> {lappend y {key %A}}
set y {}
event generate .t1 <Key> -keysym b
set y
}]
update
list $x $y
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 4)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-7.2 FAILED
==== unixEmbed-8.1 TkpClaimFocus procedure FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
frame .f2 -width 200 -height 50
pack .f1 .f2
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1 -highlightthickness 2 -bd 2 -relief sunken
}
focus -force .f2
update
list [childTkProcess eval {
focus .t1
set x [list [focus]]
update
after 500
update
lappend x [focus]
}] [focus]
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 5)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-8.1 FAILED
==== unixEmbed-9.2 EmbedWindowDeleted procedure, check embeddedPtr FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
pack .f1
update
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1 -highlightthickness 2 -bd 2 -relief sunken
set x {}
lappend x [testembed]
destroy .t1
lappend x [testembed]
}
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 5)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-9.2 FAILED
==== unixEmbed-9.3 embedded window redrawn after the container was destroyed FAILED
==== Contents of test case:
frame .f1 -container 1 -width 200 -height 50
pack .f1
update
childTkProcess eval "set w1 [winfo id .f1]"
childTkProcess eval {
destroy {*}[winfo children .]
toplevel .t1 -use $w1 -bg green -bd 2 -relief sunken
update
}
# Destroy the container while the child does not process events, so
# that it redraws the embedded window which does not exist any more.
after 200 {destroy .f1; update}
childTkProcess eval {
after 1000
.t1 configure -bg blue
update idletasks
winfo pointerxy .
set x alive
}
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: error flushing "file8": broken pipe
while executing
"flush $fd"
(procedure "childTkProcess" line 44)
invoked from within
"childTkProcess eval "set w1 [winfo id .f1]""
("uplevel" body line 5)
invoked from within
"uplevel 1 $script"
---- errorCode: POSIX EPIPE {broken pipe}
==== unixEmbed-9.3 FAILED
serhiy.storchaka added on 2026-09-22 06:29:42: Added test unixEmbed-5.4 in [63c88e8a6d]: after the embedded application (in a child process) claimed the focus, the X focus is set to the container's toplevel as a click-to-focus window manager does, and the embedded application must get it back. It uses a new test command testxfocus ?window? (generic/tkTest.c, X11 only) which returns the Tk window with the X input focus and, with an argument, sets it as a window manager does. The same command is added on the branch for [220892], and the branch for [a53a902ac6] has a simpler version of it without the optional argument. Merging them will conflict in generic/tkTest.c and tests/constraints.tcl: keep the version with the optional argument (it is a superset) and one constraint line, and keep the tests of all branches. serhiy.storchaka added on 2026-09-19 13:00:16: After the embedded application claimed the focus, the window manager set the X focus back to the container's toplevel, and Tk ignored that FocusIn (NotifyInferior), so key events went to the container until a Leave/Enter cycle. Fixed in [eb2b41d5b3] (branch x11-embed-focus-return). marc_culler added on 2019-02-08 16:41:12: The failure on macOS (invalid window id) is expected. On the Mac, Tk does not support embedding into a window that belongs to a different process. bll added on 2017-04-20 21:10:17: After clicking in the child entry widget and moving the mouse cursor outside the frame:
(unknown window: no associated TkWindow structure)
Move the mouse cursor to the child window, the events are:
FocusIn, unknown window
GenerateFocusEvent for parent container window
FocusIn, parent container window (EmbedFocusProc invoked)
FocusOut, unknown window
FocusIn, unknown window
GenerateFocusEvent for child entry widget
*** This should probably be a focus event for the child top window only
FocusIn, child top window
FocusIn, child entry widget
Move the mouse cursor further in to the child entry widget:
Enter, unknown window
Enter, unknown window
Enter, parent container window
Enter, child top window
Enter, child entry widget
FocusOut, unknown window
FocusIn, unknown window (two events are queued, the event handler
handles the focus-out first, then the focus-in)
GenerateFocusEvent for child entry widget
*** but this appears to be generating a focus-out event, not focus-in.
*** This should probably be a focus-IN event for the child entry widget
FocusOut, child entry widget
FocusOut, child top window
bll added on 2017-04-20 18:36:41: X11: If I click in the child entry box, move the mouse cursor out of the window, then move the mouse cursor to the window frame, but not in the entry box, the focus is in the entry widget and I can type in it. If I instead click in the child entry box, move the mouse cursor out of the window, then move the mouse cursor to the window, in the entry widget, the focus for the entry widget is not set. I have to move the cursor out of the window entirely to reset the focus. It almost seems like the focus state is backwards. Note: many of the Tk container/use tests use same application or a child interpreter to test -- the tests in these cases work. I have not been able to create a test case that can return a result, as all 'grab', 'focus', 'event generate' work as expected, but generating the events externally fails. bll added on 2017-04-20 17:23:35: Confirmed issue on X11. The child is essentially unusable.
Works on Windows.
Mac OS X:
application-specific initialization failed: The window ID 0x7fbd9d8abf90 does not correspond to a valid Tk Window
Error in startup script: can't invoke "label" command: application has been destroyed
while executing
"label .l2 -text child"
(file "./c.tcl" line 2)
| |||
