summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-06-02 20:48:00 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-06-02 20:48:00 (GMT)
commitf0b89aefda27ec85cef23db0ada5b6e292844a1b (patch)
tree14fabfb1455d9e289f26c832489cebd9d9ebca90
parent169bf5a922972c64aa154479d588919763f77e88 (diff)
downloadtk-f0b89aefda27ec85cef23db0ada5b6e292844a1b.zip
tk-f0b89aefda27ec85cef23db0ada5b6e292844a1b.tar.gz
tk-f0b89aefda27ec85cef23db0ada5b6e292844a1b.tar.bz2
Rename DoWarp to DoWarWrtScreen, add function DoWarpWrtWin to factorize the code a bit.
-rw-r--r--generic/tkBind.c54
-rw-r--r--generic/tkGrab.c32
-rw-r--r--generic/tkInt.h1
-rw-r--r--tests/bind.test4
4 files changed, 55 insertions, 36 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 7fd9e74..6eac1dd 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -717,7 +717,7 @@ static int NameToWindow(Tcl_Interp *interp, Tk_Window main,
Tcl_Obj *objPtr, Tk_Window *tkwinPtr);
static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr,
TkPattern *patPtr, EventMask *eventMaskPtr);
-static void DoWarp(TkDisplay *dispPtr);
+static void DoWarpWrtScreen(TkDisplay *dispPtr);
static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr,
Tcl_Obj *object, int onlyConsiderDetailedEvents);
static void ClearLookupTable(LookupTables *lookupTables, ClientData object);
@@ -4376,7 +4376,7 @@ HandleEventGenerate(
*/
if (!dispPtr->warpWindow) {
- DoWarp(dispPtr);
+ DoWarpWrtScreen(dispPtr);
}
}
@@ -4461,7 +4461,7 @@ NameToWindow(
/*
*-------------------------------------------------------------------------
*
- * DoWarp --
+ * DoWarpWrtScreen --
*
* Perform warping of mouse pointer with respect to the whole screen.
*
@@ -4475,7 +4475,7 @@ NameToWindow(
*/
static void
-DoWarp(
+DoWarpWrtScreen(
TkDisplay *dispPtr)
{
assert(dispPtr);
@@ -4494,6 +4494,52 @@ DoWarp(
/*
*-------------------------------------------------------------------------
*
+ * DoWarpWrtWin --
+ *
+ * Perform warping of mouse pointer with respect to a window.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * Mouse pointer moves to a new location.
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+DoWarpWrtWin(
+ TkDisplay *dispPtr)
+{
+ assert(dispPtr);
+
+ /*
+ * A NULL warpWindow means warping with respect to the whole screen.
+ * We want to warp here only if we're warping with respect to a window.
+ */
+
+ if (dispPtr->warpWindow) {
+
+ /*
+ * Warping with respect to a window can only be done if the window is
+ * mapped. This was checked in HandleEvent. The window needs to be
+ * still mapped at the time the present code is executed. Also
+ * one needs to guard against window destruction in the meantime,
+ * which could have happened as a side effect of an event handler.
+ */
+
+ if (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None) {
+ TkpWarpPointer(dispPtr);
+ XForceScreenSaver(dispPtr->display, ScreenSaverReset);
+ }
+ Tcl_Release(dispPtr->warpWindow);
+ dispPtr->warpWindow = NULL;
+ }
+}
+
+/*
+ *-------------------------------------------------------------------------
+ *
* GetVirtualEventUid --
*
* Determine if the given string is in the proper format for a virtual
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index c923608..711bcad 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -775,28 +775,7 @@ TkPointerEvent(
}
if ((eventPtr->type == MotionNotify) && !appGrabbed) {
-
- /*
- * A NULL warpWindow means warping with respect to the whole screen.
- * We want to warp here only if we're warping with respect to a window.
- */
-
- if (dispPtr->warpWindow) {
-
- /*
- * Warping with respect to a window can only be done if the window is
- * mapped. This was checked in HandleEvent. The windows needs to be
- * still mapped at the time the present code is executed. Also
- * one needs to guard against window destruction in the meantime.
- */
-
- if (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None) {
- TkpWarpPointer(dispPtr);
- XForceScreenSaver(dispPtr->display, ScreenSaverReset);
- }
- Tcl_Release(dispPtr->warpWindow);
- dispPtr->warpWindow = NULL;
- }
+ DoWarpWrtWin(dispPtr);
}
if (!appGrabbed) {
@@ -825,14 +804,7 @@ TkPointerEvent(
Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
return 0;
}
- if (dispPtr->warpWindow) {
- if (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None) {
- TkpWarpPointer(dispPtr);
- XForceScreenSaver(dispPtr->display, ScreenSaverReset);
- }
- Tcl_Release(dispPtr->warpWindow);
- dispPtr->warpWindow = NULL;
- }
+ DoWarpWrtWin(dispPtr);
return 1;
}
diff --git a/generic/tkInt.h b/generic/tkInt.h
index cc710d6..5dd1454 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1247,6 +1247,7 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
ClientData clientData);
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
+MODULE_SCOPE void DoWarpWrtWin(TkDisplay *dispPtr);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
diff --git a/tests/bind.test b/tests/bind.test
index c677109..b9dab48 100644
--- a/tests/bind.test
+++ b/tests/bind.test
@@ -6136,9 +6136,9 @@ test bind-31.7 {virtual event user_data field - unshared, asynch} -setup {
destroy .t.f
} -result {{} {} {TestUserData >b<}}
-test bind-32.1 {-warp, window was destroyed before the idle callback DoWarp} -setup {
+test bind-32.1 {-warp, window was destroyed before the idle callback DoWarpWrtScreen} -setup {
# note: this test is now essentially useless
- # since DoWarp no longer is an idle callback
+ # since DoWarpWrtScreen no longer is an idle callback
frame .t.f
pack .t.f
focus -force .t.f