-
-
-// ----------------------------------------------------------------------------
-// surfaces and painting
-// ----------------------------------------------------------------------------
-
-IDirectFBSurfacePtr wxTopLevelWindowDFB::ObtainDfbSurface() const
-{
- IDirectFBSurfacePtr surface;
- DFB_CALL( m_dfbwin->GetSurface(m_dfbwin, &surface) );
- return surface;
-}
-
-void wxTopLevelWindowDFB::HandleQueuedPaintRequests()
-{
- wxDfbQueuedPaintRequests& toPaint = *m_toPaint;
- if ( toPaint.empty() )
- return; // nothing to do
-
- // process queued paint requests:
- wxRect winRect(wxPoint(0, 0), GetSize());
- wxRect paintedRect;
-
- size_t cnt = toPaint.size();
- for ( size_t i = 0; i < cnt; ++i )
- {
- const wxDfbPaintRequest& request = *toPaint[i];
-
- wxRect clipped(request.m_rect);
-
- wxLogTrace(TRACE_PAINT,
- _T("%p ('%s'): processing paint request [x=%i,y=%i,w=%i,h=%i]"),
- this, GetName().c_str(),
- clipped.x, clipped.y, clipped.width, clipped.height);
-
- clipped.Intersect(winRect);
- if ( clipped.IsEmpty() )
- continue; // nothing to refresh
-
- PaintWindow(clipped, request.m_eraseBackground);
-
- // remember rectangle covering all repainted areas:
- if ( paintedRect.IsEmpty() )
- paintedRect = clipped;
- else
- paintedRect.Union(clipped);
- }
-
- WX_CLEAR_ARRAY(toPaint);
-
- if ( paintedRect.IsEmpty() )
- return; // no painting occurred, no need to flip
-
- // flip the surface to make the changes visible:
- DFBRegion r = {paintedRect.GetLeft(), paintedRect.GetTop(),
- paintedRect.GetRight(), paintedRect.GetBottom()};
- DFBRegion *rptr = (winRect == paintedRect) ? NULL : &r;
-
- IDirectFBSurfacePtr surface(GetDfbSurface());
- DFB_CALL( surface->Flip(surface, rptr, DSFLIP_NONE) );
-}
-
-void wxTopLevelWindowDFB::DoRefreshRect(const wxRect& rect, bool eraseBack)
-{
- // defer paiting until idle time or until Update() is called:
- m_toPaint->push_back(new wxDfbPaintRequest(rect, eraseBack));
-}
-
-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:
- {
- recipient = wxWindow::FindFocus();
- handlerFunc = &wxWindowDFB::HandleKeyEvent;
- break;
- }
-
- case DWET_NONE:
- case DWET_ALL:
- {
- wxFAIL_MSG( _T("invalid event type") );
- break;
- }
- }
-
- if ( !recipient )
- {
- wxLogTrace(TRACE_EVENTS, _T("ignoring event: no recipient window"));
- return;
- }
-
- wxCHECK_RET( recipient && recipient->GetTLW() == tlw,
- _T("event recipient not in TLW which received the event") );
-
- // process the event:
- (recipient->*handlerFunc)(event_);
-}
-
-// ---------------------------------------------------------------------------
-// idle events processing
-// ---------------------------------------------------------------------------
-
-void wxTopLevelWindowDFB::OnInternalIdle()
-{
- wxTopLevelWindowBase::OnInternalIdle();
- HandleQueuedPaintRequests();
-}