-// Processes an X event.
-void wxApp::ProcessXEvent(WXEvent* _event)
-{
- XEvent* event = (XEvent*) _event;
-
- if (event->type == KeyPress)
- {
-#ifdef __WXDEBUG__
- Widget widget = XtWindowToWidget(event->xany.display, event->xany.window);
- wxLogDebug("Got key press event for 0x%08x (parent = 0x%08x)",
- widget, XtParent(widget));
-#endif // DEBUG
-
- if (CheckForAccelerator(_event))
- {
- // Do nothing! We intercepted and processed the event as an
- // accelerator.
- return;
- }
-#if 1
- // It seemed before that this hack was redundant and
- // key down events were being generated by wxCanvasInputEvent.
- // But no longer - why ???
- //
- else if (CheckForKeyDown(_event))
- {
- // We intercepted and processed the key down event
- return;
- }
-#endif
- else
- {
- XtDispatchEvent(event);
- return;
- }
- }
- else if (event->type == KeyRelease)
- {
- // TODO: work out why we still need this ! -michael
- //
- if (CheckForKeyUp(_event))
- {
- // We intercepted and processed the key up event
- return;
- }
- else
- {
- XtDispatchEvent(event);
- return;
- }
- }
- else if (event->type == PropertyNotify)
- {
- HandlePropertyChange(_event);
- return;
- }
- else if (event->type == ResizeRequest)
- {
- /* Terry Gitnick <terryg@scientech.com> - 1/21/98
- * If resize event, don't resize until the last resize event for this
- * window is recieved. Prevents flicker as windows are resized.
- */
-
- Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
- Window win = event->xany.window;
- XEvent report;
-
- // to avoid flicker
- report = * event;
- while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report));
-
- // TODO: when implementing refresh optimization, we can use
- // XtAddExposureToRegion to expand the window's paint region.
-
- XtDispatchEvent(event);
- }
- else
- {
- XtDispatchEvent(event);
- }
-}
-
-// Returns TRUE if more time is needed.
-bool wxApp::ProcessIdle()
-{
- wxIdleEvent event;
- event.SetEventObject(this);
- ProcessEvent(event);
-
- return event.MoreRequested();
-}
-
-void wxApp::ExitMainLoop()
-{
- m_keepGoing = FALSE;
-}
-
-// Is a message/event pending?
-bool wxApp::Pending()
-{
- XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
-
- // Fix by Doug from STI, to prevent a stall if non-X event
- // is found.
- return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
-}
-
-// Dispatch a message.
-void wxApp::Dispatch()
-{
- // XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
-
- XEvent event;
- XtAppNextEvent((XtAppContext) GetAppContext(), &event);
- ProcessXEvent((WXEvent*) & event);
-}
-