::uint8_t CDeserialiser::ReadU8()
{
- if( m_offset + 1 >= m_length )
- throw ::std::out_of_range("CDeserialiser::ReadU8");
+ RangeCheck("CDeserialiser::ReadU8", 1);
uint8_t rv = m_data[m_offset];
m_offset ++;
return rv;
::uint16_t CDeserialiser::ReadU16()
{
- if( m_offset + 2 >= m_length )
- throw ::std::out_of_range("CDeserialiser::ReadU16");
-
+ RangeCheck("CDeserialiser::ReadU16", 2);
uint16_t rv = m_data[m_offset] | ((uint16_t)m_data[m_offset+1] << 8);
m_offset += 2;
return rv;
CWindow* CClient::GetWindow(int ID)
{
- if( ID == 0 )
- return 0;
-
- return m_windows[ID];
+ _SysDebug("GetWindow(ID=%i)", ID);
+ try {
+ return m_windows.at(ID);
+ }
+ catch(const std::exception& e) {
+ return NULL;
+ }
}
void CClient::SetWindow(int ID, CWindow* window)
if( m_windows[ID] ) {
delete m_windows[ID];
}
- _SysDebug("SetWindow - Set", ID, window);
m_windows[ID] = window;
- _SysDebug("SetWindow - END");
}
void CClient::HandleMessage(CDeserialiser& message)
int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& rfds)
{
- _SysDebug("CIPCChannel_AcessIPCPipe::FillSelect");
int maxfd = m_fd;
FD_SET(m_fd, &rfds);
for( auto& clientref : m_clients )
{
- _SysDebug("CIPCChannel_AcessIPCPipe::FillSelect - FD%i", clientref.m_fd);
maxfd = ::std::max(maxfd, clientref.m_fd);
FD_SET(clientref.m_fd, &rfds);
}
void CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& rfds)
{
- _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect");
if( FD_ISSET(m_fd, &rfds) )
{
- _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - New client on FD %i", m_fd);
int newfd = _SysOpenChild(m_fd, "newclient", OPENFLAG_READ|OPENFLAG_WRITE);
- _SysDebug("newfd = %i", newfd);
-
- // emplace creates a new object within the list
- m_clients.emplace( m_clients.end(), *this, newfd );
- IPC::RegisterClient( m_clients.back() );
+ if( newfd == -1 ) {
+ _SysDebug("ERROR - Failure to open new client on FD%i", m_fd);
+ }
+ else {
+ _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - New client on FD %i with FD%i", m_fd, newfd);
+
+ // emplace creates a new object within the list
+ m_clients.emplace( m_clients.end(), *this, newfd );
+ IPC::RegisterClient( m_clients.back() );
+ }
}
for( auto it = m_clients.begin(); it != m_clients.end(); )
{
CClient_AcessIPCPipe& clientref = *it;
- _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - Trying FD%i", clientref.m_fd);
++ it;
if( FD_ISSET(clientref.m_fd, &rfds) )
clientref.HandleReceive();
}
catch( const ::std::exception& e ) {
- _SysDebug("ERROR - Exception processing IPCPipe FD%i: %s",
+ _SysDebug("ERROR - Exception processing IPCPipe FD%i: '%s', removing",
clientref.m_fd, e.what()
);
it = m_clients.erase(--it);
}
}
}
- _SysDebug("CIPCChannel_AcessIPCPipe::HandleSelect - END");
}
{
}
+void CRect::Move(int NewX, int NewY)
+{
+ // TODO: Add a parent rectangle, and prevent this from fully leaving its bounds
+ m_x = NewX;
+ m_y = NewY;
+ m_x2 = m_x + m_w;
+ m_y2 = m_y + m_h;
+}
+
bool CRect::HasIntersection(const CRect& other) const
{
// If other's origin is past our far corner
* - Window
*/
#include <CSurface.hpp>
+#include <cassert>
namespace AxWin {
-CSurface::CSurface(unsigned int x, unsigned int y, unsigned int w, unsigned int h):
+CSurface::CSurface(int x, int y, unsigned int w, unsigned int h):
m_rect(x,y, w,h)
{
}
{
}
+void CSurface::Resize(unsigned int W, unsigned int H)
+{
+ assert(!"TODO: CSurface::Resize");
+}
+
const uint32_t* CSurface::GetScanline(unsigned int row, unsigned int x_ofs) const
{
return 0;
#include <CWindow.hpp>
#include <CCompositor.hpp>
#include <assert.h>
+#include <ipc.hpp>
namespace AxWin {
void CWindow::Move(int X, int Y)
{
- assert(!"TODO: CWindow::Move");
+ m_surface.m_rect.Move(X, Y);
}
void CWindow::Resize(unsigned int W, unsigned int H)
{
- assert(!"TODO: CWindow::Resize");
+ m_surface.Resize(W, H);
+ IPC::SendNotify_Dims(m_client, W, H);
}
uint64_t CWindow::ShareSurface()
{
};
CRect(int X, int Y, unsigned int W, unsigned int H);
+ void Move(int NewX, int NewY);
+
bool HasIntersection(const CRect& other) const;
CRect Intersection(const CRect& other) const;
class CSurface
{
public:
- CSurface(unsigned int x, unsigned int y, unsigned int w, unsigned int h);
+ CSurface(int x, int y, unsigned int w, unsigned int h);
~CSurface();
+ void Resize(unsigned int new_w, unsigned int new_h);
+
const uint32_t* GetScanline(unsigned int row, unsigned int x_ofs) const;
CRect m_rect;
extern void HandleSelect(const ::fd_set& rfds);
extern void RegisterClient(CClient& client);
extern void DeregisterClient(CClient& client);
+
+extern void SendNotify_Dims(CClient& client, unsigned int W, unsigned int H);
+
extern void HandleMessage(CClient& client, CDeserialiser& message);
class CClientFailure:
int FillSelect(fd_set& rfds)
{
int ret = 0;
- _SysDebug("IPC::FillSelect");
for( auto channel : glChannels )
{
_SysDebug("IPC::FillSelect - channel=%p", channel);
void HandleSelect(const fd_set& rfds)
{
- _SysDebug("IPC::HandleSelect");
for( auto channel : glChannels )
{
- _SysDebug("IPC::HandleSelect - channel=%p", channel);
channel->HandleSelect(rfds);
}
}
}
+void SendNotify_Dims(CClient& client, unsigned int NewW, unsigned int NewH)
+{
+ assert(!"TODO: CClient::SendNotify_Dims");
+}
+
void HandleMessage_Nop(CClient& client, CDeserialiser& message)
{
void HandleMessage_DestroyWindow(CClient& client, CDeserialiser& message)
{
uint16_t win_id = message.ReadU16();
+ _SysDebug("_DestroyWindow: (%i)", win_id);
CWindow* win = client.GetWindow(win_id);
if(!win) {
- throw IPC::CClientFailure("Bad window");
+ throw IPC::CClientFailure("_DestroyWindow: Bad window");
}
client.SetWindow(win_id, 0);
{
uint16_t win_id = message.ReadU16();
uint16_t attr_id = message.ReadU16();
-
+ _SysDebug("_SetWindowAttr: (%i, %i)", win_id, attr_id);
+
CWindow* win = client.GetWindow(win_id);
if(!win) {
- throw IPC::CClientFailure("Bad window");
+ throw IPC::CClientFailure("_SetWindowAttr - Bad window");
}
switch(attr_id)
uint16_t new_w = message.ReadU16();
uint16_t new_h = message.ReadU16();
win->Resize(new_w, new_h);
- assert(!"TODO: IPC_WINATTR_DIMENSIONS");
break; }
case IPC_WINATTR_POSITION: {
int16_t new_x = message.ReadS16();
int16_t new_y = message.ReadS16();
win->Move(new_x, new_y);
- assert(!"TODO: IPC_WINATTR_POSITION");
break; }
default:
_SysDebug("HandleMessage_SetWindowAttr - Bad attr %u", attr_id);
void HandleMessage_GetWindowAttr(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_GetWindowAttr");
}
void HandleMessage_SendIPC(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_SendIPC");
}
void HandleMessage_GetWindowBuffer(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_GetWindowBuffer");
}
void HandleMessage_PushData(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_PushData");
}
void HandleMessage_Blit(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_Blit");
}
void HandleMessage_DrawCtl(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_DrawCtl");
}
void HandleMessage_DrawText(CClient& client, CDeserialiser& message)
{
- assert(!"TODO");
+ assert(!"TODO HandleMessage_DrawText");
}
typedef void MessageHandler_op_t(CClient& client, CDeserialiser& message);
if( FD_ISSET(i, &rfds) )
FD_SET(i, &efds);
+ #if 0
for( int i = 0; i < nfd; i ++ ) {
if( FD_ISSET(i, &rfds) ) {
_SysDebug("FD%i", i);
}
}
+ #endif
// TODO: Support _SysSendMessage IPC?
int64_t timeout = Timing::GetTimeToNextEvent();
}
int rv = ::_SysSelect(nfd, &rfds, NULL, NULL/*&efds*/, timeoutp, 0);
+ #if 0
for( int i = 0; i < nfd; i ++ ) {
if( FD_ISSET(i, &rfds) ) {
_SysDebug("FD%i", i);
}
}
- _SysDebug("rv=%i, timeout=%lli", rv, timeout);
+ #endif
+ //_SysDebug("rv=%i, timeout=%lli", rv, timeout);
try {
Timing::CheckEvents();