Attachment "test-e3888d5820.tcl" to
ticket [e3888d58]
added by
erikleunissen
2020-01-06 16:00:27.
#! /usr/local/bin/wish8.6
package require tcltest
namespace import -force ::tcltest::*
test bug-e3888d5820 {pointer warp with grab on master, bug e3888d582045d0817375b66ae7f5e46f93f809e9} -setup {
# proc twait: wait for a specified duration while allowing the screen to be updated
proc twait {duration} {
set ::_twait 1; after $duration {unset ::_twait}
vwait ::_twait
}
package require Tk
} -body {
#
# Ensure that the mouse pointer never <Enters> the toplevel used for this test. To this end,
# we move the mouse pointer out of the way to the top left corner of the screen.
# This only succeeds if a (any) toplevel is mapped; we use the root window for that purpose.
#
wm deiconify .
twait 2000
event generate {} <Motion> -warp 1 -x 1 -y 1
wm withdraw .
twait 500
# create the toplevel for the test and position it away from the mouse pointer
toplevel .t
wm geometry .t 200x200+300+300
set label [label .t.l -height 5 -width 20 -highlightthickness 2 -highlightbackground black -bg yellow -text " "]
pack $label -side bottom
wm deiconify .t
twait 2000
event generate .t <Motion> -warp 1 -x -50 -y 50
twait 200
# Grab the toplevel (highlighting is not essential, it only facilitates
# visual recognition of the grab window), and warp the pointer into the label.
.t configure -bg #FF9999; grab .t
twait 1000
event generate $label <Motion> -warp 1 -x 10 -y 10
twait 200
#
# Without the fix for bug e3888d5820, the mouse pointer remains stuck
# in the top left corner of the grabbed toplevel window.
#
#
# Define the precise test result.
# What accuracy do we need? I'm reluctant to specifying exact screen
# coordinates because these can depend on window decorations by thw wm.
# Therefore just report the window that contains the pointer.
#
set coords [winfo pointerxy $label]
set containingWindow [winfo containing {*}$coords]
if {$containingWindow eq $label} {
set result 1
} else {
puts [outputChannel] "pointer remained stuck at screen coordinates $coords in $containingWindow (cf. Fossil bug ticket e3888d5820)."
set result 0
}
} -cleanup {
destroy .t
unset -nocomplain label result
rename twait {}
} -result 1 -output ""
tcltest::cleanupTests
# EOF