+ return TRUE;
+ }
+
+#if !wxUSE_NANOX
+ case GraphicsExpose:
+ {
+ printf( "GraphicExpose event\n" );
+
+ // wxLogDebug( "GraphicsExpose from %s", win->GetName().c_str(),
+ // event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+ // event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+
+ win->GetUpdateRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+ event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+
+ win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
+ event->xgraphicsexpose.width, event->xgraphicsexpose.height);
+
+ if (event->xgraphicsexpose.count == 0)
+ {
+ // Only erase background, paint in idle time.
+ win->SendEraseEvents();
+ // win->Update();
+ }
+
+ return TRUE;
+ }
+#endif
+
+ case KeyPress:
+ {
+ if (!win->IsEnabled())
+ return FALSE;
+
+ wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
+ wxTranslateKeyEvent(keyEvent, win, window, event);
+
+ // wxLogDebug( "OnKey from %s", win->GetName().c_str() );
+
+ // We didn't process wxEVT_KEY_DOWN, so send wxEVT_CHAR
+ if (win->GetEventHandler()->ProcessEvent( keyEvent ))
+ return TRUE;
+
+ keyEvent.SetEventType(wxEVT_CHAR);
+ if (win->GetEventHandler()->ProcessEvent( keyEvent ))
+ return TRUE;
+
+ if ( (keyEvent.m_keyCode == WXK_TAB) &&
+ win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
+ {
+ wxNavigationKeyEvent new_event;
+ new_event.SetEventObject( win->GetParent() );
+ /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
+ new_event.SetDirection( (keyEvent.m_keyCode == WXK_TAB) );
+ /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ new_event.SetWindowChange( keyEvent.ControlDown() );
+ new_event.SetCurrentFocus( win );
+ return win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
+ }
+
+ return FALSE;
+ }
+ case KeyRelease:
+ {
+ if (!win->IsEnabled())
+ return FALSE;
+
+ wxKeyEvent keyEvent(wxEVT_KEY_UP);
+ wxTranslateKeyEvent(keyEvent, win, window, event);
+
+ return win->GetEventHandler()->ProcessEvent( keyEvent );
+ }
+ case ConfigureNotify:
+ {
+#if wxUSE_NANOX
+ if (event->update.utype == GR_UPDATE_SIZE)
+#endif
+ {
+ if (win->IsTopLevel())
+ {
+ wxTopLevelWindow *tlw = (wxTopLevelWindow*) win;
+ tlw->SetConfigureGeometry( XConfigureEventGetX(event), XConfigureEventGetY(event),
+ XConfigureEventGetWidth(event), XConfigureEventGetHeight(event) );
+ }
+
+ if (win->IsTopLevel() && win->IsShown())
+ {
+ wxTopLevelWindowX11 *tlw = (wxTopLevelWindowX11 *) win;
+ tlw->SetNeedResizeInIdle();
+ }
+ else
+ {
+ wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() );
+ sizeEvent.SetEventObject( win );
+
+ return win->GetEventHandler()->ProcessEvent( sizeEvent );
+ }
+ }
+ return FALSE;
+ break;
+ }
+#if !wxUSE_NANOX
+ case PropertyNotify:
+ {
+ //wxLogDebug("PropertyNotify: %s", windowClass.c_str());
+ return HandlePropertyChange(_event);
+ }
+ case ClientMessage:
+ {
+ if (!win->IsEnabled())
+ return FALSE;
+
+ Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);
+ Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);
+
+ if (event->xclient.message_type == wm_protocols)
+ {
+ if ((Atom) (event->xclient.data.l[0]) == wm_delete_window)
+ {
+ win->Close(FALSE);
+ return TRUE;
+ }
+ }
+ return FALSE;
+ }
+#if 0
+ case DestroyNotify:
+ {
+ printf( "destroy from %s\n", win->GetName().c_str() );
+ break;
+ }
+ case CreateNotify:
+ {
+ printf( "create from %s\n", win->GetName().c_str() );
+ break;
+ }
+ case MapRequest:
+ {
+ printf( "map request from %s\n", win->GetName().c_str() );
+ break;
+ }
+ case ResizeRequest:
+ {
+ printf( "resize request from %s\n", win->GetName().c_str() );
+
+ Display *disp = (Display*) wxGetDisplay();
+ XEvent report;
+
+ // to avoid flicker
+ report = * event;
+ while( XCheckTypedWindowEvent (disp, actualWindow, ResizeRequest, &report));
+
+ wxSize sz = win->GetSize();
+ wxSizeEvent sizeEvent(sz, win->GetId());
+ sizeEvent.SetEventObject(win);
+
+ return win->GetEventHandler()->ProcessEvent( sizeEvent );
+ }
+#endif
+#endif
+#if wxUSE_NANOX
+ case GR_EVENT_TYPE_CLOSE_REQ:
+ {
+ if (win)
+ {
+ win->Close(FALSE);
+ return TRUE;
+ }
+ return FALSE;
+ break;
+ }
+#endif
+ case EnterNotify:
+ case LeaveNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ case MotionNotify:
+ {
+ if (!win->IsEnabled())
+ return FALSE;
+
+ // Here we check if the top level window is
+ // disabled, which is one aspect of modality.
+ wxWindow *tlw = win;
+ while (tlw && !tlw->IsTopLevel())
+ tlw = tlw->GetParent();
+ if (tlw && !tlw->IsEnabled())
+ return FALSE;
+
+ if (event->type == ButtonPress)
+ {
+ if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
+ {
+ // This might actually be done in wxWindow::SetFocus()
+ // and not here. TODO.
+ g_prevFocus = wxWindow::FindFocus();
+ g_nextFocus = win;
+
+ win->SetFocus();
+ }
+ }
+
+#if !wxUSE_NANOX
+ if (event->type == LeaveNotify || event->type == EnterNotify)
+ {
+ // Throw out NotifyGrab and NotifyUngrab
+ if (event->xcrossing.mode != NotifyNormal)
+ return FALSE;
+ }
+#endif
+ wxMouseEvent wxevent;
+ wxTranslateMouseEvent(wxevent, win, window, event);
+ return win->GetEventHandler()->ProcessEvent( wxevent );
+ }
+ case FocusIn:
+ {
+#if !wxUSE_NANOX
+ if ((event->xfocus.detail != NotifyPointer) &&
+ (event->xfocus.mode == NotifyNormal))
+#endif
+ {
+ // wxLogDebug( "FocusIn from %s of type %s", win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+
+ wxFocusEvent focusEvent(wxEVT_SET_FOCUS, win->GetId());
+ focusEvent.SetEventObject(win);
+ focusEvent.SetWindow( g_prevFocus );
+ g_prevFocus = NULL;
+
+ return win->GetEventHandler()->ProcessEvent(focusEvent);
+ }
+ return FALSE;
+ break;
+ }
+ case FocusOut:
+ {
+#if !wxUSE_NANOX
+ if ((event->xfocus.detail != NotifyPointer) &&
+ (event->xfocus.mode == NotifyNormal))
+#endif
+ {
+ // wxLogDebug( "FocusOut from %s of type %s", win->GetName().c_str(), win->GetClassInfo()->GetClassName() );
+
+ wxFocusEvent focusEvent(wxEVT_KILL_FOCUS, win->GetId());
+ focusEvent.SetEventObject(win);
+ focusEvent.SetWindow( g_nextFocus );
+ g_nextFocus = NULL;
+ return win->GetEventHandler()->ProcessEvent(focusEvent);
+ }
+ return FALSE;
+ break;
+ }
+ default:
+ {
+#ifdef __WXDEBUG__
+ //wxString eventName = wxGetXEventName(XEvent& event);
+ //wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
+#endif
+ return FALSE;
+ break;
+ }