summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2012-11-27 18:52:35 (GMT)
committerpetasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e>2012-11-27 18:52:35 (GMT)
commit9dfeac405ca61c25ea88efba2be219a4acea295d (patch)
treec39576d2ea35fc020d5f37438510928fdab69f02
parent4035a38e552ebb50a78905de531a47ff4f9ea1e7 (diff)
downloadtkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.zip
tkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.tar.gz
tkdnd-9dfeac405ca61c25ea88efba2be219a4acea295d.tar.bz2
XDND: %X & %Y for drop events
-rw-r--r--Changelog7
-rw-r--r--library/tkdnd_unix.tcl21
-rw-r--r--library/tkdnd_windows.tcl17
3 files changed, 41 insertions, 4 deletions
diff --git a/Changelog b/Changelog
index bca2e92..d067e91 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,10 @@
+2012-11-27 Petasis George <petasis@iit.demokritos.gr>
+ * library/tkdnd_unix.tcl:
+ * library/tkdnd_windows.tcl: Leave and Drop events do not report 0
+ as root x/y (%X %Y). In case the underlying protocol does not support
+ reporting the mouse coordinates for the specific event, the last known
+ possition from the position event is used.
+
2012-08-26 Petasis George <petasis@iit.demokritos.gr>
TkDND 2.6 released.
* unix/tkUnixSelect.c: Added a work-around for getting the selection
diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl
index 811fa88..2f3b6c9 100644
--- a/library/tkdnd_unix.tcl
+++ b/library/tkdnd_unix.tcl
@@ -50,6 +50,9 @@ namespace eval xdnd {
variable _dragging 0
+ variable _last_mouse_root_x 0
+ variable _last_mouse_root_y 0
+
proc debug {msg} {
puts $msg
};# debug
@@ -69,6 +72,9 @@ proc xdnd::_HandleXdndEnter { path drag_source typelist } {
variable _drop_target; set _drop_target {}
variable _actionlist; set _actionlist \
{copy move link ask private}
+
+ variable _last_mouse_root_x; set _last_mouse_root_x 0
+ variable _last_mouse_root_y; set _last_mouse_root_y 0
# debug "\n==============================================================="
# debug "xdnd::_HandleXdndEnter: path=$path, drag_source=$drag_source,\
# typelist=$typelist"
@@ -89,6 +95,10 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } {
variable _common_drop_target_types
variable _drag_source
variable _drop_target
+
+ variable _last_mouse_root_x; set _last_mouse_root_x $rootX
+ variable _last_mouse_root_y; set _last_mouse_root_y $rootY
+
# debug "xdnd::_HandleXdndPosition: drop_target=$drop_target,\
# _drop_target=$_drop_target, rootX=$rootX, rootY=$rootY"
@@ -215,13 +225,16 @@ proc xdnd::_HandleXdndLeave { } {
variable _common_drop_target_types
variable _drag_source
variable _drop_target
+ variable _last_mouse_root_x
+ variable _last_mouse_root_y
if {![info exists _drop_target]} {set _drop_target {}}
# debug "xdnd::_HandleXdndLeave: _drop_target=$_drop_target"
if {[info exists _drop_target] && [string length $_drop_target]} {
set cmd [bind $_drop_target <<DropLeave>>]
if {[string length $cmd]} {
set _codelist $_typelist
- set cmd [string map [list %W $_drop_target %X 0 %Y 0 \
+ set cmd [string map [list %W $_drop_target \
+ %X $_last_mouse_root_x %Y $_last_mouse_root_y \
%CST \{$_common_drag_source_types\} \
%CTT \{$_common_drop_target_types\} \
%ST \{$_typelist\} %TT \{$_types\} \
@@ -255,8 +268,10 @@ proc xdnd::_HandleXdndDrop { time } {
variable _common_drop_target_types
variable _drag_source
variable _drop_target
- set rootX 0
- set rootY 0
+ variable _last_mouse_root_x
+ variable _last_mouse_root_y
+ set rootX $_last_mouse_root_x
+ set rootY $_last_mouse_root_y
# puts "xdnd::_HandleXdndDrop: $time"
diff --git a/library/tkdnd_windows.tcl b/library/tkdnd_windows.tcl
index 32b0187..d839216 100644
--- a/library/tkdnd_windows.tcl
+++ b/library/tkdnd_windows.tcl
@@ -46,6 +46,9 @@ namespace eval olednd {
variable _common_drag_source_types {}
variable _common_drop_target_types {}
variable _unhandled_types {}
+
+ variable _last_mouse_root_x 0
+ variable _last_mouse_root_y 0
};# namespace olednd
# ----------------------------------------------------------------------------
@@ -60,6 +63,10 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys
variable _action; set _action {}
variable _common_drag_source_types; set _common_drag_source_types {}
variable _common_drop_target_types; set _common_drop_target_types {}
+
+ variable _last_mouse_root_x; set _last_mouse_root_x $rootX
+ variable _last_mouse_root_y; set _last_mouse_root_y $rootY
+
# puts "olednd::_HandleDragEnter: drop_target=$drop_target,\
# typelist=$typelist, actionlist=$actionlist,\
# pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY"
@@ -119,6 +126,10 @@ proc olednd::_HandleDragOver { drop_target pressedkeys rootX rootY } {
variable _action
variable _common_drag_source_types
variable _common_drop_target_types
+
+ variable _last_mouse_root_x; set _last_mouse_root_x $rootX
+ variable _last_mouse_root_y; set _last_mouse_root_y $rootY
+
# puts "olednd::_HandleDragOver: drop_target=$drop_target,\
# pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY"
@@ -156,6 +167,9 @@ proc olednd::_HandleDragLeave { drop_target } {
variable _action
variable _common_drag_source_types
variable _common_drop_target_types
+ variable _last_mouse_root_x
+ variable _last_mouse_root_y
+
if {![llength $_common_drag_source_types]} {return}
foreach var {_types _typelist _actionlist _pressedkeys _action
_common_drag_source_types _common_drop_target_types} {
@@ -164,7 +178,8 @@ proc olednd::_HandleDragLeave { drop_target } {
set cmd [bind $drop_target <<DropLeave>>]
if {[string length $cmd]} {
- set cmd [string map [list %W $drop_target %X 0 %Y 0 \
+ set cmd [string map [list %W $drop_target \
+ %X $_last_mouse_root_x %Y $_last_mouse_root_y \
%CST \{$_common_drag_source_types\} \
%CTT \{$_common_drop_target_types\} \
%ST \{$_typelist\} %TT \{$_types\} \