sleep 1
LD_LIBRARY_PATH=${DIR}:${DISTROOT}Libs AN_PREOPEN=$VTERM:$VTERM:$VTERM ${DBG} ${DISTROOT}Apps/AxWin/4.0/AxWinServer
+trap '' SIGINT
cleanup
-Subproject commit a5d190a89ca3f3a78c8b44a855b044ff4e713bb3
+Subproject commit 9f2d7faf34c16ceaee2f1bffe3d5558c41382523
IPCMSG_BLIT, // (win, sx, sy, dx, dy, w, h) - Blit locally
IPCMSG_DRAWCTL, // (win, x, y, w, h, ctlid) - Draw
IPCMSG_DRAWTEXT, // (win, x, y, fontid, text) - Draw text using an internal font
+
+ // - Client-bound commands
+ IPCMSG_INPUTEVENT, // (u8 event, u16 win, ...)
};
enum eIPC_GlobalAttrs
IPC_WINATTR_TITLE, // string
};
+enum eIPC_InputEvents
+{
+ IPC_INEV_KEYBOARD, // (u16 keysym, u8 keydown, string text)
+ IPC_INEV_MOUSEBTN, // (u16 x, u16 y)
+ IPC_INEV_MOUSEMOVE, // (u16 x, u16 y, u8 btn, u8 btndown)
+};
+
};
#endif
void CWindow::Resize(unsigned int W, unsigned int H)
{
m_surface.Resize(W, H);
- IPC::SendMessage_NotifyDims(m_client, W, H);
+ IPC::SendMessage_NotifyDims(m_client, m_id, W, H);
}
void CWindow::SetFlags(uint32_t Flags)
{
void CWindow::MouseButton(int ButtonID, int X, int Y, bool Down)
{
+ IPC::SendMessage_MouseButton(m_client, m_id, X, Y, ButtonID, Down);
}
void CWindow::MouseMove(int NewX, int NewY)
{
+ // TODO: Only enable move events if client requests them
+ //IPC::SendMessage_MouseMove(m_client, m_id, NewX, NewY);
}
void CWindow::KeyEvent(::uint32_t Scancode, const ::std::string &Translated, bool Down)
{
+ IPC::SendMessage_KeyEvent(m_client, m_id, Scancode, Down, Translated.c_str());
}
CCompositor::CCompositor(CVideo& video):
// TODO: Support multiple screens
m_video(video),
+ m_focussed_window(nullptr),
m_windowIDBuffer(video.width(), video.height())
{
//
{
// Redraw the screen and clear damage rects
if( m_damageRects.empty() ) {
- _SysDebug("- No damaged regions");
+ //_SysDebug("- No damaged regions");
return ;
}
CWindow *dstwin = getWindowForCoord(X, Y);
if( dstwin )
{
- // TODO: Pass event on to window
+ // Pass event on to window
+ dstwin->MouseMove(X, Y);
}
}
{
// 1. Give focus and bring to front
// 2. Send event
- // TODO: Pass event on to window
+ dstwin->MouseButton(Button, X, Y, Press);
}
}
void CCompositor::KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint)
{
_SysDebug("KeyState(%i, 0x%x, %b, 0x%x)", KeyboardID, KeySym, Press, Codepoint);
+ if( m_focussed_window )
+ {
+ m_focussed_window->KeyEvent(KeySym, "", Press);
+ }
}
CWindow* CCompositor::getWindowForCoord(unsigned int X, unsigned int Y)
CVideo& m_video;
::std::list<CRect> m_damageRects;
::std::list<CWindow*> m_windows;
+ CWindow* m_focussed_window;
CWindowIDBuffer m_windowIDBuffer; // One 32-bit value per pixel
extern CClient* GetClientByID(uint16_t id);
extern void DeregisterClient(CClient& client);
-extern void SendMessage_NotifyDims(CClient& client, unsigned int NewW, unsigned int NewH);
+extern void SendMessage_NotifyDims(CClient& client, unsigned int WinID, unsigned int NewW, unsigned int NewH);
+extern void SendMessage_MouseButton(CClient& client, unsigned int WinID, unsigned int X, unsigned int Y, uint8_t Button, bool Pressed);
+extern void SendMessage_MouseMove(CClient& client, unsigned int WinID, unsigned int X, unsigned int Y);
+extern void SendMessage_KeyEvent(CClient& client, unsigned int WinID, uint32_t KeySym, bool Pressed, const char *Translated);
extern void HandleMessage(CClient& client, CDeserialiser& message);
}
-void SendMessage_NotifyDims(CClient& client, unsigned int NewW, unsigned int NewH)
+void SendMessage_NotifyDims(CClient& client, unsigned int WinID, unsigned int NewW, unsigned int NewH)
{
- _SysDebug("TODO: CClient::SendNotify_Dims");
+ _SysDebug("TODO: IPC::SendMessage_NotifyDims");
+}
+void SendMessage_MouseButton(CClient& client, unsigned int WinID, unsigned int X, unsigned int Y, uint8_t Button, bool Pressed)
+{
+ CSerialiser msg;
+ msg.WriteU8(IPCMSG_INPUTEVENT);
+ msg.WriteU8(IPC_INEV_MOUSEBTN);
+ msg.WriteU16(WinID);
+ msg.WriteU16(X);
+ msg.WriteU16(Y);
+ msg.WriteU8(Button);
+ msg.WriteU8(Pressed ? 0 : 1);
+ client.SendMessage(msg);
+}
+void SendMessage_MouseMove(CClient& client, unsigned int WinID, unsigned int X, unsigned int Y)
+{
+ _SysDebug("TODO: IPC::SendMessage_MouseButton");
+}
+void SendMessage_KeyEvent(CClient& client, unsigned int WinID, uint32_t KeySym, bool Pressed, const char *Translated)
+{
+ CSerialiser msg;
+ msg.WriteU8(IPCMSG_INPUTEVENT);
+ msg.WriteU8(IPC_INEV_KEYBOARD);
+ msg.WriteU16(WinID);
+ msg.WriteU16(KeySym);
+ msg.WriteU8(Pressed ? 0 : 1);
+ msg.WriteString(Translated);
+ client.SendMessage(msg);
}
_SysDebug("RecvMessage: id=%i", id);
switch(id)
{
+ case IPCMSG_PING:
+ // If we hear ping, we must pong
+ {
+ CSerialiser pong;
+ pong.WriteU8(IPCMSG_REPLY);
+ pong.WriteU8(IPCMSG_PING);
+ SendMessage(pong);
+ }
+ break;
case IPCMSG_REPLY:
// Flag reply and take a copy of this message
if( !gSyncReplyActive )
gSyncReplyBuf = message;
}
break;
+ // TODO: Handle messages from server (input events, IPC)
+ // TODO: If an event is currently being processed, save the message in a queue to be handled when processing is complete
+ // - This will prevent deep recursion (and make server errors aparent)
default:
_SysDebug("TODO: RecvMessage(%i)", id);
break;