]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/toplevel.cpp
[ 1560860 ] wxComboCtrl EVT_TEXT filtering.
[wxWidgets.git] / src / dfb / toplevel.cpp
index 3aebd23e4041ffb48ff497290429a1810a9586f1..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;
 }
@@ -441,7 +456,11 @@ void wxTopLevelWindowDFB::HandleQueuedPaintRequests()
 
 void wxTopLevelWindowDFB::DoRefreshRect(const wxRect& rect)
 {
-    wxASSERT_MSG( rect.width > 0 && rect.height > 0, _T("invalid rect") );
+    // don't overlap outside of the window (NB: 'rect' is in window coords):
+    wxRect r(rect);
+    r.Intersect(wxRect(GetSize()));
+    if ( r.IsEmpty() )
+        return;
 
     wxLogTrace(TRACE_PAINT,
                _T("%p ('%s'): [TLW] refresh rect [%i,%i,%i,%i]"),
@@ -461,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_)
 {