ProcessXEvent now returns TRUE if processed, FALSE if not

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-03-08 12:06:12 +00:00
parent 6f8239de23
commit 086fd5603b
3 changed files with 48 additions and 38 deletions

View File

@@ -74,7 +74,7 @@ public:
bool SendIdleEvents(wxWindow* win);
// Processes an X event.
virtual void ProcessXEvent(WXEvent* event);
virtual bool ProcessXEvent(WXEvent* event);
virtual void OnAssert(const wxChar *file, int line, const wxChar *msg);
@@ -94,7 +94,7 @@ public:
long GetMaxRequestSize() const { return m_maxRequestSize; }
// This handler is called when a property change event occurs
virtual void HandlePropertyChange(WXEvent *event);
virtual bool HandlePropertyChange(WXEvent *event);
// We need this before create the app
static WXDisplay* GetDisplay() { return ms_display; }

View File

@@ -449,10 +449,10 @@ static Bool expose_predicate (Display *display, XEvent *xevent, XPointer arg)
// wxUSE_NANOX
//-----------------------------------------------------------------------
// Processes an X event.
// Processes an X event, returning TRUE if the event was processed.
//-----------------------------------------------------------------------
void wxApp::ProcessXEvent(WXEvent* _event)
bool wxApp::ProcessXEvent(WXEvent* _event)
{
XEvent* event = (XEvent*) _event;
@@ -479,7 +479,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
case KeyPress:
{
if (!win->IsEnabled())
return;
return FALSE;
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
wxTranslateKeyEvent(keyEvent, win, window, event);
@@ -491,20 +491,20 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
{
keyEvent.SetEventType(wxEVT_CHAR);
win->GetEventHandler()->ProcessEvent( keyEvent );
if (!win->GetEventHandler()->ProcessEvent( keyEvent ))
return FALSE;
}
return;
return TRUE;
}
case KeyRelease:
{
if (!win->IsEnabled())
return;
return FALSE;
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, window, event);
win->GetEventHandler()->ProcessEvent( keyEvent );
return;
return win->GetEventHandler()->ProcessEvent( keyEvent );
}
case ConfigureNotify:
{
@@ -516,21 +516,21 @@ void wxApp::ProcessXEvent(WXEvent* _event)
wxSizeEvent sizeEvent( wxSize(XConfigureEventGetWidth(event), XConfigureEventGetHeight(event)), win->GetId() );
sizeEvent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( sizeEvent );
return win->GetEventHandler()->ProcessEvent( sizeEvent );
}
return FALSE;
break;
}
#if !wxUSE_NANOX
case PropertyNotify:
{
//wxLogDebug("PropertyNotify: %s", windowClass.c_str());
HandlePropertyChange(_event);
return;
return HandlePropertyChange(_event);
}
case ClientMessage:
{
if (!win->IsEnabled())
return;
return FALSE;
Atom wm_delete_window = XInternAtom(wxGlobalDisplay(), "WM_DELETE_WINDOW", True);
Atom wm_protocols = XInternAtom(wxGlobalDisplay(), "WM_PROTOCOLS", True);
@@ -540,9 +540,10 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if ((Atom) (event->xclient.data.l[0]) == wm_delete_window)
{
win->Close(FALSE);
return TRUE;
}
}
return;
return FALSE;
}
case ResizeRequest:
{
@@ -564,10 +565,10 @@ void wxApp::ProcessXEvent(WXEvent* _event)
wxSizeEvent sizeEvent(sz, win->GetId());
sizeEvent.SetEventObject(win);
win->GetEventHandler()->ProcessEvent( sizeEvent );
return win->GetEventHandler()->ProcessEvent( sizeEvent );
}
return;
return FALSE;
}
#endif
#if wxUSE_NANOX
@@ -576,7 +577,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if (win)
{
win->Close(FALSE);
return TRUE;
}
return FALSE;
break;
}
#endif
@@ -607,7 +610,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
win->SendEraseEvents();
return;
return TRUE;
}
#if !wxUSE_NANOX
case GraphicsExpose:
@@ -628,7 +631,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
win->SendEraseEvents();
}
return;
return TRUE;
}
#endif
case EnterNotify:
@@ -638,7 +641,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
case MotionNotify:
{
if (!win->IsEnabled())
return;
return FALSE;
// Here we check if the top level window is
// disabled, which is one aspect of modality.
@@ -646,7 +649,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
while (tlw && !tlw->IsTopLevel())
tlw = tlw->GetParent();
if (tlw && !tlw->IsEnabled())
return;
return FALSE;
if (event->type == ButtonPress)
{
@@ -658,6 +661,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
g_nextFocus = win;
win->SetFocus();
return TRUE;
}
}
@@ -666,14 +670,12 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
// Throw out NotifyGrab and NotifyUngrab
if (event->xcrossing.mode != NotifyNormal)
return;
return FALSE;
}
#endif
wxMouseEvent wxevent;
wxTranslateMouseEvent(wxevent, win, window, event);
win->GetEventHandler()->ProcessEvent( wxevent );
return;
return win->GetEventHandler()->ProcessEvent( wxevent );
}
case FocusIn:
{
@@ -689,8 +691,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
focusEvent.SetWindow( g_prevFocus );
g_prevFocus = NULL;
win->GetEventHandler()->ProcessEvent(focusEvent);
return win->GetEventHandler()->ProcessEvent(focusEvent);
}
return FALSE;
break;
}
case FocusOut:
@@ -706,8 +709,9 @@ void wxApp::ProcessXEvent(WXEvent* _event)
focusEvent.SetEventObject(win);
focusEvent.SetWindow( g_nextFocus );
g_nextFocus = NULL;
win->GetEventHandler()->ProcessEvent(focusEvent);
return win->GetEventHandler()->ProcessEvent(focusEvent);
}
return FALSE;
break;
}
#ifndef wxUSE_NANOX
@@ -715,6 +719,7 @@ void wxApp::ProcessXEvent(WXEvent* _event)
{
// Do we want to process this (for top-level windows)?
// But we want to be able to veto closes, anyway
return FALSE;
break;
}
#endif
@@ -724,9 +729,11 @@ void wxApp::ProcessXEvent(WXEvent* _event)
//wxString eventName = wxGetXEventName(XEvent& event);
//wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
#endif
return FALSE;
break;
}
}
return FALSE;
}
// Returns TRUE if more time is needed.
@@ -761,11 +768,12 @@ void wxApp::Dispatch()
// This should be redefined in a derived class for
// handling property change events for XAtom IPC.
void wxApp::HandlePropertyChange(WXEvent *event)
bool wxApp::HandlePropertyChange(WXEvent *event)
{
// by default do nothing special
// TODO: what to do for X11
// XtDispatchEvent((XEvent*) event);
return FALSE;
}
void wxApp::OnIdle(wxIdleEvent& event)

View File

@@ -42,8 +42,8 @@ public:
// ctor
wxEventLoopImpl() { SetExitCode(0); m_keepGoing = FALSE; }
// process an XEvent
void ProcessEvent(XEvent* event);
// process an XEvent, return TRUE if it was processed
bool ProcessEvent(XEvent* event);
// generate an idle message, return TRUE if more idle time requested
bool SendIdleEvent();
@@ -71,15 +71,17 @@ public:
// wxEventLoopImpl message processing
// ----------------------------------------------------------------------------
void wxEventLoopImpl::ProcessEvent(XEvent *event)
bool wxEventLoopImpl::ProcessEvent(XEvent *event)
{
// give us the chance to preprocess the message first
if ( !PreProcessEvent(event) )
{
if ( PreProcessEvent(event) )
return TRUE;
// if it wasn't done, dispatch it to the corresponding window
if (wxTheApp)
wxTheApp->ProcessXEvent((WXEvent*) event);
}
return wxTheApp->ProcessXEvent((WXEvent*) event);
return FALSE;
}
bool wxEventLoopImpl::PreProcessEvent(XEvent *event)
@@ -222,7 +224,7 @@ bool wxEventLoop::Dispatch()
// TODO allowing for threads, as per e.g. wxMSW
XNextEvent((Display*) wxGetDisplay(), & event);
m_impl->ProcessEvent(& event);
(void) m_impl->ProcessEvent(& event);
return TRUE;
}