]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/toplevel.cpp
[ 1563875 ] wxTreeCtrl::FindItem asserts when item not found
[wxWidgets.git] / src / dfb / toplevel.cpp
index b607ecc863cc93b0b33c32a965e986fc8f202652..db6224a74bbd9f481e1afadd5fa9596e680b66f9 100644 (file)
@@ -214,7 +214,11 @@ void wxTopLevelWindowDFB::DoMoveWindow(int x, int y, int width, int height)
     wxSize cursize = GetSize();
     if ( cursize.x != width || cursize.y != height )
     {
+        // changing window's size changes its surface:
+        InvalidateDfbSurface();
+
         m_dfbwin->Resize(width, height);
+
         // we must repaint the window after it changed size:
         if ( IsShown() )
             DoRefreshWindow();
@@ -276,10 +280,21 @@ bool wxTopLevelWindowDFB::Show(bool show)
         GetEventHandler()->ProcessEvent(event);
     }
 
-    // FIXME_DFB: do this at all?
-    if ( show && AcceptsFocus() )
-        SetFocus();
-        // FIXME_DFB -- don't do this for popup windows?
+    if ( show )
+    {
+        wxWindow *focused = wxWindow::FindFocus();
+        if ( focused && focused->GetTLW() == this )
+        {
+            SetDfbFocus();
+        }
+        else if ( AcceptsFocus() )
+        {
+            // FIXME: we should probably always call SetDfbFocus instead
+            // and call SetFocus() from wxActivateEvent/DWET_GOTFOCUS
+            // handler
+            SetFocus();
+        }
+    }
 
     return true;
 }
@@ -465,6 +480,15 @@ void wxTopLevelWindowDFB::Update()
 // events handling
 // ---------------------------------------------------------------------------
 
+void wxTopLevelWindowDFB::SetDfbFocus()
+{
+    wxCHECK_RET( IsShown(), _T("cannot set focus to hidden window") );
+    wxASSERT_MSG( FindFocus() && FindFocus()->GetTLW() == this,
+                  _T("setting DirectFB focus to unexpected window") );
+
+    GetDirectFBWindow()->RequestFocus();
+}
+
 /* static */
 void wxTopLevelWindowDFB::HandleDFBWindowEvent(const wxDFBWindowEvent& event_)
 {