customize event loop
This commit is contained in:
@@ -199,6 +199,19 @@ int main(int argc, char *argv[]) {
|
|||||||
XmMainWindowSetAreas(mainwin, menubar, NULL, NULL, NULL, form);
|
XmMainWindowSetAreas(mainwin, menubar, NULL, NULL, NULL, form);
|
||||||
|
|
||||||
XtRealizeWidget(toplevel);
|
XtRealizeWidget(toplevel);
|
||||||
XtAppMainLoop(app);
|
|
||||||
|
/* 自定义事件循环 */
|
||||||
|
XEvent event;
|
||||||
|
while (1) {
|
||||||
|
if (XtAppPending(app)) {
|
||||||
|
XtAppNextEvent(app, &event);
|
||||||
|
XtDispatchEvent(&event);
|
||||||
|
} else {
|
||||||
|
/* 空闲时可以执行后台逻辑 */
|
||||||
|
printf("Idle...\n");
|
||||||
|
usleep(500000); /* 0.5秒 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user