diff --git a/changelog.txt b/changelog.txt index 714c958..3157a1c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,16 @@ +0.6.3 + - Fixed drag-over stalls (sometimes lasting several seconds to a + minute) while dragging files/text over a drop target on Linux/X11, + most noticeable under XWayland. The XDND position handler was + fetching the full dropped-data selection on every pointer motion + while hovering, even when nothing used it; it's now only fetched + when a bound <>/<> binding actually + references it, and the result is cached per hovered target instead + of being re-fetched on every mouse-move. This also shrinks the + window for a state race with drag-leave handling that could + intermittently make a drop silently produce no data. Related to + issues #16 and #20. + 0.6.2 - Rebuilt the Linux binaries (linux-x64(-tcl9) and linux-arm64(-tcl9)) from TkDND 2.10.1 to pick up a fix for a race condition in the X11 diff --git a/setup.py b/setup.py index f765fed..12cedd9 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="tkinterdnd2", - version="0.6.2", + version="0.6.3", author="petasis\\pmgagne\\eliav2\\squiblydoo", description="TkinterDnD2 is a python wrapper for George Petasis'' tkDnD Tk extension version 2", long_description=long_description, diff --git a/tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.1.so b/tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.2.so similarity index 73% rename from tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.1.so rename to tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.2.so index 238e44a..8fa2c95 100644 Binary files a/tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.1.so and b/tkinterdnd2/tkdnd/linux-arm64-tcl9/libtcl9tkdnd2.10.2.so differ diff --git a/tkinterdnd2/tkdnd/linux-arm64-tcl9/pkgIndex.tcl b/tkinterdnd2/tkdnd/linux-arm64-tcl9/pkgIndex.tcl index f4ab188..215a68d 100644 --- a/tkinterdnd2/tkdnd/linux-arm64-tcl9/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/linux-arm64-tcl9/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.1.so tkdnd" + tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.2.so tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/linux-arm64-tcl9/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/linux-arm64-tcl9/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/linux-arm64-tcl9/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/linux-arm64-tcl9/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.1.so b/tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.2.so similarity index 95% rename from tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.1.so rename to tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.2.so index a02196d..91a977f 100644 Binary files a/tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.1.so and b/tkinterdnd2/tkdnd/linux-arm64/libtkdnd2.10.2.so differ diff --git a/tkinterdnd2/tkdnd/linux-arm64/pkgIndex.tcl b/tkinterdnd2/tkdnd/linux-arm64/pkgIndex.tcl index 159ee55..dfbdd60 100644 --- a/tkinterdnd2/tkdnd/linux-arm64/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/linux-arm64/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1.so tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2.so tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/linux-arm64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/linux-arm64/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/linux-arm64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/linux-arm64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.1.so b/tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.2.so similarity index 85% rename from tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.1.so rename to tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.2.so index 60622e7..932b80c 100644 Binary files a/tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.1.so and b/tkinterdnd2/tkdnd/linux-x64-tcl9/libtcl9tkdnd2.10.2.so differ diff --git a/tkinterdnd2/tkdnd/linux-x64-tcl9/pkgIndex.tcl b/tkinterdnd2/tkdnd/linux-x64-tcl9/pkgIndex.tcl index f4ab188..215a68d 100644 --- a/tkinterdnd2/tkdnd/linux-x64-tcl9/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/linux-x64-tcl9/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.1.so tkdnd" + tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.2.so tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/linux-x64-tcl9/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/linux-x64-tcl9/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/linux-x64-tcl9/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/linux-x64-tcl9/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.1.so b/tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.2.so similarity index 85% rename from tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.1.so rename to tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.2.so index 8a0c1da..58fd66e 100644 Binary files a/tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.1.so and b/tkinterdnd2/tkdnd/linux-x64/libtkdnd2.10.2.so differ diff --git a/tkinterdnd2/tkdnd/linux-x64/pkgIndex.tcl b/tkinterdnd2/tkdnd/linux-x64/pkgIndex.tcl index 159ee55..dfbdd60 100644 --- a/tkinterdnd2/tkdnd/linux-x64/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/linux-x64/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1.so tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2.so tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/linux-x64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/linux-x64/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/linux-x64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/linux-x64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.1.dylib b/tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.2.dylib similarity index 99% rename from tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.1.dylib rename to tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.2.dylib index 3d339b6..7118680 100644 Binary files a/tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.1.dylib and b/tkinterdnd2/tkdnd/osx-arm64-tcl9/libtcl9tkdnd2.10.2.dylib differ diff --git a/tkinterdnd2/tkdnd/osx-arm64-tcl9/pkgIndex.tcl b/tkinterdnd2/tkdnd/osx-arm64-tcl9/pkgIndex.tcl index ecf504d..0d0345f 100644 --- a/tkinterdnd2/tkdnd/osx-arm64-tcl9/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/osx-arm64-tcl9/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.1.dylib tkdnd" + tkdnd::initialise \{$dir\} libtcl9tkdnd2.10.2.dylib tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/osx-arm64-tcl9/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/osx-arm64-tcl9/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/osx-arm64-tcl9/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/osx-arm64-tcl9/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.1.dylib b/tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.2.dylib similarity index 99% rename from tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.1.dylib rename to tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.2.dylib index f0d18a0..b723bd9 100644 Binary files a/tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.1.dylib and b/tkinterdnd2/tkdnd/osx-arm64/libtkdnd2.10.2.dylib differ diff --git a/tkinterdnd2/tkdnd/osx-arm64/pkgIndex.tcl b/tkinterdnd2/tkdnd/osx-arm64/pkgIndex.tcl index 20a0633..da79f74 100644 --- a/tkinterdnd2/tkdnd/osx-arm64/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/osx-arm64/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1.dylib tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2.dylib tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/osx-arm64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/osx-arm64/tkdnd_unix.tcl index 1b80fad..d3e3b50 100644 --- a/tkinterdnd2/tkdnd/osx-arm64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/osx-arm64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/osx-x64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/osx-x64/tkdnd_unix.tcl index 4446f21..08c79e6 100644 --- a/tkinterdnd2/tkdnd/osx-x64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/osx-x64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.1.dll b/tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.2.dll similarity index 99% rename from tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.1.dll rename to tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.2.dll index a3ecf32..f6f4d20 100644 Binary files a/tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.1.dll and b/tkinterdnd2/tkdnd/win-arm64/libtkdnd2.10.2.dll differ diff --git a/tkinterdnd2/tkdnd/win-arm64/pkgIndex.tcl b/tkinterdnd2/tkdnd/win-arm64/pkgIndex.tcl index 7567eb0..bee9fcb 100644 --- a/tkinterdnd2/tkdnd/win-arm64/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/win-arm64/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1[info sharedlibextension] tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2[info sharedlibextension] tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.1.lib b/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.1.lib deleted file mode 100644 index 5246451..0000000 Binary files a/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.1.lib and /dev/null differ diff --git a/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.2.lib b/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.2.lib new file mode 100644 index 0000000..a773965 Binary files /dev/null and b/tkinterdnd2/tkdnd/win-arm64/tkdnd2.10.2.lib differ diff --git a/tkinterdnd2/tkdnd/win-arm64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/win-arm64/tkdnd_unix.tcl index e9b8ce0..92b5bac 100644 --- a/tkinterdnd2/tkdnd/win-arm64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/win-arm64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.1.dll b/tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.2.dll similarity index 69% rename from tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.1.dll rename to tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.2.dll index 59a12c0..8619629 100644 Binary files a/tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.1.dll and b/tkinterdnd2/tkdnd/win-x64-tcl9/libtkdnd2.10.2.dll differ diff --git a/tkinterdnd2/tkdnd/win-x64-tcl9/pkgIndex.tcl b/tkinterdnd2/tkdnd/win-x64-tcl9/pkgIndex.tcl index 7567eb0..bee9fcb 100644 --- a/tkinterdnd2/tkdnd/win-x64-tcl9/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/win-x64-tcl9/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1[info sharedlibextension] tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2[info sharedlibextension] tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.1.lib b/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.1.lib deleted file mode 100644 index aa481a1..0000000 Binary files a/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.1.lib and /dev/null differ diff --git a/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.2.lib b/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.2.lib new file mode 100644 index 0000000..4b86f94 Binary files /dev/null and b/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd2.10.2.lib differ diff --git a/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd_unix.tcl index e9b8ce0..92b5bac 100644 --- a/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/win-x64-tcl9/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.1.dll b/tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.2.dll similarity index 69% rename from tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.1.dll rename to tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.2.dll index ccdcdbf..97bb80c 100644 Binary files a/tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.1.dll and b/tkinterdnd2/tkdnd/win-x64/libtkdnd2.10.2.dll differ diff --git a/tkinterdnd2/tkdnd/win-x64/pkgIndex.tcl b/tkinterdnd2/tkdnd/win-x64/pkgIndex.tcl index 7567eb0..bee9fcb 100644 --- a/tkinterdnd2/tkdnd/win-x64/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/win-x64/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1[info sharedlibextension] tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2[info sharedlibextension] tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.1.lib b/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.1.lib deleted file mode 100644 index aa481a1..0000000 Binary files a/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.1.lib and /dev/null differ diff --git a/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.2.lib b/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.2.lib new file mode 100644 index 0000000..4b86f94 Binary files /dev/null and b/tkinterdnd2/tkdnd/win-x64/tkdnd2.10.2.lib differ diff --git a/tkinterdnd2/tkdnd/win-x64/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/win-x64/tkdnd_unix.tcl index e9b8ce0..92b5bac 100644 --- a/tkinterdnd2/tkdnd/win-x64/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/win-x64/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.1.dll b/tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.2.dll similarity index 99% rename from tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.1.dll rename to tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.2.dll index 311b142..abf1f9d 100644 Binary files a/tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.1.dll and b/tkinterdnd2/tkdnd/win-x86-tcl9/libtkdnd2.10.2.dll differ diff --git a/tkinterdnd2/tkdnd/win-x86-tcl9/pkgIndex.tcl b/tkinterdnd2/tkdnd/win-x86-tcl9/pkgIndex.tcl index 7567eb0..bee9fcb 100644 --- a/tkinterdnd2/tkdnd/win-x86-tcl9/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/win-x86-tcl9/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1[info sharedlibextension] tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2[info sharedlibextension] tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.1.lib b/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.1.lib deleted file mode 100644 index 9baa0dc..0000000 Binary files a/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.1.lib and /dev/null differ diff --git a/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.2.lib b/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.2.lib new file mode 100644 index 0000000..15c97a0 Binary files /dev/null and b/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd2.10.2.lib differ diff --git a/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd_unix.tcl index e9b8ce0..92b5bac 100644 --- a/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/win-x86-tcl9/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave diff --git a/tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.1.dll b/tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.2.dll similarity index 99% rename from tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.1.dll rename to tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.2.dll index efcbec9..0ebc39d 100644 Binary files a/tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.1.dll and b/tkinterdnd2/tkdnd/win-x86/libtkdnd2.10.2.dll differ diff --git a/tkinterdnd2/tkdnd/win-x86/pkgIndex.tcl b/tkinterdnd2/tkdnd/win-x86/pkgIndex.tcl index 7567eb0..bee9fcb 100644 --- a/tkinterdnd2/tkdnd/win-x86/pkgIndex.tcl +++ b/tkinterdnd2/tkdnd/win-x86/pkgIndex.tcl @@ -53,10 +53,10 @@ namespace eval ::tkdnd { }; # namespace ::tkdnd -package ifneeded tkdnd 2.10.1 \ +package ifneeded tkdnd 2.10.2 \ "tkdnd::source \{$dir/tkdnd.tcl\} ; \ - tkdnd::initialise \{$dir\} libtkdnd2.10.1[info sharedlibextension] tkdnd" + tkdnd::initialise \{$dir\} libtkdnd2.10.2[info sharedlibextension] tkdnd" -package ifneeded tkdnd::utils 2.10.1 \ +package ifneeded tkdnd::utils 2.10.2 \ "tkdnd::source \{$dir/tkdnd_utils.tcl\} ; \ - package provide tkdnd::utils 2.10.1" + package provide tkdnd::utils 2.10.2" diff --git a/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.1.lib b/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.1.lib deleted file mode 100644 index 9baa0dc..0000000 Binary files a/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.1.lib and /dev/null differ diff --git a/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.2.lib b/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.2.lib new file mode 100644 index 0000000..15c97a0 Binary files /dev/null and b/tkinterdnd2/tkdnd/win-x86/tkdnd2.10.2.lib differ diff --git a/tkinterdnd2/tkdnd/win-x86/tkdnd_unix.tcl b/tkinterdnd2/tkdnd/win-x86/tkdnd_unix.tcl index e9b8ce0..92b5bac 100644 --- a/tkinterdnd2/tkdnd/win-x86/tkdnd_unix.tcl +++ b/tkinterdnd2/tkdnd/win-x86/tkdnd_unix.tcl @@ -89,6 +89,8 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time variable _pressedkeys variable _actionlist variable _typelist + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} set _pressedkeys [GetPressedKeys $drop_target] set _actionlist { copy move link ask private } set _typelist $typelist @@ -101,17 +103,42 @@ proc xdnd::HandleXdndEnter { drop_target drag_source typelist time # ---------------------------------------------------------------------------- # Command xdnd::HandleXdndPosition # ---------------------------------------------------------------------------- +proc xdnd::NeedsPositionData { resolved_target } { + foreach event {<> <>} { + if {[string first %D [bind $resolved_target $event]] >= 0} { return 1 } + } + return 0 +};# xdnd::NeedsPositionData + proc xdnd::HandleXdndPosition { drop_target rootX rootY time { drag_source {} } { action default } } { variable _pressedkeys variable _typelist variable _last_mouse_root_x; set _last_mouse_root_x $rootX variable _last_mouse_root_y; set _last_mouse_root_y $rootY + variable _position_data_target + variable _position_data_cache set _pressedkeys [GetPressedKeys $drop_target] #DBG debug "xdnd::HandleXdndPosition: $time" - ## Get the dropped data... - catch { - ::tkdnd::generic::SetDroppedData [GetPositionData $drop_target $_typelist $time] + ## The dropped data can't change for the life of a drag, so only pay for + ## the (possibly multi-second, per candidate type) selection round-trip + ## once per hovered target, and only if a bound <>/<> + ## script actually uses %D. Doing this unconditionally on every pointer + ## motion is what causes drag-over stalls and races with HandleLeave (see + ## the snapshot/restore comment in HandleXdndDrop above). + foreach {resolved common_drag_source_types common_drop_target_types} \ + [::tkdnd::generic::FindWindowWithCommonTypes $drop_target $_typelist] {break} + if {[string length $resolved] && [NeedsPositionData $resolved]} { + if {![info exists _position_data_target] || + $_position_data_target ne $resolved} { + set _position_data_target $resolved + set _position_data_cache {} + catch {set _position_data_cache [GetPositionData $drop_target $_typelist $time]} + } + ::tkdnd::generic::SetDroppedData $_position_data_cache + } else { + set _position_data_target {} + ::tkdnd::generic::SetDroppedData {} } ::tkdnd::generic::HandlePosition $drop_target $drag_source \ $_pressedkeys $rootX $rootY $action @@ -121,6 +148,8 @@ proc xdnd::HandleXdndPosition { drop_target rootX rootY time # Command xdnd::HandleXdndLeave # ---------------------------------------------------------------------------- proc xdnd::HandleXdndLeave { } { + variable _position_data_target; set _position_data_target {} + variable _position_data_cache; set _position_data_cache {} #DBG debug "xdnd::HandleXdndLeave" ::tkdnd::generic::HandleLeave };# xdnd::HandleXdndLeave