void invoke_pending_caml_signals (ClientData clientdata) { signal_events = 0; enter_blocking_section(); /* triggers signal handling */ /* Rearm timer */ Tk_CreateTimerHandler(SIGNAL_INTERVAL, invoke_pending_caml_signals, NULL); signal_events = 1; leave_blocking_section(); }
CAMLprim value camltk_tk_mainloop(void) { CheckInit(); if (cltk_slave_mode) return Val_unit; if (!signal_events) { /* Initialise signal handling */ signal_events = 1; Tk_CreateTimerHandler(100, invoke_pending_caml_signals, NULL); } Tk_MainLoop(); return Val_unit; }
EventuallyRedrawGraph(SimGraph *graph) { if (!(graph->flags & VIEW_REDRAW_PENDING)) { assert(graph->draw_graph_token == 0); if (graph->draw_graph_token == 0) { graph->draw_graph_token = Tk_CreateTimerHandler( GraphUpdateTime, DisplaySimGraph, (ClientData) graph); graph->flags |= VIEW_REDRAW_PENDING; //fprintf(stderr, "EventuallyRedrawGraph token %d\n", graph->draw_graph_token); } } }
void DoGraphics(ClientData cl) { /* printf("c doGraph\n"); */ sprintf(TclCommand,"UpdateTime %g ; update; DoGraphics; update idletasks\n", *theTimeStep); Tcl_Eval(interp,TclCommand); if(theRunFlag==TRUE) { #ifdef Tcl75_Tk41 Tcl_CreateTimerHandler(0, DoMain,(ClientData)NULL); #endif #ifdef Tcl74_Tk40 Tk_CreateTimerHandler(0, DoMain,(ClientData)NULL); #endif } }
void callGraphDisplay::nonSliderButtonAutoRepeatCallback(ClientData cd) { // If the mouse button has been released, do NOT re-invoke the timer. callGraphDisplay *pthis = (callGraphDisplay *)cd; if (!pthis->nonSliderButtonCurrentlyPressed) return; const int listboxLeft = pthis->nonSliderSubtreeCenter - pthis->nonSliderCurrentSubtree-> horiz_pix_everything_below_root(pthis->consts); const int listboxTop = pthis->nonSliderSubtreeTop + pthis->nonSliderCurrentSubtree->getNodeData(). getHeightAsRoot() + pthis->consts.vertPixParent2ChildTop; const int listboxActualDataPix = pthis->nonSliderCurrentSubtree->getListboxActualPixHeight() - 2 * listboxBorderPix; int deltaYpix = 0; int repeatIntervalMillisecs = 100; switch (pthis->nonSliderButtonPressRegion) { case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarUpArrow: deltaYpix = -4; repeatIntervalMillisecs = 10; break; case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarDownArrow: deltaYpix = 4; repeatIntervalMillisecs = 10; break; case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPageup: deltaYpix = -listboxActualDataPix; repeatIntervalMillisecs = 250; // not so fast break; case whereNodeGraphicalPath<callGraphRootNode>::ListboxScrollbarPagedown: deltaYpix = listboxActualDataPix; repeatIntervalMillisecs = 250; // not so fast break; default: assert(false); } (void)pthis->nonSliderCurrentSubtree->scroll_listbox(pthis->consts, listboxLeft,listboxTop, deltaYpix); pthis->buttonAutoRepeatToken =Tk_CreateTimerHandler(repeatIntervalMillisecs, nonSliderButtonAutoRepeatCallback, pthis); }
void DoMain(ClientData cl) { char thePDumpFile[80], thePDFRoot[80]; strncpy(thePDFRoot,theDumpFile,findlen(theDumpFile)); thePDFRoot[findlen(theDumpFile)] = '\0'; sprintf(TclCommand,"update \n"); Tcl_Eval(interp,TclCommand); /* printf("c domain\n"); */ if (theNumberOfSteps==0 || theCurrentStep<=theNumberOfSteps) { int il; for(il=0;il<iterationsPerXUpdate;il++) { XGMainLoop(); if (theDumpPeriod!=0 && theCurrentStep%theDumpPeriod==0) { sprintf(thePDumpFile,"%s%d%s",thePDFRoot, theCurrentStep/theDumpPeriod,theDumpExtension); if (theIDumpFlag) Dump(thePDumpFile); else Dump(theDumpFile); } theCurrentStep++; } #ifdef Tcl75_Tk41 Tcl_CreateTimerHandler(0, DoGraphics,(ClientData)NULL); #endif #ifdef Tcl74_Tk40 Tk_CreateTimerHandler(0, DoGraphics,(ClientData)NULL); #endif } else { if(theExitFlag) { if ((theDumpPeriod!=0) && (theIDumpFlag)) { sprintf(thePDumpFile,"%s%d%s",thePDFRoot, theCurrentStep/theDumpPeriod+1,theDumpExtension); Dump(thePDumpFile); } else Dump(theDumpFile); XG_Quit(); } else { theNumberOfSteps = 0; Tcl_Eval(interp,".lbframe.run invoke\n"); Tcl_Eval(interp,".lbframe.save invoke\n"); } } }
static void inc_tmo (ClientData client_data) { char new_string[80]; if (count2 > 10) ACE_OS::exit (0); ACE_OS::sprintf (new_string, "Events: [%d] [%d] [%d]", count1, count2++, count3); // sprintf (command,"set %s %s",(char *)client_data,new_string); // eval (command); const char *varValue = Tcl_SetVar (tcl_interp,(char *)client_data,new_string,TCL_LEAVE_ERR_MSG); if (varValue == 0) ACE_ERROR ((LM_ERROR,"Tcl_SetVar failed in inc_tmo\n")); (void) Tk_CreateTimerHandler (1000, inc_tmo, client_data); }
void TkiFlash (Tcl_Interp *interp, Tki_Object *object) { FlashItem *p; if (flashList == NULL) { flashList = (FlashItem *) ckalloc (sizeof(FlashItem)); p = flashList; p->id = ckstrdup(object->id); p->nextPtr = NULL; Tk_CreateTimerHandler (500, FlashProc, (ClientData) interp); } else { /* * Move to the end of the list and check if it exists already. */ for (p = flashList; p->nextPtr != NULL; p = p->nextPtr) { if (p->id && strcmp (p->id, object->id) == 0) return; } if (p->id && strcmp (p->id, object->id) == 0) { return; } /* * Create a new entry for the flash list. */ p->nextPtr = (FlashItem *) ckalloc (sizeof(FlashItem)); p = p->nextPtr; p->id = ckstrdup(object->id); p->nextPtr = NULL; } }
int run_main (int, ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("TkReactor_Test")); tcl_interp = Tcl_CreateInterp (); if (init (tcl_interp) != TCL_OK) { ACE_OS::exit (1); } Tk_Window tk = 0; tk = Tk_MainWindow(tcl_interp); if (tk == 0) { ACE_ERROR_RETURN ((LM_ERROR, "Tk_Reactor_Test: %s\n", tcl_interp->result),1); } char tcl_cmd[] = "source TkReactor_Test.tcl"; if (Tcl_Eval (tcl_interp, tcl_cmd) != TCL_OK) { ACE_OS::exit (1); } // set up callback char label_var_name[] = "label_var"; char pressme[] = "pressme"; Tcl_CreateCommand (tcl_interp, pressme, inc_count, label_var_name, 0); // Register callback for X Timer (void) Tk_CreateTimerHandler (1000, inc_tmo, label_var_name); // It will perform Tk Main Loop ACE_TkReactor reactor; ACE_Reactor r (&reactor); //Event Handler for ACE Timer. EV_handler evh; ACE_Acceptor <Connection_Handler, ACE_SOCK_ACCEPTOR> acceptor; if (acceptor.open (ACE_INET_Addr ((u_short) SERV_TCP_PORT), &r) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); if (reactor.schedule_timer (&evh, (const void *) "label_var", ACE_Time_Value (2), ACE_Time_Value (2))==-1) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) can't register with reactor\n"), -1); ACE_Thread_Manager::instance ()->spawn ((ACE_THR_FUNC) client, 0, THR_NEW_LWP | THR_DETACHED); while (!quit) { int result = reactor.handle_events (); switch (result) { case 0: // ACE_DEBUG ((LM_DEBUG,"handle_events timed out\n")); break; case -1: ACE_DEBUG ((LM_DEBUG,"handle_events returned -1\n")); quit = 1; break; } } ACE_END_TEST; return 0; }
static void FlashProc (ClientData clientData) { Tcl_Interp *interp = (Tcl_Interp *) clientData; Tki_Object *object; char *color; FlashItem *p; int max = 0; Tk_Window window; Tk_Window tkwin = Tk_MainWindow(interp); for (p = flashList; p != NULL; p = p->nextPtr) { if (p->id == NULL) continue; object = Tki_LookupObject (p->id); if (object == NULL) continue; window = Tk_NameToWindow(interp, object->editor->toplevel, tkwin); if (! window) { continue; } if (! object->editor->color) { if ((object->flash) % 2) { color = "black"; } else { color = "white"; } } else { color = object->color; if ((object->flash) % 2) { if (strcasecmp(color, "white") == 0) color = "black"; } else { color = "white"; } } Tcl_VarEval (interp, type_to_string (object->type), "__color ", object->id, " ", color, (char *) NULL); #if 1 if (object->editor) { Tki_EditorAttribute(object->editor, interp, 1, &flashIcon); const char *tresult = Tcl_GetStringResult(interp); if ((*tresult != '\0') && (strcmp(tresult, "yes") == 0 || strcmp(tresult, "true") == 0 || strcmp(tresult, "on") == 0 || strcmp(tresult, "1") == 0)) { char *buf = (object->flash % 2) ? "icon" : "noicon"; Tcl_VarEval(interp, "if ![winfo ismapped ", object->editor->toplevel, "] {", "wm iconbitmap ", object->editor->toplevel, " ", buf, "}", (char *) NULL); } } #endif object->flash -= 1; if (object->flash == 0) { TkiNoTrace (m_color, interp, object, 1, &object->color); ckfree (p->id); p->id = NULL; } max = ( object->flash > max ) ? object->flash : max; } if (max <= 0) { /* everything is done - remove the flashList */ FlashItem *q; for (p = flashList; p != NULL; p = q) { q = p->nextPtr; if (p->id != NULL) ckfree (p->id); ckfree ((char *) p); } flashList = NULL; } Tcl_Eval (interp, "update"); if (max > 0) { Tk_CreateTimerHandler (500, FlashProc, (ClientData) interp); } }