X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/42b0d8b96d2b4246ccfbe985639ee40f94225b5b..11fe6505b848a968f4c89cb3c3fd37a6a03bcaea:/src/dfb/toplevel.cpp diff --git a/src/dfb/toplevel.cpp b/src/dfb/toplevel.cpp index cf667df95d..cac71c9acb 100644 --- a/src/dfb/toplevel.cpp +++ b/src/dfb/toplevel.cpp @@ -19,6 +19,8 @@ #include "wx/dfb/private.h" +#define TRACE_EVENTS "events" + // ============================================================================ // wxTopLevelWindowDFB // ============================================================================ @@ -166,3 +168,40 @@ bool wxTopLevelWindowDFB::IsIconized() const { return false; } + +// ---------------------------------------------------------------------------- +// focus handling +// ---------------------------------------------------------------------------- + +void wxTopLevelWindowDFB::HandleFocusEvent(const wxDFBWindowEvent& event_) +{ + const DFBWindowEvent& dfbevent = event_; + const bool activate = (dfbevent.type == DWET_GOTFOCUS); + + wxLogTrace(TRACE_EVENTS, + "toplevel window %p ('%s') %s focus", + this, GetName(), + activate ? "got" : "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, + "setting wx focus to toplevel window %p ('%s')", + this, GetName()); + + if ( CanAcceptFocus() ) + SetFocus(); + else + wxLogTrace(TRACE_EVENTS, "...which doesn't accept it"); + } + } +}