Usermode/axwin4 - Continuing
authorJohn Hodge <[email protected]>
Fri, 23 May 2014 00:13:19 +0000 (08:13 +0800)
committerJohn Hodge <[email protected]>
Fri, 23 May 2014 00:13:19 +0000 (08:13 +0800)
12 files changed:
Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp [new file with mode: 0644]
Usermode/Applications/axwin4_src/Server/Makefile
Usermode/Applications/axwin4_src/Server/compositor.cpp
Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp
Usermode/Applications/axwin4_src/Server/include/CConfigIPC.hpp
Usermode/Applications/axwin4_src/Server/include/CIPCChannel_AcessIPCPipe.hpp [new file with mode: 0644]
Usermode/Applications/axwin4_src/Server/include/IIPCChannel.hpp
Usermode/Applications/axwin4_src/Server/include/input.hpp
Usermode/Applications/axwin4_src/Server/include/ipc.hpp
Usermode/Applications/axwin4_src/Server/input.cpp
Usermode/Applications/axwin4_src/Server/ipc.cpp
Usermode/Applications/axwin4_src/Server/main.cpp

diff --git a/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp b/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp
new file mode 100644 (file)
index 0000000..1686349
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CIPCChannel_AcessIPCPipe.cpp
+ * - IPC Channel :: Acess' IPC Pipe /Devices/ipcpipe/<name>
+ */
+#include <CIPCChannel_AcessIPCPipe.hpp>
+
+namespace AxWin {
+
+CIPCChannel_AcessIPCPipe::CIPCChannel_AcessIPCPipe(const ::std::string& suffix)
+{
+       
+}
+CIPCChannel_AcessIPCPipe::~CIPCChannel_AcessIPCPipe()
+{
+}
+
+int CIPCChannel_AcessIPCPipe::FillSelect(fd_set& rfds)
+{
+       return 0;
+}
+
+void CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& rfds)
+{
+}
+
+};
+
index 2b8089f..2c7a74e 100644 (file)
@@ -5,6 +5,7 @@ CPPFLAGS += -Iinclude/
 OBJ := main.o ipc.o CConfig.o video.o input.o timing.o
 OBJ += compositor.o CWindow.o
 OBJ += serialisation.o CClient.o
+OBJ += CIPCChannel_AcessIPCPipe.o
 OBJ += CRect.o CSurface.o
 BIN := AxWinServer
 
index 9306e41..61d42e3 100644 (file)
@@ -34,6 +34,7 @@ void CCompositor::Redraw()
        // For all windows, check for intersection with damage rects
        for( auto rect : m_damageRects )
        {
+               // window list should be sorted by draw order (lowest first)
                for( auto window : m_windows )
                {
                        if( rect.HasIntersection( window->m_surface.m_rect ) )
@@ -44,6 +45,8 @@ void CCompositor::Redraw()
                                //window->Repaint( rel_rect );
                        }
                }
+               
+               // TODO: Blit from windows to a local surface, then blit from there to screen here
        }
 
        m_damageRects.clear();
@@ -51,6 +54,7 @@ void CCompositor::Redraw()
 
 void CCompositor::DamageArea(const CRect& area)
 {
+       m_damageRects.push_back( area );
        // 1. Locate intersection with any existing damaged areas
        // 2. Append after removing intersections
 }
index 0b051be..48b17c6 100644 (file)
@@ -24,6 +24,15 @@ struct TWindowID
        uint16_t        Window;
 };
 
+enum eMouseButton
+{
+       MOUSEBTN_MAIN,  // Left
+       MOUSEBTN_SECONDARY,     // Right
+       MOUSEBTN_MIDDLE,        // Scroll wheel
+       MOUSEBTN_BTN4,
+       MOUSEBTN_BTN5,
+};
+
 class CCompositor
 {
        CVideo& m_video;
@@ -41,6 +50,11 @@ public:
        void    Redraw();
        void    DamageArea(const CRect& rect);
        void    BlitFromSurface(const CSurface& dest, const CRect& src_rect);
+       
+       void    MouseMove(unsigned int CursorID,  unsigned int X, unsigned int Y,  int dX, int dY);
+       void    MouseButton(unsigned int CursorID,  unsigned int X, unsigned int Y,  eMouseButton Button, bool Press);
+       
+       void    KeyState(unsigned int KeyboardID, uint32_t KeySym, bool Press, uint32_t Codepoint);
 };
 
 
index 9e10dd9..053e376 100644 (file)
@@ -8,8 +8,17 @@
 #ifndef _CCONFIGIPC_H_
 #define _CCONFIGIPC_H_
 
+#include <string>
+
 namespace AxWin {
 
+class CConfigIPC_Channel
+{
+public:
+       ::std::string   m_name;
+       ::std::string   m_argument;
+};
+
 class CConfigIPC
 {
 public:
diff --git a/Usermode/Applications/axwin4_src/Server/include/CIPCChannel_AcessIPCPipe.hpp b/Usermode/Applications/axwin4_src/Server/include/CIPCChannel_AcessIPCPipe.hpp
new file mode 100644 (file)
index 0000000..1e24b0e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CIPCChannel_AcessIPCPipe.hpp
+ * - IPC Channel :: Acess' IPC Pipe /Devices/ipcpipe/<name>
+ */
+#ifndef _CIPCCHANNEL_ACESSIPCPIPE_HPP_
+#define _CIPCCHANNEL_ACESSIPCPIPE_HPP_
+
+#include <IIPCChannel.hpp>
+#include <string>
+#include <list>
+
+namespace AxWin {
+
+class CClient_AcessIPCPipe
+{
+public:
+};
+
+class CIPCChannel_AcessIPCPipe:
+       public IIPCChannel
+{
+        int    m_mainFD;
+       ::std::list<CClient_AcessIPCPipe>       m_clients;
+public:
+       CIPCChannel_AcessIPCPipe(const ::std::string& suffix);
+       virtual ~CIPCChannel_AcessIPCPipe();
+       
+       virtual int  FillSelect(fd_set& rfds);
+       virtual void HandleSelect(const fd_set& rfds);
+};
+
+}      // namespace AxWin
+
+#endif
+
index 5063c4a..5dc88e2 100644 (file)
@@ -8,6 +8,10 @@
 #ifndef _IIPCCHANNEL_H_
 #define _IIPCCHANNEL_H_
 
+extern "C" {
+#include <acess/sys.h>
+}
+
 namespace AxWin {
 
 class IIPCChannel
@@ -16,7 +20,7 @@ public:
        virtual ~IIPCChannel();
        
        virtual int     FillSelect(::fd_set& rfds) = 0;
-       virtual void    HandleSelect(::fd_set& rfds) = 0;
+       virtual void    HandleSelect(const ::fd_set& rfds) = 0;
 };
 
 
index 6a43034..952e2e9 100644 (file)
 #include <acess/sys.h>
 
 namespace AxWin {
-namespace Input {
 
-extern void    Initialise(const CConfigInput& config);
-extern int     FillSelect(::fd_set& rfds);
-extern void    HandleSelect(::fd_set& rfds);
+class CCompositor;
 
+class CInput
+{
+       CCompositor&    m_compositor;
+        int    m_keyboardFD;
+        int    m_mouseFD;
+public:
+       CInput(const CConfigInput& config, CCompositor& compositor);
+        int FillSelect(::fd_set& rfds);
+       void HandleSelect(::fd_set& rfds);
 };
-};
+
+};     // namespace AxWin
 
 #endif
 
index 439f3ea..c51c201 100644 (file)
@@ -19,7 +19,7 @@ class CCompositor;
 
 namespace IPC {
 
-extern void    Initialise(const CConfigIPC& config, CCompositor* compositor);
+extern void    Initialise(const CConfigIPC& config, CCompositor& compositor);
 extern int     FillSelect(::fd_set& rfds);
 extern void    HandleSelect(::fd_set& rfds);
 
index bea4777..7519b87 100644 (file)
@@ -7,26 +7,38 @@
  */
 #include <CConfigInput.hpp>
 #include <input.hpp>
+#include <CCompositor.hpp>
+#include <algorithm>
 
 namespace AxWin {
 
-namespace Input {
-
-void Initialise(const ::AxWin::CConfigInput& config)
+CInput::CInput(const ::AxWin::CConfigInput& config, CCompositor& compositor):
+       m_compositor(compositor),
+       m_keyboardFD(0),
+       m_mouseFD(-1)
 {
        
 }
 
-int FillSelect(::fd_set& rfds)
+int CInput::FillSelect(::fd_set& rfds)
 {
-       return 0;
+       FD_SET(m_keyboardFD, &rfds);
+       FD_SET(m_mouseFD, &rfds);
+       return ::std::max(m_keyboardFD, m_mouseFD)+1;
 }
 
-void HandleSelect(::fd_set& rfds)
+void CInput::HandleSelect(::fd_set& rfds)
 {
+       if( FD_ISSET(m_keyboardFD, &rfds) )
+       {
+               // TODO: Read keystroke and handle
+       }
+       
+       if( FD_ISSET(m_mouseFD, &rfds) )
+       {
+               // TODO: Read mouse event and handle
+       }
 }
 
-};
-
 };     // namespace AxWin
 
index 0d92e6a..2a63350 100644 (file)
 extern "C" {
 #include <assert.h>
 };
+#include <CIPCChannel_AcessIPCPipe.hpp>
 
 namespace AxWin {
 namespace IPC {
 
 CCompositor*   gpCompositor;
-::std::list<IIPCChannel*>      channels;
+::std::list<IIPCChannel*>      glChannels;
+//::std::map<uint16_t,CClient*>        glClients;
 
-void Initialise(const CConfigIPC& config, CCompositor* compositor)
+void Initialise(const CConfigIPC& config, CCompositor& compositor)
 {
-       gpCompositor = compositor;
+       gpCompositor = &compositor;
+       
+       ::std::string pipe_basepath = "axwin4";
+       glChannels.push_back( new CIPCChannel_AcessIPCPipe( pipe_basepath ) );
+
+       //glChannels.push_back( new CIPCChannel_TCP("0.0.0.0:2100") );
+       
        //for( auto channel : config.m_channels )
        //{
        //      channels.push_back(  );
@@ -30,7 +38,7 @@ void Initialise(const CConfigIPC& config, CCompositor* compositor)
 int FillSelect(fd_set& rfds)
 {
        int ret = 0;
-       for( auto channel : channels )
+       for( auto channel : glChannels )
        {
                ret = ::std::max(ret, channel->FillSelect(rfds));
        }
@@ -39,12 +47,22 @@ int FillSelect(fd_set& rfds)
 
 void HandleSelect(fd_set& rfds)
 {
-       
+       for( auto channel : glChannels )
+       {
+               channel->HandleSelect(rfds);
+       }
 }
 
-void RegisterClient(IIPCChannel& channel, CClient& client)
+void RegisterClient(CClient& client)
 {
-       
+       // allocate a client ID, and save
+       //client.m_id = 123;
+       //glClients[client.m_id] = &client;
+}
+
+void DeregisterClient(CClient& client)
+{
+       //glClients.erase( client.m_id );
 }
 
 
@@ -163,6 +181,11 @@ void HandleMessage_SendIPC(CClient& client, CDeserialiser& message)
        assert(!"TODO");
 }
 
-};
+};     // namespace IPC
+
+IIPCChannel::~IIPCChannel()
+{
+}
+
 };     // namespace AxWin
 
index 8f0d9e8..0117806 100644 (file)
@@ -39,10 +39,10 @@ int main(int argc, char *argv[])
        // - Initialise compositor structures
        CCompositor* compositor = new CCompositor(/*config.m_compositor,*/ *vid);
        // - Open input
-       Input::Initialise(config.m_input);
+       CInput* input = new CInput(config.m_input, *compositor);
        //  > Handles hotkeys?
        // - Bind IPC channels
-       IPC::Initialise(config.m_ipc, compositor);
+       IPC::Initialise(config.m_ipc, *compositor);
        // - Start root child process (from config)
        // TODO: Spin up child process
 
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
                 int    nfd = 0;
                fd_set  rfds;
                
-               nfd = ::std::max(nfd, Input::FillSelect(rfds));
+               nfd = ::std::max(nfd, input->FillSelect(rfds));
                nfd = ::std::max(nfd, IPC::FillSelect(rfds));
                
                // TODO: Support _SysSendMessage IPC?
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
                
                Timing::CheckEvents();
                
-               Input::HandleSelect(rfds);
+               input->HandleSelect(rfds);
                IPC::HandleSelect(rfds);
                
                compositor->Redraw();

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