void htime(XtPointer client_data, XtIntervalId *timer) { XEvent bogus_event; Display** displays; int numdr; #ifdef DEBUG printf("here\n"); #endif if(--tsec == 0) { // XtDestroyApplicationContext (app_context); #ifdef DEBUG printf("alive\n"); #endif /* This is EVIL */ tflag = 1; XtGetDisplays(app_context, &displays, &numdr); bogus_event.type = 0; /* XAnyEvent type, ignored. */ bogus_event.xany.display = displays[0]; bogus_event.xany.window = 0; XPutBackEvent(displays[0], &bogus_event); XtAppSetExitFlag (app_context); } else { timer = (XtIntervalId)XtAppAddTimeOut(app_context, (unsigned long)1000, (XtTimerCallbackProc)htime, test); } }
void QNPXt::appStartingUp() { /* QApplication could be using a Display from an outside source, so we should only initialize the display if the current application context does not contain the QApplication display */ bool display_found = FALSE; Display **displays; Cardinal x, count; XtGetDisplays( d->appContext, &displays, &count ); for ( x = 0; x < count && ! display_found; ++x ) { if ( displays[x] == QPaintDevice::x11AppDisplay() ) display_found = TRUE; } if ( displays ) XtFree( (char *) displays ); if ( ! display_found ) { int argc = qApp->argc(); XtDisplayInitialize( d->appContext, QPaintDevice::x11AppDisplay(), qApp->name(), d->applicationClass, d->options, d->numOptions, &argc, qApp->argv() ); } d->hookMeUp(); // start a zero-timer to get the timer keep-alive working d->timerid = XtAppAddTimeOut( d->appContext, 0, qnpxt_timeout_handler, 0 ); }