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 bool CCompositor::GetScreenDims(unsigned int ScreenID, unsigned int* W, unsigned int* H)
36 m_video.GetDims(*W, *H);
41 void CCompositor::Redraw()
43 _SysDebug("CCompositor::Redraw");
44 // Redraw the screen and clear damage rects
45 if( m_damageRects.empty() )
48 // Build up foreground grid (Rects and windows)
49 // - This should already be built (mutated on window move/resize/reorder)
51 // For all windows, check for intersection with damage rects
52 for( auto rect : m_damageRects )
54 _SysDebug("rect=(%i,%i) %ix%i", rect.m_x, rect.m_y, rect.m_w, rect.m_h);
55 // window list should be sorted by draw order (lowest first)
56 for( auto window : m_windows )
58 if( rect.HasIntersection( window->m_surface.m_rect ) )
61 CRect rel_rect = window->m_surface.m_rect.RelativeIntersection(rect);
62 BlitFromSurface( window->m_surface, rel_rect );
63 //window->Repaint( rel_rect );
67 // TODO: Blit from windows to a local surface, then blit from there to screen here
70 m_damageRects.clear();
74 void CCompositor::DamageArea(const CRect& area)
76 m_damageRects.push_back( area );
77 // 1. Locate intersection with any existing damaged areas
78 // 2. Append after removing intersections
81 void CCompositor::BlitFromSurface(const CSurface& dest, const CRect& src_rect)
83 for( unsigned int i = 0; i < src_rect.m_h; i ++ )
86 dest.GetScanline(src_rect.m_y, src_rect.m_y),
87 dest.m_rect.m_y + src_rect.m_y + i,
88 dest.m_rect.m_x + src_rect.m_x,
94 void CCompositor::MouseMove(unsigned int Cursor, unsigned int X, unsigned int Y, int dX, int dY)
96 _SysDebug("MouseButton(%i, %i,%i, %+i,%+i)", Cursor, X, Y, dX, dY);
97 m_video.SetCursorPos(X+dX, Y+dY);
98 // TODO: Pass event on to window
101 void CCompositor::MouseButton(unsigned int Cursor, unsigned int X, unsigned int Y, eMouseButton Button, bool Press)
103 _SysDebug("MouseButton(%i, %i,%i, %i=%i)", Cursor, X, Y, Button, Press);
104 // TODO: Pass event on to window
107 void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint)
109 _SysDebug("KeyState(%i, 0x%x, %b, 0x%x)", KeyboardID, KeySym, Press, Codepoint);