Tk Source Code

View Ticket
Login
Ticket UUID: 629827
Title: Moving toplevel windows fails
Type: Bug Version: obsolete: 8.3.4
Submitter: hschock Created on: 2002-10-28 13:00:15
Subsystem: 68. Win Window Operations Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2019-08-30 19:29:27
Resolution: None Closed By: nobody
    Closed on:
Description:
Moving or resizing toplevel windows under Windows OS
sometimes fails. This problem occured within an
application running cyclic http calls. The attached
code reduces the problem to a few lines of code. To
reproduce the problem simply run the attached code
inside a wish, drag the window to another position and
wait until the mouse looses the window (still holding
the left mousebutton).
User Comments: fvogel added on 2019-08-30 19:29:27:

Correction: WM_EXITSIZEMOVE is sent during (probably exactly at the end of) the [after] wait period just before re-entering bgproc, and not when ::x is set.

The rest of what I stated below seems right to me however.

Here is my adapted test script:

package require Tk
wm title . "Test Window"
wm geometry . 200x200+0+0
proc bgproc {} { 
    puts "Entering bgproc"
    puts [after 100 {puts Setting; set ::x 0 ; puts SET}]
    vwait ::x
    puts "Running in background..."
    puts [after 1000 bgproc]
    puts "Leaving bgproc\n"
}
bgproc

I have added a printf+fflush(stdout) in WmProc() on WM_ENTERSIZEMOVE and on WM_EXITSIZEMOVE.

The above spits the following output showing exactly when WM_EXITSIZEMOVE is sent:

...

Entering bgproc
after#36
Setting
SET
Running in background...
after#37
Leaving bgproc

WM_ENTERSIZEMOVE
Entering bgproc
after#38
Setting
SET
Running in background...
after#39
Leaving bgproc

WM_EXITSIZEMOVE
Entering bgproc
after#40
Setting
SET
Running in background...
after#41
Leaving bgproc

...


fvogel added on 2019-08-30 18:38:39:

A few findings:

  • The issue is that the window being dragged by the mouse unexpectedly jumps back to its original position while the script executes.
  • This happens on Windows (Win10), not on Linux (Debian 8).
  • The call to 'update' is not needed in the test script to trigger the issue.
  • The issue exactly happens when we're waiting (through vwait or tkwait), when the variable ::x we're waiting for is set. This can be seen by testing with increased timing values in the given test script.
  • Cancellation of movement happens only if the mouse is currently moving the window when the wait variable gets set. If the window is moved by the mouse, then mouse movement is stopped (while the mouse button is still down), and then variable ::x is set, then the window does _not_ jump to its original position. The window must be moving when ::x is set, and in this case only the window jumps to its original position.
  • It looks like vwait, upon detection of the variable being set, is doing something that lets the Windows OS send a WM_EXITSIZEMOVE event that we are not expecting. This can be seen by instrumenting WmProc() in tkWinWM.c.
  • The good question is what exactly triggers WM_EXITSIZEMOVE.


fvogel added on 2019-08-28 20:18:43:

I have now fixed [943d5ebe51] but the issue described in the present ticket persists so it's a different issue.


ckoechli added on 2018-12-11 15:54:17:
It's still there with 8.6.9 and windows 10
Resizing the window or draging it around triggers the problem.
It is possible to recover from it using:
wm resizable . 1 1 

Would the use of threads instead of the "after" trick solve it ?
That would at least prevent something from being interrupted at the wrong time.

fvogel added on 2018-06-29 19:06:10:

See also [943d5ebe51], it looks similar.


fvogel added on 2016-08-17 15:38:36:
Still here with core-8-5-branch, core-8-6-branch and trunk.

hschock added on 2002-10-28 20:00:15:

File Added - 34067: winerr.tcl

Attachments: