- const wxDfbPaintRequest& request = *requests[i];
-
- wxRect clipped(request.m_rect);
- clipped.Intersect(winRect);
- if ( clipped.IsEmpty() )
- continue; // nothing to refresh
-
- wxLogTrace(TRACE_PAINT,
- _T("%p ('%s'): processing paint request [%i,%i,%i,%i]"),
- this, GetName().c_str(),
- clipped.x, clipped.y, clipped.GetRight(), clipped.GetBottom());
-
- PaintWindow(clipped);
-
- // remember rectangle covering all repainted areas:
- if ( paintedRect.IsEmpty() )
- paintedRect = clipped;
- else
- paintedRect.Union(clipped);
- }
-
- m_isPainting = false;
-
- m_toPaint->Clear();
-
- if ( paintedRect.IsEmpty() )
- return; // no painting occurred, no need to flip
-
- // Flip the surface to make the changes visible. Note that the rectangle we
- // flip is *superset* of the union of repainted rectangles (created as
- // "rectangles union" by wxRect::Union) and so some parts of the back
- // buffer that we didn't touch in this HandleQueuedPaintRequests call will
- // be copied to the front buffer as well. This is safe/correct thing to do
- // *only* because wx always use wxIDirectFBSurface::FlipToFront() and so
- // the back and front buffers contain the same data.
- //
- // Note that we do _not_ split m_toPaint into disjoint rectangles and
- // do FlipToFront() for each of them, because that could result in visible
- // updating of the screen; instead, we prefer to flip everything at once.
-
- DFBRegion r = {paintedRect.GetLeft(), paintedRect.GetTop(),
- paintedRect.GetRight(), paintedRect.GetBottom()};
- DFBRegion *rptr = (winRect == paintedRect) ? NULL : &r;
-
- GetDfbSurface()->FlipToFront(rptr);
-
- wxLogTrace(TRACE_PAINT,
- _T("%p ('%s'): flipped surface: [%i,%i,%i,%i]"),
- this, GetName().c_str(),
- paintedRect.x, paintedRect.y,
- paintedRect.GetRight(), paintedRect.GetBottom());
-}
-
-void wxTopLevelWindowDFB::DoRefreshRect(const wxRect& rect)
-{
- wxASSERT_MSG( rect.width > 0 && rect.height > 0, _T("invalid rect") );
-
- wxLogTrace(TRACE_PAINT,
- _T("%p ('%s'): [TLW] refresh rect [%i,%i,%i,%i]"),
- this, GetName().c_str(),
- rect.x, rect.y, rect.GetRight(), rect.GetBottom());
-
- // defer painting until idle time or until Update() is called:
- m_toPaint->Add(rect);
-}
-
-void wxTopLevelWindowDFB::Update()
-{
- HandleQueuedPaintRequests();
-}
-
-// ---------------------------------------------------------------------------
-// events handling
-// ---------------------------------------------------------------------------
-
-/* static */
-void wxTopLevelWindowDFB::HandleDFBWindowEvent(const wxDFBWindowEvent& event_)
-{
- const DFBWindowEvent& event = event_;
-
- if ( gs_dfbWindowsMap.find(event.window_id) == gs_dfbWindowsMap.end() )
- {
- wxLogTrace(TRACE_EVENTS,
- _T("received event for unknown DirectFB window, ignoring"));
- return;
- }
-
- wxTopLevelWindowDFB *tlw = gs_dfbWindowsMap[event.window_id];
- wxWindow *recipient = NULL;
- void (wxWindow::*handlerFunc)(const wxDFBWindowEvent&) = NULL;
-
- switch ( event.type )
- {
- case DWET_KEYDOWN:
- case DWET_KEYUP: