]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/toplevel.cpp
Move code that does not need realized GdkWinow out of realize handler
[wxWidgets.git] / src / dfb / toplevel.cpp
index cf667df95ddccd3f85d99e5f8b1155991f7caa42..dc3f425d06c156d589d85a411f9043d1a18d30c2 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     Top level window, abstraction of wxFrame and wxDialog
 // Author:      Vaclav Slavik
 // Created:     2006-08-10
-// RCS-ID:      $Id$
 // Copyright:   (c) 2006 REA Elektronik GmbH
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -19,6 +18,8 @@
 
 #include "wx/dfb/private.h"
 
+#define TRACE_EVENTS "events"
+
 // ============================================================================
 // wxTopLevelWindowDFB
 // ============================================================================
@@ -72,7 +73,6 @@ bool wxTopLevelWindowDFB::Create(wxWindow *parent,
 // showing and hiding
 // ----------------------------------------------------------------------------
 
-#warning "FIXME: the rest of this file is almost same as for MGL, merge it"
 bool wxTopLevelWindowDFB::ShowFullScreen(bool show, long style)
 {
     if ( show == m_fsIsShowing )
@@ -166,3 +166,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);
+    HandleWindowEvent(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");
+        }
+    }
+}