// Created: 01.11.02
// RCS-ID: $Id$
// Copyright: (c) 2002 Mattia Barbon
-// License: wxWindows license
+// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "evtloop.h"
#endif
#include "wx/evtloop.h"
#include "wx/event.h"
#include "wx/app.h"
+#include "wx/window.h"
#ifdef __VMS__
#pragma message disable nosimpint
static bool SendIdleMessage()
{
- wxIdleEvent event;
-
- return wxTheApp->ProcessEvent(event) && event.MoreRequested();
+ return wxTheApp->ProcessIdle();
}
bool wxEventLoopImpl::SendIdleMessage()
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
-wxEventLoop *wxEventLoop::ms_activeLoop = NULL;
+wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL;
wxEventLoop::~wxEventLoop()
{
wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
}
-bool wxEventLoop::IsRunning() const
-{
- return m_impl != NULL;
-}
-
int wxEventLoop::Run()
{
// event loops are not recursive, you need to create another loop!
* window is recieved. Prevents flicker as windows are resized.
*/
- Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
+ Display *disp = event->xany.display;
Window win = event->xany.window;
XEvent report;
{
// Find a wxWindow for this window
// TODO: should get display for the window, not the current display
- Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
+ Widget widget = XtWindowToWidget(event->xany.display,
event->xany.window);
wxWindow* win = NULL;
{
if (event->xany.type == KeyPress)
{
- Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
- event->xany.window);
+ Widget widget = XtWindowToWidget(event->xany.display,
+ event->xany.window);
wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, event);
- return win->ProcessEvent( keyEvent );
+ return win->GetEventHandler()->ProcessEvent( keyEvent );
}
return false;
{
if (event->xany.type == KeyRelease)
{
- Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
- event->xany.window);
+ Widget widget = XtWindowToWidget(event->xany.display,
+ event->xany.window);
wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, event);
- return win->ProcessEvent( keyEvent );
+ return win->GetEventHandler()->ProcessEvent( keyEvent );
}
return false;
// leave the main loop to give other threads a chance to
// perform their GUI work
wxMutexGuiLeave();
- wxUsleep(20);
+ wxMilliSleep(20);
wxMutexGuiEnter();
}
#endif
virtual bool OnInit()
{
+ // Must be done before modules are initialized
+#if 0
if( pipe(idleFds) != 0 )
return false;
-
+#endif
return true;
}
close( idleFds[1] );
}
private:
- DECLARE_DYNAMIC_CLASS(wxIdlePipeModule);
+ DECLARE_DYNAMIC_CLASS(wxIdlePipeModule)
};
IMPLEMENT_DYNAMIC_CLASS(wxIdlePipeModule, wxModule);
static void wxBreakDispatch()
{
- char dummy;
+ char dummy = 0; // for valgrind
// check if wxWakeUpIdle has already been called
fd_set in;
write( idleFds[1], &dummy, 1 );
}
-void wxWakeUpIdle()
+void wxApp::WakeUpIdle()
{
::wxBreakDispatch();
}
+bool wxInitIdleFds()
+{
+ if( pipe(idleFds) != 0 )
+ return false;
+ return true;
+}
+
bool wxAddIdleCallback()
{
+ if (!wxInitIdleFds())
+ return false;
+
// install input handler for wxWakeUpIdle
inputId = XtAppAddInput( (XtAppContext) wxTheApp->GetAppContext(),
idleFds[0],