3 * - By John Hodge (thePowersGang)
9 #include <CCompositor.hpp>
14 CCompositor::CCompositor(CVideo& video):
20 CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name)
22 return new CWindow(*this, client, name);
25 void CCompositor::ShowWindow(CWindow* window)
27 DamageArea(window->m_surface.m_rect);
28 // TODO: Append to separate sub-lists (or to separate lists all together)
29 // if flags AXWIN4_WNDFLAG_KEEPBELOW or AXWIN4_WNDFLAG_KEEPABOVE are set
30 m_windows.push_back(window);
32 void CCompositor::HideWindow(CWindow* window)
34 DamageArea(window->m_surface.m_rect);
35 m_windows.remove(window);
38 bool CCompositor::GetScreenDims(unsigned int ScreenID, unsigned int* W, unsigned int* H)
49 m_video.GetDims(*W, *H);
54 void CCompositor::Redraw()
56 // Redraw the screen and clear damage rects
57 if( m_damageRects.empty() ) {
58 _SysDebug("- No damaged regions");
62 // Build up foreground grid (Rects and windows)
63 // - This should already be built (mutated on window move/resize/reorder)
65 // For all windows, check for intersection with damage rects
66 for( auto rect : m_damageRects )
68 // window list should be sorted by draw order (lowest first)
69 for( auto window : m_windows )
71 if( window->m_is_shown && rect.HasIntersection( window->m_surface.m_rect ) )
74 CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
75 _SysDebug("Reblit (%i,%i) %ix%i", rel_rect.m_x, rel_rect.m_y, rel_rect.m_w, rel_rect.m_h);
76 BlitFromSurface( window->m_surface, rel_rect );
77 //window->Repaint( rel_rect );
81 // TODO: Blit from windows to a local surface, then blit from there to screen here
84 m_damageRects.clear();
88 void CCompositor::DamageArea(const CRect& area)
90 m_damageRects.push_back( area );
91 // 1. Locate intersection with any existing damaged areas
92 // 2. Append after removing intersections
95 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
97 for( unsigned int i = 0; i < src_rect.m_h; i ++ )
100 dest.GetScanline(src_rect.m_y+i, src_rect.m_x),
101 dest.m_rect.m_y + src_rect.m_y + i,
102 dest.m_rect.m_x + src_rect.m_x,
108 void CCompositor::MouseMove(unsigned int Cursor, unsigned int X, unsigned int Y, int dX, int dY)
110 _SysDebug("MouseButton(%i, %i,%i, %+i,%+i)", Cursor, X, Y, dX, dY);
111 m_video.SetCursorPos(X+dX, Y+dY);
112 // TODO: Pass event on to window
115 void CCompositor::MouseButton(unsigned int Cursor, unsigned int X, unsigned int Y, eMouseButton Button, bool Press)
117 _SysDebug("MouseButton(%i, %i,%i, %i=%i)", Cursor, X, Y, Button, Press);
118 // TODO: Pass event on to window
121 void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint)
123 _SysDebug("KeyState(%i, 0x%x, %b, 0x%x)", KeyboardID, KeySym, Press, Codepoint);