Tk Source Code

View Ticket
Login
Ticket UUID: a2abc45ee636463eccff3b7255de688619fa51a3
Title: Cursor at wrong position after event generate -warp on secondary screen
Type: Bug Version: 8.6.1
Submitter: sbron Created on: 2014-05-06 10:59:02
Subsystem: 65. Generic Window Operations Assigned To: fvogel
Priority: 6 Severity: Minor
Status: Closed Last Modified: 2016-08-23 20:53:04
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-08-23 20:53:04
Description:
When using the -warp option with event generate for a widget that is on a different screen from the main application, it takes the -x and -y as absolute positions, instead of relative to the specified widget as it does on the main screen.

Example script:

package require Tk

set screen2 [lindex $argv 0]
if {$screen2 eq ""} {set screen2 :1}

toplevel .t -screen $screen2

proc cursor {w} {
    puts "Widget: [winfo rootx $w],[winfo rooty $w]"
    event generate $w <Motion> -x 100 -y 100 -warp 1
    update idletasks
    puts "Cursor: [join [winfo pointerxy $w] ,]\n"
}

after 10000 {
    cursor .
    cursor .t
    exit
}

This should report a cursor position that is 100 higher than the widget position in both x and y direction. It is correct for the main screen, but reports 100,100 for the secondary screen.

This works correctly with Tk 8.5.15, but not with Tk 8.6.0.

Tk 8.5.15:
Widget: 796,94
Cursor: 896,194

Widget: 172,216
Cursor: 272,316

Tk 8.6.0:
Widget: 820,142
Cursor: 920,242

Widget: 196,264
Cursor: 100,100


OS: OpenSUSE linux 13.1 KDE 4.11.2, kernel 3.11.6.
User Comments: fvogel added on 2016-08-23 20:53:04:
Fix merged in core-8-6-branch and trunk.

fvogel added on 2016-08-13 20:12:46:

The display used to identify the warpWindow was the wrong one in commit [0ebe1c29].

See the fix here: [9339d0a471]


fvogel added on 2016-08-13 09:08:13:

Oh gosh, got bitten again by this formatting thing loosing newlines... <sigh>... Again:

I could reproduce (thanks to helpful people in the chat) on a Linux laptop, the required second screen (":7") being created by:

    Xnest :7 -ac &
    mwm -display :7 &

Then, running the following in wish triggers the issue:

    package require Tk
    toplevel .t -screen :7
    proc cursor {w} {
        puts "Widget: [winfo rootx $w],[winfo rooty $w]"
        event generate $w <Motion> -x 100 -y 100 -warp 1
        update idletasks
        puts "Cursor: [join [winfo pointerxy $w] ,]\n"
    }
    after 10000 {
        cursor .
        cursor .t
        exit
    }

This problem was introduced by commit [0ebe1c29], as evidenced by fossil bisect:

[0ebe1c29] Bug [2926819]: Factor out the pointer warping code a bit better and extend it to work on OSX too. (user: dkf, tags: trunk)


fvogel added on 2016-08-13 09:02:30:

I could reproduce (thanks to helpful people in the chat) on a Linux laptop, the required second screen (":7") being created by:

Xnest :7 -ac & mwm -display :7 &

Then, running the following in wish triggers the issue:

package require Tk toplevel .t -screen :7 proc cursor {w} { puts "Widget: [winfo rootx $w],[winfo rooty $w]" event generate $w <Motion> -x 100 -y 100 -warp 1 update idletasks puts "Cursor: [join [winfo pointerxy $w] ,]\n" } after 10000 { cursor . cursor .t exit }

This problem was introduced by commit [0ebe1c29], as evidenced by fossil bisect:

[0ebe1c29] Bug [2926819]: Factor out the pointer warping code a bit better and extend it to work on OSX too. (user: dkf, tags: trunk)