Tk Source Code

View Ticket
Login
Ticket UUID: 58418fbd37769662b4219e6bbc389c69927353b0
Title: Incorrect pointer window reported upon <Leave>'ing toplevel after [wm withdraw]
Type: Bug Version: 8.6.11
Submitter: erikleunissen Created on: 2021-08-12 08:21:24
Subsystem: 48. Geometry Management Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2021-12-05 19:57:48
Resolution: None Closed By: nobody
    Closed on: 2021-12-05 12:23:09
Description:
If the mouse pointer is inside a toplevel window and the window is withdrawn from the screen, [winfo containing $pointerX $pointerY] returns an incorrect result after the <Leave> event has been delivered to the toplevel window. Most of the times (but not always), it returns the name of the toplevel window instead of the the empty string (which is the correct result). 

The attached script exercises the behaviour. Sample outputs of this script under a few different window managers:

(KDE Plasma and IceWM sample, output varies per invocation)
> ./exercise.tcl
<Leave> .t 154 179 ||
<Enter> .t 154 179 |.t|
<Leave> .t 154 179 |.t|
<Enter> .t 154 179 |.t|
<Leave> .t 154 179 |.t|
<Enter> .t 154 179 |.t|
<Leave> .t 154 179 ||
<Enter> .t 154 179 |.t|
<Leave> .t 154 179 |.t|

(TWM, consistently this same correct output on each invocation)
> ./exercise.tcl
<Leave> .t 152 179 ||
<Enter> .t 152 179 |.t|
<Leave> .t 152 179 ||
<Enter> .t 152 179 |.t|
<Leave> .t 152 179 ||
<Enter> .t 152 179 |.t|
<Leave> .t 152 179 ||
<Enter> .t 152 179 |.t|
<Leave> .t 152 179 ||

This suggests a race condition of sorts, probably with involvement of the window manager process, but the OS or X Server may play a role too. Given that the misbehaviour doesn't show under TWM, the role of and the interaction with the window manager is highly interesting.

Executing an "after 1" statement just before "winfo containing $pointerX $pointerY" (by uncommenting it in the script), makes the script consistently produce correct results under the circumstances where it otherwise failed.

Execution environment:
- tcl8.6.11
- Linux
- Window managers: KDE Plasma, IceWM, TWM
- The erratic misbehaviour has NOT been observed on Windows 7, where the correct result is returned consistently.

I'm unsure to which extent Tk is a "guilty party" here, because the misbehaviour doesn't exhibit:
- with the inverse operation: calling [wm deiconify] followed by an <Enter> event (this is also exercised by the attached script as you can see by the results);
- on MS Windows (that is, Windows 7);
- with window manager TWM
This suggests different guilty parties.

Apart from the case per se, the issue is a nuisance for the Tk library windetect (when detection events are reported without delay) and any aplications built on that. See for details if necessary:

    https://sourceforge.net/projects/tkwintrack/.
User Comments: fvogel added on 2021-12-05 19:57:48:

Oh sorry, your report was for Linux/X11, I somehow forgot about this when discussing ticket [18682cb277] mentioned by Marc, which is for macOS. Reopening since indeed there is no fix yet.


erikleunissen added on 2021-12-05 12:23:09:
Francois,

As you can see in this ticket, I originally reported this issue for Linux/X11, mentioning KDE/Plasma and TWM.

How do you know it's justified to not pursue this issue for Linux/x11?

Note: I don't intend *at all* to say that I disagree with closing this ticket now!

At 23/11/2021, 22:21 I wrote an email to you (to the address from which you also post to c.l.t.) with a lot more information regarding the subject of variability amongst desktop/windowmanagers under X11. In that email I also explained how ill-considered choices may lead to regrets ...

I hope you received that email, and maybe you understand my general logic/point after all.

I agree that proceeding with this awkward subject isn't easy. That's part of my point (please see also my email). Another part of my point is that acting without direction/policy among this variability may lead to a waste of effort.

With my previous post in this ticket, I tried to help preventing that waste specifically for this ticket.

Maybe better continued by email ...

fvogel added on 2021-12-04 21:06:42:

Ticket [18682cb277] mentioned by Marc being now closed, I think we can close this ticket as well.

Oh and Erik, I'm afraid I'm not really following your point in your latest post below. We are fixing issues in the bleeding edge of Tk (not exactly in 8.6.12 nor in 8.7a5) and do our best to cope with differences in environments (this is limited by what we have at hands, plus CI at GitHub Actions). It looks like your results show there are some race conditions in the code that trigger more often in some environments than in others, but characterizing such things is not easy and I'm puzzled about what could be the next steps with this unfortunately.


erikleunissen added on 2021-11-25 21:45:08:
This is a more detailed report of the windowing system combinations under Linux that exhibit the issue.

The windowing system combinations are indicated with a tuple of the format ws.de.wm(.th), where:
	ws = windowing system (always x11 in this case)
	de = desktop environment
	wm = window manager
	th = desktop environment theme (only for KDE: aurorae or non-aurorae)

The following table lists the windowing system combinations that have been inspected with the corresponding count of failures when running the script exercise.tcl with N=100 instead of N=5, on an OpenSuSE 15.0 Linux distribution.

Windowing system combination      Tk8.6.12  Tk8.7a5
------------------------------------------------------
x11.-.TWM                            0          0
x11.Enlightenment.Enlightenment     70        100
x11.ICEWM.IceWM                     64         93
x11.KDE.KWin.aurorae                 1          6
x11.KDE.KWin.non-aurorae             2          3
x11.KDE.Sawfish.aurorae              0          1
x11.KDE.Sawfish.non-aurorae          0          1
x11.WindowMaker.WindowMaker          0          3
x11.XFCE.Sawfish                     0          3
x11.XFCE.Xfwm4                       0          0
------------------------------------------------------

    Note: the mention of "KDE/Plasma window manager" in previous reports in this ticket
          is inadequate. What was meant is the x11.KDE.KWin.aurorae in the table above.


This information is a reason to ask the question:

	"to which combination of de-wm do we intend to adapt Tk?"

I'm not saying that this information is enough to answer that question because:
- desktop environments and window managers can be highly configurable. Results of this investigation may change significantly with other configurations than mine.
- the OpenSuSE 15.0 system is quite old. Newer ws-combinations may perform differently.
- there are more desktop environments and window managers than those in the list above

----

fvogel added on 2021-11-23 22:31:59:

For reference, the ticket mentioned below is [18682cb277].


marc_culler (claiming to be Marc Culler) added on 2021-11-19 20:54:58:
The test script now shows the correct result on macOS with the tip of branch
macos_enter_leave.  Of course fixing this required making Enter and Leave
events work at all on macOS.  Doing that was the main point of the
macos_enter_leave branch, and required a pretty large change.  The details
will appear in another ticket.

marc_culler (claiming to be Marc Culler) added on 2021-11-12 15:58:45:
On macOS it appears that withdrawing a window containing the pointer does
not generate a <Leave> event at all.  And moving a window so that it contains
the pointer does not generate an <Enter> event.

Attachments: