Usermode/AxWin4 - Send mouse/keyboard events to client
authorJohn Hodge (sonata) <[email protected]>
Sun, 9 Nov 2014 00:07:04 +0000 (08:07 +0800)
committerJohn Hodge (sonata) <[email protected]>
Sun, 9 Nov 2014 00:07:04 +0000 (08:07 +0800)
AcessNative/RunNative
Externals/libspiderscript/source
Usermode/Applications/axwin4_src/Common/include/ipc_proto.hpp
Usermode/Applications/axwin4_src/Server/CWindow.cpp
Usermode/Applications/axwin4_src/Server/compositor.cpp
Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp
Usermode/Applications/axwin4_src/Server/include/ipc.hpp
Usermode/Applications/axwin4_src/Server/ipc.cpp
Usermode/Libraries/libaxwin4.so_src/ipc.cpp

index f22ed7f..03ec6b0 100755 (executable)
@@ -25,5 +25,6 @@ echo Kernel is $KERNEL_PID
 sleep 1
 LD_LIBRARY_PATH=${DIR}:${DISTROOT}Libs AN_PREOPEN=$VTERM:$VTERM:$VTERM ${DBG} ${DISTROOT}Apps/AxWin/4.0/AxWinServer
 
+trap '' SIGINT
 cleanup
 
index a5d190a..9f2d7fa 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a5d190a89ca3f3a78c8b44a855b044ff4e713bb3
+Subproject commit 9f2d7faf34c16ceaee2f1bffe3d5558c41382523
index e47ed14..d9c71bd 100644 (file)
@@ -33,6 +33,9 @@ enum
        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
@@ -50,6 +53,13 @@ enum eIPC_WinAttrs
        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
index 55c2482..7d50b7b 100644 (file)
@@ -59,7 +59,7 @@ void CWindow::Move(int X, int Y)
 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)
 {
@@ -74,14 +74,18 @@ uint64_t CWindow::ShareSurface()
 
 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());
 }
 
 
index da924e8..cf8192e 100644 (file)
@@ -16,6 +16,7 @@ namespace AxWin {
 CCompositor::CCompositor(CVideo& video):
        // TODO: Support multiple screens
        m_video(video),
+       m_focussed_window(nullptr),
        m_windowIDBuffer(video.width(), video.height())
 {
        // 
@@ -54,7 +55,7 @@ void CCompositor::Redraw()
 {
        // Redraw the screen and clear damage rects
        if( m_damageRects.empty() ) {
-               _SysDebug("- No damaged regions");
+               //_SysDebug("- No damaged regions");
                return ;
        }
        
@@ -112,7 +113,8 @@ void CCompositor::MouseMove(unsigned int Cursor, unsigned int X, unsigned int Y,
        CWindow *dstwin = getWindowForCoord(X, Y);
        if( dstwin )
        {
-               // TODO: Pass event on to window
+               // Pass event on to window
+               dstwin->MouseMove(X, Y);
        }
 }
 
@@ -125,13 +127,17 @@ void CCompositor::MouseButton(unsigned int Cursor, unsigned int X, unsigned int
        {
                // 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)
index ec40d36..fe24303 100644 (file)
@@ -50,6 +50,7 @@ class CCompositor
        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
        
index 5706a85..50b0dbe 100644 (file)
@@ -31,7 +31,10 @@ extern void  RegisterClient(CClient& client);
 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);
 
index 1c5ba99..5f59ae1 100644 (file)
@@ -101,9 +101,36 @@ void DeregisterClient(CClient& client)
 }
 
 
-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);
 }
 
 
index a262a9e..e42d406 100644 (file)
@@ -86,6 +86,15 @@ void RecvMessage(CDeserialiser& message)
        _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 )
@@ -103,6 +112,9 @@ void RecvMessage(CDeserialiser& message)
                        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;

UCC git Repository :: git.ucc.asn.au