X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2Fcompositor.cpp;fp=Usermode%2FApplications%2Faxwin4_src%2FServer%2Fcompositor.cpp;h=42bb8b9b1d963564e6debc992a93ba49342fe6c4;hb=8b16265b4394af76f64c30393e27d08c294c4bac;hp=7a18747aa14af6f931209a078fedc8926e19eb2d;hpb=5cab4c07bc13888dc7956194ef9595508072a4eb;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/compositor.cpp b/Usermode/Applications/axwin4_src/Server/compositor.cpp index 7a18747a..42bb8b9b 100644 --- a/Usermode/Applications/axwin4_src/Server/compositor.cpp +++ b/Usermode/Applications/axwin4_src/Server/compositor.cpp @@ -7,21 +7,20 @@ */ #include #include +#include +#include #include namespace AxWin { CCompositor::CCompositor(CVideo& video): - m_video(video) + // TODO: Support multiple screens + m_video(video), + m_windowIDBuffer(video.width(), video.height()) { // } -CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name) -{ - return new CWindow(*this, client, name); -} - void CCompositor::ShowWindow(CWindow* window) { DamageArea(window->m_surface.m_rect); @@ -75,6 +74,7 @@ void CCompositor::Redraw() _SysDebug("Reblit (%i,%i) %ix%i", rel_rect.m_x, rel_rect.m_y, rel_rect.m_w, rel_rect.m_h); BlitFromSurface( window->m_surface, rel_rect ); //window->Repaint( rel_rect ); + m_windowIDBuffer.set(rel_rect.m_x, rel_rect.m_y, rel_rect.m_w, rel_rect.m_h, window); } } @@ -109,13 +109,23 @@ void CCompositor::MouseMove(unsigned int Cursor, unsigned int X, unsigned int Y, { _SysDebug("MouseButton(%i, %i,%i, %+i,%+i)", Cursor, X, Y, dX, dY); m_video.SetCursorPos(X+dX, Y+dY); - // TODO: Pass event on to window + CWindow *dstwin = getWindowForCoord(X, Y); + if( dstwin ) + { + // TODO: Pass event on to window + } } void CCompositor::MouseButton(unsigned int Cursor, unsigned int X, unsigned int Y, eMouseButton Button, bool Press) { _SysDebug("MouseButton(%i, %i,%i, %i=%i)", Cursor, X, Y, Button, Press); - // TODO: Pass event on to window + CWindow *dstwin = getWindowForCoord(X, Y); + if( dstwin ) + { + // 1. Give focus and bring to front + // 2. Send event + // TODO: Pass event on to window + } } void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint) @@ -123,5 +133,38 @@ void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, _SysDebug("KeyState(%i, 0x%x, %b, 0x%x)", KeyboardID, KeySym, Press, Codepoint); } +CWindow* CCompositor::getWindowForCoord(unsigned int X, unsigned int Y) +{ + return m_windowIDBuffer.get(X, Y); +} + +// -------------------------------------------------------------------- +CWindowIDBuffer::CWindowIDBuffer(unsigned int W, unsigned int H): + m_w(W), + m_buf(W*H) +{ +} +void CWindowIDBuffer::set(unsigned int X, unsigned int Y, unsigned int W, unsigned int H, CWindow* win) +{ + TWindowID ent = { + .Client = win->client().id(), + .Window = win->id(), + }; + +} +CWindow* CWindowIDBuffer::get(unsigned int X, unsigned int Y) +{ + if( X >= m_w ) + return nullptr; + unsigned int pos = Y*m_w + X; + if( pos >= m_buf.size() ) + return nullptr; + auto id = m_buf[pos]; + auto client = ::AxWin::IPC::GetClientByID(id.Client); + if( client == nullptr ) + return nullptr; + return client->GetWindow(id.Window); +} + } // namespace AxWin