Tk Source Code

Changes On Branch bug-e3888d5820
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-e3888d5820 Excluding Merge-Ins

This is equivalent to a diff from 3125db91 to 5c500188

2020-07-06
21:18
Fix [e3888d5820]: Grab on master prevents mouse pointer warp into slave widget. Mouse pointer warping happens at idle time, and the fix does not change this. check-in: 7f3b5a11 user: fvogel tags: core-8-6-branch
2020-06-14
16:19
Rework test bind-35.1 and simplify it a bit, make it fail in core-8-6-branch that does not have the fix yet. Closed-Leaf check-in: 5c500188 user: fvogel tags: bug-e3888d5820
2020-06-07
19:58
Add comment explaining the result expected for bind-35.1 check-in: c5754760 user: fvogel tags: bug-e3888d5820
2020-02-24
01:11
Fix for utility/floating windows on macOS not displaying completely on initial creation check-in: cade7f7f user: kevin_walzer tags: core-8-6-branch
2020-02-23
14:41
merge core-8-6-branch check-in: 5fa8b7e7 user: fvogel tags: bug-e3888d5820
14:39
Prevent some textTag tests from triggering hot spots of the Linux KDE/Plasma desktop. What is needed in these tests is to move the mouse out of the test window when the test starts, so that the events expected by the test can be observed. We don't need to move the mouse exactly at the upper-left corner of the screen, we only have to make sure the mouse pointer is outside the test window. check-in: dc6628ca user: fvogel tags: trunk
14:38
Prevent some textTag tests from triggering hot spots of the Linux KDE/Plasma desktop. What is needed in these tests is to move the mouse out of the test window when the test starts, so that the events expected by the test can be observed. We don't need to move the mouse exactly at the upper-left corner of the screen, we only have to make sure the mouse pointer is outside the test window. check-in: 3125db91 user: fvogel tags: core-8-6-branch
2020-02-18
21:19
Use TkGrabState() in function TestgrabObjCmd() instead of dispPtr->grabWinPtr to make the code clearer and the interface cleaner. check-in: 1e8dcf37 user: fvogel tags: bug-e3888d5820
2020-02-17
22:06
Refine test bind-35.1 once more since [grab current] returns the eventualGrabWin while we're interested in the grabWin instead. check-in: 0b310b17 user: fvogel tags: bug-e3888d5820
2020-02-16
12:42
Merge 8.5 check-in: dc776f94 user: jan.nijtmans tags: core-8-6-branch

Changes to generic/tkBind.c.

4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
















4382
4383
4384
4385
4386
4387
4388
	     * refcount before firing it into the low-level event subsystem; the
	     * refcount will be decremented once the event has been processed.
	     */
	    event.virtual.user_data = userDataObj;
	    Tcl_IncrRefCount(userDataObj);
	}

	/*
	 * Now we have constructed the event, inject it into the event handling
	 * code.
	 */

	if (synch) {
	    Tk_HandleEvent(&event.general);
	} else {
	    Tk_QueueWindowEvent(&event.general, pos);
	}

	/*
	 * We only allow warping if the window is mapped.
	 */

	if (warp && Tk_IsMapped(tkwin)) {
	    TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);

	    Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window);

	    if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
		Tcl_DoWhenIdle(DoWarp, dispPtr);
		dispPtr->flags |= TK_DISPLAY_IN_WARP;
	    }

	    if (warpWindow != dispPtr->warpWindow) {
		if (warpWindow) {
		    Tcl_Preserve(warpWindow);
		}
		if (dispPtr->warpWindow) {
		    Tcl_Release(dispPtr->warpWindow);
		}
		dispPtr->warpWindow = warpWindow;
	    }
	    dispPtr->warpMainwin = mainWin;
	    dispPtr->warpX = event.general.xmotion.x;
	    dispPtr->warpY = event.general.xmotion.y;
















	}
    }

    Tcl_ResetResult(interp);
    return TCL_OK;
}
/*







<
<
<
<
<
<
<
<
<
<
<









<
<
<
<
<












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4338
4339
4340
4341
4342
4343
4344











4345
4346
4347
4348
4349
4350
4351
4352
4353





4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
	     * refcount before firing it into the low-level event subsystem; the
	     * refcount will be decremented once the event has been processed.
	     */
	    event.virtual.user_data = userDataObj;
	    Tcl_IncrRefCount(userDataObj);
	}












	/*
	 * We only allow warping if the window is mapped.
	 */

	if (warp && Tk_IsMapped(tkwin)) {
	    TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);

	    Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, event.general.xmotion.window);






	    if (warpWindow != dispPtr->warpWindow) {
		if (warpWindow) {
		    Tcl_Preserve(warpWindow);
		}
		if (dispPtr->warpWindow) {
		    Tcl_Release(dispPtr->warpWindow);
		}
		dispPtr->warpWindow = warpWindow;
	    }
	    dispPtr->warpMainwin = mainWin;
	    dispPtr->warpX = event.general.xmotion.x;
	    dispPtr->warpY = event.general.xmotion.y;

	    if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
		Tcl_DoWhenIdle(DoWarp, dispPtr);
		dispPtr->flags |= TK_DISPLAY_IN_WARP;
	    }
	}

	/*
	 * Now we have constructed the event, inject it into the event handling
	 * code.
	 */

	if (synch) {
	    Tk_HandleEvent(&event.general);
	} else {
	    Tk_QueueWindowEvent(&event.general, pos);
	}
    }

    Tcl_ResetResult(interp);
    return TCL_OK;
}
/*

Changes to macosx/tkMacOSXMouseEvent.c.

637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
}

void
TkpWarpPointer(
    TkDisplay *dispPtr)
{
    CGPoint pt;
    NSPoint loc;
    int wNum;

    if (dispPtr->warpWindow) {
	int x, y;
	TkWindow *winPtr = (TkWindow *) dispPtr->warpWindow;
	TkWindow *topPtr = winPtr->privatePtr->toplevel->winPtr;
	NSWindow *w = TkMacOSXDrawableWindow(winPtr->window);
	wNum = [w windowNumber];
	Tk_GetRootCoords(dispPtr->warpWindow, &x, &y);
	pt.x = x + dispPtr->warpX;
	pt.y = y + dispPtr->warpY;
	loc.x = dispPtr->warpX;
	loc.y = Tk_Height(topPtr) - dispPtr->warpY;
    } else {
	wNum = 0;
	pt.x = loc.x = dispPtr->warpX;
	pt.y = dispPtr->warpY;
	loc.y = TkMacOSXZeroScreenHeight() - pt.y;
    }

    /*
     * Generate an NSEvent of type NSMouseMoved.
     *
     * It is not clear why this is necessary.  For example, calling
     *     event generate $w <Motion> -warp 1 -x $X -y $Y
     * will cause two <Motion> events to be added to the Tcl queue.
     */

    CGWarpMouseCursorPosition(pt);
    NSEvent *warpEvent = [NSEvent mouseEventWithType:NSMouseMoved
	location:loc
	modifierFlags:0
	timestamp:GetCurrentEventTime()
	windowNumber:wNum
	context:nil
	eventNumber:0
	clickCount:1
	pressure:0.0];
    [NSApp postEvent:warpEvent atStart:NO];
}

/*
 *----------------------------------------------------------------------
 *
 * TkpSetCapture --
 *







<
<



<
<
<
<



<
<

<
|

<


<
<
<
<
<
<
<
<

<
<
<
<
<
<
<
<
<
<







637
638
639
640
641
642
643


644
645
646




647
648
649


650

651
652

653
654








655










656
657
658
659
660
661
662
}

void
TkpWarpPointer(
    TkDisplay *dispPtr)
{
    CGPoint pt;



    if (dispPtr->warpWindow) {
	int x, y;




	Tk_GetRootCoords(dispPtr->warpWindow, &x, &y);
	pt.x = x + dispPtr->warpX;
	pt.y = y + dispPtr->warpY;


    } else {

	pt.x = dispPtr->warpX;
	pt.y = dispPtr->warpY;

    }









    CGWarpMouseCursorPosition(pt);










}

/*
 *----------------------------------------------------------------------
 *
 * TkpSetCapture --
 *

Changes to tests/bind.test.

32
33
34
35
36
37
38



39
40
41





42
43
44


45
46
47
48
49
50
51
    bind xyz <Enter> {}
    bind {a b} <Enter> {}
    bind .t <Enter> {}
}

# move the mouse pointer away of the testing area
# otherwise some spurious events may pollute the tests



toplevel .top
wm geometry .top 50x50-50-50
update





event generate .top <Button-1> -warp 1
update
destroy .top



test bind-1.1 {bind command} -body {
    bind
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
test bind-1.2 {bind command} -body {
    bind a b c d
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}







>
>
>
|
|
|
>
>
>
>
>
|
|
|
>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    bind xyz <Enter> {}
    bind {a b} <Enter> {}
    bind .t <Enter> {}
}

# move the mouse pointer away of the testing area
# otherwise some spurious events may pollute the tests
# also, this will procure a known grab state at startup
# for tests mixing grabs and pointer warps
proc pointerAway {} {
    toplevel .top
    wm geometry .top 50x50-50-50
    update
    # On KDE/Plasma _with_the_Aurorae_theme_ (at least), setting up the toplevel
    # will not be finished right after the above 'update'. The WM still
    # needs some time before the window is fully ready. For me 50 ms is enough,
    # but let's wait more (it depends on computer performance).
    after 100 ; update
    event generate .top <Button-1> -warp 1
    update
    destroy .top
}
pointerAway

test bind-1.1 {bind command} -body {
    bind
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
test bind-1.2 {bind command} -body {
    bind a b c d
} -returnCodes error -result {wrong # args: should be "bind window ?pattern? ?command?"}
6623
6624
6625
6626
6627
6628
6629


6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
    # Old implementation failed, and returned "first", but this was wrong,
    # because both bindings are homogeneous equal, so the most recently defined
    # must be preferred.
} -result {last}

test bind-34.1 {-warp works relatively to a window} -setup {
    toplevel .top


} -body {
    # In order to avoid platform-dependent coordinate results due to
    # decorations and borders, this test warps the pointer twice 
    # relatively to a window that moved in the meantime, and checks
    # how much the pointer moved
    wm geometry .top +200+200
    update
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos1 [winfo pointerxy .t]
    wm geometry .top +600+600
    update
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos2 [winfo pointerxy .t]
    # from the first warped position to the second one, the mouse
    # pointer should have moved the same amount as the window moved
    set res 1
    foreach pos1 $pointerPos1 pos2 $pointerPos2 {
        if {$pos1 != [expr {$pos2 - 400}]} {
            set res [list $pointerPos1 $pointerPos2]
        }







>
>










|





|







6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
    # Old implementation failed, and returned "first", but this was wrong,
    # because both bindings are homogeneous equal, so the most recently defined
    # must be preferred.
} -result {last}

test bind-34.1 {-warp works relatively to a window} -setup {
    toplevel .top
    wm geometry .top +100+100
    update
} -body {
    # In order to avoid platform-dependent coordinate results due to
    # decorations and borders, this test warps the pointer twice 
    # relatively to a window that moved in the meantime, and checks
    # how much the pointer moved
    wm geometry .top +200+200
    update
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos1 [winfo pointerxy .top]
    wm geometry .top +600+600
    update
    event generate .top <Motion> -x 20 -y 20 -warp 1
    update idletasks ; # DoWarp is an idle callback
    after 50         ; # Win specific - wait for SendInput to be executed
    set pointerPos2 [winfo pointerxy .top]
    # from the first warped position to the second one, the mouse
    # pointer should have moved the same amount as the window moved
    set res 1
    foreach pos1 $pointerPos1 pos2 $pointerPos2 {
        if {$pos1 != [expr {$pos2 - 400}]} {
            set res [list $pointerPos1 $pointerPos2]
        }
6702
6703
6704
6705
6706
6707
6708






































6709
6710
6711
6712
6713
6714
6715
6716
6717
        } else {
            lappend res $dim
        }
    }
    set res
} -cleanup {
} -result {ok ok ok ok}







































# cleanup
cleanupTests
return

# vi:set ts=4 sw=4 et:
# Local Variables:
# mode: tcl
# End:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
        } else {
            lappend res $dim
        }
    }
    set res
} -cleanup {
} -result {ok ok ok ok}

test bind-35.1 {pointer warp with grab on master, bug [e3888d5820]} -setup {
    pointerAway
    toplevel .top
    grab release .top
    wm geometry .top 200x200+300+300
    label .top.l -height 5 -width 20 -highlightthickness 2 \
            -highlightbackground black -bg yellow -text "My label"
    pack .top.l -side bottom
    update
    # On KDE/Plasma _with_the_Aurorae_theme_ (at least), setting up the toplevel
    # and the label will not be finished after the above 'update'. The WM still
    # needs some time before the window is fully ready. For me 50 ms is enough,
    # but let's wait more (it depends on computer performance).
    after 100 ; update
} -body {
    grab .top  ; # this will queue events
    after 50
    update
    event generate .top.l <Motion> -warp 1 -x 10 -y 10
    update idletasks ; after 50
    foreach {x1 y1} [winfo pointerxy .top.l] {}
    event generate {} <Motion> -warp 1 -x 50 -y 50
    update idletasks ; after 50
    grab release .top  ; # this will queue events
    after 50
    update
    event generate .top.l <Motion> -warp 1 -x 10 -y 10
    update idletasks ; after 50
    foreach {x2 y2} [winfo pointerxy .top.l] {}
    # success if the coords are the same with or without the grab, and if they
    # are at (10,10) inside the label widget as requested by the warping
    expr {$x1==$x2 && $y1==$y2 && $x1==[winfo rootx .top.l]+10 \
                               && $y1==[winfo rooty .top.l]+10}
} -cleanup {
    destroy .top
    unset x1 y1 x2 y2
} -result {1}

# cleanup
cleanupTests
return

# vi:set ts=4 sw=4 et:
# Local Variables:
# mode: tcl
# End: