MCPcopy Create free account
hub / github.com/SimHacker/micropolis / ButtonEventProc

Function ButtonEventProc

micropolis-activity/src/tk/tkbutton.c:1222–1258  ·  view source on GitHub ↗
(clientData, eventPtr)

Source from the content-addressed store, hash-verified

1220 *
1221 * Side effects:
1222 * When the window gets deleted, internal structures get
1223 * cleaned up. When it gets exposed, it is redisplayed.
1224 *
1225 *--------------------------------------------------------------
1226 */
1227
1228static void
1229ButtonEventProc(clientData, eventPtr)
1230 ClientData clientData; /* Information about window. */
1231 XEvent *eventPtr; /* Information about event. */
1232{
1233 Button *butPtr = (Button *) clientData;
1234 if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
1235 if ((butPtr->tkwin != NULL) && !(butPtr->flags & REDRAW_PENDING)) {
1236//Tk_TimerToken last = butPtr->updateTimerToken;
1237 butPtr->flags |= REDRAW_PENDING;
1238// Tk_DoWhenIdle(DisplayButton, (ClientData) butPtr);
1239 assert(butPtr->updateTimerToken == NULL);
1240 if (butPtr->updateTimerToken == NULL) {
1241 butPtr->updateTimerToken =
1242 Tk_CreateTimerHandler(
1243 ButtonUpdateTime,
1244 DisplayButton,
1245 (ClientData) butPtr);
1246 } // if
1247//fprintf(stderr, "ButtonEventProc Expose Set Timer %s %s was %d now %d\n", Tk_Class(butPtr->tkwin), Tk_PathName(butPtr->tkwin), last, butPtr->updateTimerToken);
1248 }
1249 } else if (eventPtr->type == DestroyNotify) {
1250 Tcl_DeleteCommand(butPtr->interp, Tk_PathName(butPtr->tkwin));
1251 butPtr->tkwin = NULL;
1252 if (butPtr->flags & REDRAW_PENDING) {
1253//fprintf(stderr, "ButtonEventProc Destroy Timer was %d now 0\n", butPtr->updateTimerToken);
1254// Tk_CancelIdleCall(DisplayButton, (ClientData) butPtr);
1255 butPtr->flags &= ~REDRAW_PENDING;
1256 assert(butPtr->updateTimerToken != NULL);
1257 if (butPtr->updateTimerToken != NULL) {
1258 Tk_DeleteTimerHandler(butPtr->updateTimerToken);
1259 butPtr->updateTimerToken = 0;
1260 }
1261 }

Callers

nothing calls this directly

Calls 4

Tk_EventuallyFreeFunction · 0.85
Tk_CreateTimerHandlerFunction · 0.70
Tk_DeleteTimerHandlerFunction · 0.70
Tcl_DeleteCommandFunction · 0.50

Tested by

no test coverage detected