summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorculler <culler>2024-05-29 16:18:42 (GMT)
committerculler <culler>2024-05-29 16:18:42 (GMT)
commitb39986a99d587498f5ba40e71cddf6ea0360b89f (patch)
tree6327e3356f8a0142e8863e1062aa6f5284449054 /generic
parent65eb0c8c381b378de6ac9095d2b5549078b4eee5 (diff)
downloadtk-b39986a99d587498f5ba40e71cddf6ea0360b89f.zip
tk-b39986a99d587498f5ba40e71cddf6ea0360b89f.tar.gz
tk-b39986a99d587498f5ba40e71cddf6ea0360b89f.tar.bz2
Add a simple version of the processevents test command and use it for the event-9* tests.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkTest.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 755a6be..4fc6a80 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -147,6 +147,9 @@ typedef struct TrivialCommandHeader {
static int ImageObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
+static int ProcessEventsObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj * const objv[]);
static int TestbitmapObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
@@ -247,6 +250,7 @@ Tktest_Init(
return TCL_ERROR;
}
+ Tcl_CreateObjCommand(interp, "processevents", ProcessEventsObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testbitmap", TestbitmapObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
@@ -1682,6 +1686,48 @@ ImageDelete(
/*
*----------------------------------------------------------------------
*
+ * ProcessEventsObjCmd --
+ *
+ * This function implements the "processevents" command. Currently
+ * It processes all <Enter> or <Leave> events on the queue.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * Events are processed
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Tk_RestrictAction
+CrossingRestrictProc(
+ ClientData arg,
+ XEvent *eventPtr)
+{
+ if (eventPtr->type == EnterNotify || eventPtr->type == LeaveNotify) {
+ return TK_PROCESS_EVENT;
+ }
+ return TK_DEFER_EVENT;
+}
+
+static int ProcessEventsObjCmd(ClientData dummy,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj * const objv[])
+{
+ ClientData oldArg;
+ Tk_RestrictProc *oldProc;
+ int count = 0;
+ oldProc = Tk_RestrictEvents(CrossingRestrictProc, NULL, &oldArg);
+ while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS|TCL_DONT_WAIT)) {};
+ Tk_RestrictEvents(oldProc, oldArg, &oldArg);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TestmakeexistObjCmd --
*
* This function implements the "testmakeexist" command. It calls