// wxWindows as in wx
void SetDfbFocus();
+ // overriden in wxTopLevelWindowDFB, there's no common handling for wxTLW
+ // and wxPopupWindow to be done here
+ virtual void HandleFocusEvent(const wxDFBWindowEvent& WXUNUSED(event_)) {}
+
private:
// do queued painting in idle time
void HandleQueuedPaintRequests();
// common part of all ctors
void Init();
+ virtual void HandleFocusEvent(const wxDFBWindowEvent& event_);
+
protected:
wxString m_title;
m_dfbwin->SetOpacity(show ? m_opacity : 0);
if ( show )
- {
- wxWindow *focused = wxWindow::FindFocus();
- if ( focused && focused->GetTLW() == this )
- {
- SetDfbFocus();
- }
- else if ( CanAcceptFocus() )
- {
- // FIXME: we should probably always call SetDfbFocus instead
- // and call SetFocus() from wxActivateEvent/DWET_GOTFOCUS
- // handler
- SetFocus();
- }
- }
+ SetDfbFocus();
return true;
}
}
wxNonOwnedWindow *tlw = gs_dfbWindowsMap[event.window_id];
- wxWindow *recipient = NULL;
- void (wxWindow::*handlerFunc)(const wxDFBWindowEvent&) = NULL;
switch ( event.type )
{
case DWET_KEYDOWN:
case DWET_KEYUP:
{
- recipient = wxWindow::FindFocus();
- handlerFunc = &wxWindowDFB::HandleKeyEvent;
+ wxWindow *recipient = wxWindow::FindFocus();
+ if ( !recipient )
+ {
+ wxLogTrace(TRACE_EVENTS,
+ _T("ignoring event: no recipient window"));
+ return;
+ }
+
+ wxCHECK_RET( recipient && recipient->GetTLW() == tlw,
+ _T("event recipient not in TLW which received the event") );
+
+ recipient->HandleKeyEvent(event_);
break;
}
+ case DWET_GOTFOCUS:
+ case DWET_LOSTFOCUS:
+ tlw->HandleFocusEvent(event_);
+ break;
+
case DWET_NONE:
case DWET_ALL:
- {
wxFAIL_MSG( _T("invalid event type") );
break;
- }
default:
// we're not interested in them here
break;
}
-
- if ( !recipient )
- {
- wxLogTrace(TRACE_EVENTS, _T("ignoring event: no recipient window"));
- return;
- }
-
- wxCHECK_RET( recipient && recipient->GetTLW() == tlw,
- _T("event recipient not in TLW which received the event") );
-
- // process the event:
- (recipient->*handlerFunc)(event_);
}
// ---------------------------------------------------------------------------
#include "wx/dfb/private.h"
+#define TRACE_EVENTS _T("events")
+
// ============================================================================
// wxTopLevelWindowDFB
// ============================================================================
{
return false;
}
+
+// ----------------------------------------------------------------------------
+// focus handling
+// ----------------------------------------------------------------------------
+
+void wxTopLevelWindowDFB::HandleFocusEvent(const wxDFBWindowEvent& event_)
+{
+ const DFBWindowEvent& dfbevent = event_;
+ const bool activate = (dfbevent.type == DWET_GOTFOCUS);
+
+ wxLogTrace(TRACE_EVENTS,
+ _T("toplevel window %p ('%s') %s focus"),
+ this, GetName(),
+ activate ? _T("got") : _T("lost"));
+
+ wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId());
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+
+ // if a frame that doesn't have wx focus inside it just got focus, we
+ // need to set focus to it (or its child):
+ if ( activate )
+ {
+ wxWindow *focused = wxWindow::FindFocus();
+ if ( !focused || focused->GetTLW() != this )
+ {
+ wxLogTrace(TRACE_EVENTS,
+ _T("setting wx focus to toplevel window %p ('%s')"),
+ this, GetName());
+
+ if ( CanAcceptFocus() )
+ SetFocus();
+ }
+ }
+}
if ( gs_mouseCapture == this )
ReleaseMouse();
-#warning "FIXME: what to do with gs_activeFrame here and elsewhere?"
-#if 0
- if (gs_activeFrame == this)
- {
- gs_activeFrame = NULL;
- // activate next frame in Z-order:
- if ( m_wnd->prev )
- {
- wxWindowDFB *win = (wxWindowDFB*)m_wnd->prev->userData;
- win->SetFocus();
- }
- else if ( m_wnd->next )
- {
- wxWindowDFB *win = (wxWindowDFB*)m_wnd->next->userData;
- win->SetFocus();
- }
- }
-#endif
-
if ( gs_focusedWindow == this )
DFBKillFocus();
// are hidden; when the TLW becomes visible, it will set the focus
// to use from wxTLW::Show()
- #warning "FIXME: implement in terms of DWET_{GOT,LOST}FOCUS"
- #warning "FIXME: keep this or not? not, think multiapp core"
-#if 0
- wxWindowDFB *active = wxGetTopLevelParent((wxWindow*)this);
- if ( !(m_windowStyle & wxPOPUP_WINDOW) && active != gs_activeFrame )
- {
- if ( gs_activeFrame )
- {
- wxActivateEvent event(wxEVT_ACTIVATE, false, gs_activeFrame->GetId());
- event.SetEventObject(gs_activeFrame);
- gs_activeFrame->GetEventHandler()->ProcessEvent(event);
- }
-
- gs_activeFrame = active;
- wxActivateEvent event(wxEVT_ACTIVATE, true, gs_activeFrame->GetId());
- event.SetEventObject(gs_activeFrame);
- gs_activeFrame->GetEventHandler()->ProcessEvent(event);
- }
-#endif
-
// notify the parent keeping track of focus for the kbd navigation
// purposes that we got it
wxChildFocusEvent eventFocus((wxWindow*)this);
// parent area at the place of this window (if hiding):
DoRefreshWindow();
-#warning "FIXME: all of this must be implemented for DFB"
-#if 0
- DFB_wmShowWindow(m_wnd, show);
-
- if (!show && gs_activeFrame == this)
- {
- // activate next frame in Z-order:
- if ( m_wnd->prev )
- {
- wxWindowDFB *win = (wxWindowDFB*)m_wnd->prev->userData;
- win->SetFocus();
- }
- else if ( m_wnd->next )
- {
- wxWindowDFB *win = (wxWindowDFB*)m_wnd->next->userData;
- win->SetFocus();
- }
- else
- {
- gs_activeFrame = NULL;
- }
- }
-#endif
-
return true;
}