#include "wx/log.h"
#include "wx/intl.h"
#include "wx/evtloop.h"
+#include "wx/timer.h"
#include "wx/univ/theme.h"
#include "wx/univ/renderer.h"
extern wxList wxPendingDelete;
wxHashTable *wxWidgetHashTable = NULL;
+wxHashTable *wxClientWidgetHashTable = NULL;
wxApp *wxTheApp = NULL;
#endif
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
+ wxClientWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
wxModule::RegisterModules();
if (!wxModule::InitializeModules()) return FALSE;
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
+ delete wxClientWidgetHashTable;
+ wxClientWidgetHashTable = NULL;
wxModule::CleanUpModules();
wxTheColourDatabase = NULL;
wxDeleteStockObjects();
-
+
wxDeleteStockLists();
delete wxTheApp;
{
XSynchronize(xdisplay, True);
}
-
+
wxApp::ms_display = (WXDisplay*) xdisplay;
-
+
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
-
+
wxSetDetectableAutoRepeat( TRUE );
if (!wxApp::Initialize())
static Bool expose_predicate (Display *display, XEvent *xevent, XPointer arg)
{
wxExposeInfo *info = (wxExposeInfo*) arg;
-
+
if (info->found_non_matching)
return FALSE;
-
+
if (xevent->xany.type != Expose)
{
info->found_non_matching = TRUE;
return FALSE;
}
-
+
if (xevent->xexpose.window != info->window)
{
info->found_non_matching = TRUE;
return FALSE;
}
-
+
return TRUE;
}
#endif
wxWindow* win = NULL;
Window window = XEventGetWindow(event);
+#if 0
Window actualWindow = window;
+#endif
// Find the first wxWindow that corresponds to this event window
// Because we're receiving events after a window
win = wxGetWindowFromTable(window);
if (!win)
- return FALSE;
+ {
+#if wxUSE_TWO_WINDOWS
+ win = wxGetClientWindowFromTable(window);
+ if (!win)
+#endif
+ return FALSE;
+ }
#ifdef __WXDEBUG__
wxString windowClass = win->GetClassInfo()->GetClassName();
#endif
-
+
switch (event->type)
{
+ case Expose:
+ {
+#if wxUSE_TWO_WINDOWS
+ if (event->xexpose.window != (Window)win->GetClientWindow())
+ {
+ XEvent tmp_event;
+ wxExposeInfo info;
+ info.window = event->xexpose.window;
+ info.found_non_matching = FALSE;
+ while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, expose_predicate, (XPointer) &info ))
+ {
+ // Don't worry about optimizing redrawing the border etc.
+ }
+ win->NeedUpdateNcAreaInIdle();
+ }
+ else
+#endif
+ {
+ win->GetUpdateRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
+ XExposeEventGetWidth(event), XExposeEventGetHeight(event));
+ win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
+ XExposeEventGetWidth(event), XExposeEventGetHeight(event));
+
+#if !wxUSE_NANOX
+ XEvent tmp_event;
+ wxExposeInfo info;
+ info.window = event->xexpose.window;
+ info.found_non_matching = FALSE;
+ while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, expose_predicate, (XPointer) &info ))
+ {
+ win->GetUpdateRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
+ tmp_event.xexpose.width, tmp_event.xexpose.height );
+
+ win->GetClearRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
+ tmp_event.xexpose.width, tmp_event.xexpose.height );
+ }
+#endif
+
+ // This simplifies the expose and clear areas to simple
+ // rectangles.
+ win->GetUpdateRegion() = win->GetUpdateRegion().GetBox();
+ win->GetClearRegion() = win->GetClearRegion().GetBox();
+
+ // If we only have one X11 window, always indicate
+ // that borders might have to be redrawn.
+ if (win->GetMainWindow() == win->GetClientWindow())
+ win->NeedUpdateNcAreaInIdle();
+
+ // Only erase background, paint in idle time.
+ win->SendEraseEvents();
+ // win->Update();
+ }
+
+ return TRUE;
+ }
+
+#if !wxUSE_NANOX
+ case GraphicsExpose:
+ {
+ // 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())
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 ))
+
+ // 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)) )
{
- keyEvent.SetEventType(wxEVT_CHAR);
- if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
- return FALSE;
+ 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 TRUE;
+
+ return FALSE;
}
case KeyRelease:
{
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, window, event);
-
+
return win->GetEventHandler()->ProcessEvent( keyEvent );
}
case ConfigureNotify:
if (event->update.utype == GR_UPDATE_SIZE)
#endif
{
- //wxLogDebug("ConfigureNotify: %s", windowClass.c_str());
- wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() );
- sizeEvent.SetEventObject( win );
-
- return win->GetEventHandler()->ProcessEvent( sizeEvent );
+ 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;
}
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:
{
- /*
- * If resize event, don't resize until the last resize event for this
- * window is recieved. Prevents flicker as windows are resized.
- */
-
+ 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));
-
- if (win)
- {
- wxSize sz = win->GetSize();
- wxSizeEvent sizeEvent(sz, win->GetId());
- sizeEvent.SetEventObject(win);
- return win->GetEventHandler()->ProcessEvent( sizeEvent );
- }
+ wxSize sz = win->GetSize();
+ wxSizeEvent sizeEvent(sz, win->GetId());
+ sizeEvent.SetEventObject(win);
- return FALSE;
+ return win->GetEventHandler()->ProcessEvent( sizeEvent );
}
#endif
+#endif
#if wxUSE_NANOX
case GR_EVENT_TYPE_CLOSE_REQ:
{
return FALSE;
break;
}
-#endif
- case Expose:
- {
- //wxLogDebug("Expose: %s", windowClass.c_str());
- win->GetUpdateRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
- XExposeEventGetWidth(event), XExposeEventGetHeight(event));
-
- win->GetClearRegion().Union( XExposeEventGetX(event), XExposeEventGetY(event),
- XExposeEventGetWidth(event), XExposeEventGetHeight(event));
-
-
-#if !wxUSE_NANOX
- XEvent tmp_event;
- wxExposeInfo info;
- info.window = event->xexpose.window;
- info.found_non_matching = FALSE;
- while (XCheckIfEvent( wxGlobalDisplay(), &tmp_event, expose_predicate, (XPointer) &info ))
- {
- win->GetUpdateRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
- tmp_event.xexpose.width, tmp_event.xexpose.height );
-
- win->GetClearRegion().Union( tmp_event.xexpose.x, tmp_event.xexpose.y,
- tmp_event.xexpose.width, tmp_event.xexpose.height );
- }
-#endif
-
- win->SendEraseEvents();
-
- return TRUE;
- }
-#if !wxUSE_NANOX
- case GraphicsExpose:
- {
- // 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();
- }
-
- return TRUE;
- }
#endif
case EnterNotify:
case LeaveNotify:
{
if (!win->IsEnabled())
return FALSE;
-
+
// Here we check if the top level window is
// disabled, which is one aspect of modality.
wxWindow *tlw = win;
tlw = tlw->GetParent();
if (tlw && !tlw->IsEnabled())
return FALSE;
-
+
if (event->type == ButtonPress)
{
if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
// and not here. TODO.
g_prevFocus = wxWindow::FindFocus();
g_nextFocus = win;
-
+
win->SetFocus();
}
}
-
+
#if !wxUSE_NANOX
if (event->type == LeaveNotify || event->type == EnterNotify)
{
#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;
#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 );
return FALSE;
break;
}
-#ifndef wxUSE_NANOX
- case DestroyNotify:
- {
- // Do we want to process this (for top-level windows)?
- // But we want to be able to veto closes, anyway
- return FALSE;
- break;
- }
-#endif
default:
{
#ifdef __WXDEBUG__
node = node->Next();
}
-
+
return needMore;
}
// now we don't want to try popping up a dialog
// for error messages.
delete wxLog::SetActiveTarget(new wxLogStderr);
-
+
if (!wxAppBase::OnInitGui())
return FALSE;
-
+
GetMainColormap( wxApp::GetDisplay() );
m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() );
Window wxGetWindowParent(Window window)
{
wxASSERT_MSG( window, "invalid window" );
-
+
return (Window) 0;
Window parent, root = 0;
s_inYield = TRUE;
+ // Make sure we have an event loop object,
+ // or Pending/Dispatch will fail
+ wxEventLoop* eventLoop = wxEventLoop::GetActive();
+ wxEventLoop* newEventLoop = NULL;
+ if (!eventLoop)
+ {
+ newEventLoop = new wxEventLoop;
+ wxEventLoop::SetActive(newEventLoop);
+ }
+
while (wxTheApp && wxTheApp->Pending())
wxTheApp->Dispatch();
+#if wxUSE_TIMER
+ wxTimer::NotifyTimers();
+#endif
+ ProcessIdle();
+
+ if (newEventLoop)
+ {
+ wxEventLoop::SetActive(NULL);
+ delete newEventLoop;
+ }
+
s_inYield = FALSE;
return TRUE;
}
-wxIcon wxApp::GetStdIcon(int which) const
-{
- return wxTheme::Get()->GetRenderer()->GetStdIcon(which);
-}
-
void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg)
{
// While the GUI isn't working that well, just print out the
// message.
-#if 0
+#if 0
wxAppBase::OnAssert(file, line, msg);
#else
wxString msg2;