Usermode/libaxwin4 - Implementation and debug
authorJohn Hodge <[email protected]>
Mon, 26 May 2014 09:44:09 +0000 (17:44 +0800)
committerJohn Hodge <[email protected]>
Mon, 26 May 2014 09:44:09 +0000 (17:44 +0800)
Usermode/Libraries/libaxwin4.so_src/Makefile
Usermode/Libraries/libaxwin4.so_src/include_exp/axwin4/axwin.h
Usermode/Libraries/libaxwin4.so_src/ipc.cpp
Usermode/Libraries/libaxwin4.so_src/ipc_acessipcpipe.cpp
Usermode/Libraries/libaxwin4.so_src/window_drawing.cpp [new file with mode: 0644]
Usermode/Libraries/libaxwin4.so_src/wm.cpp

index 3162667..c279a04 100644 (file)
@@ -12,9 +12,8 @@ ASFLAGS  +=
 LDFLAGS  += -soname libaxwin4.so -Map map.txt -lc -lc++
 
 OBJ  = main.o ipc.o ipc_acessipcpipe.o
-OBJ += wm.o
+OBJ += wm.o window_drawing.o
 OBJ += Common__serialisation.o
-DEPFILES := $(OBJ:%.o=%.d)
 BIN = libaxwin4.so
 
 include ../Makefile.tpl
@@ -22,7 +21,8 @@ include ../Makefile.tpl
 $(_OBJPREFIX)Common__%.o: $(AXWIN4DIR)/Common/%.cpp
        @echo [CXX] -o $@
        @mkdir -p $(dir $@)
-       $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MQ $@ -MP -MD -MF $(@:%.o=%.dep)
+       $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MQ $@ -MP -MD -MF $(@:%=%.dep)
+
 
 
 
index fd54581..1bcf6f7 100644 (file)
@@ -22,6 +22,8 @@ extern bool   AxWin4_WaitEventQueueSelect(int nFDs, fd_set *rfds, fd_set *wfds, fd
 extern tAxWin4_Window  *AxWin4_CreateWindow(const char *Name);
 extern void    AxWin4_ShowWindow(tAxWin4_Window *Window);
 extern void    AxWin4_SetTitle(tAxWin4_Window *Window, const char *Title);
+extern void    AxWin4_MoveWindow(tAxWin4_Window *Window, int X, int Y);
+extern void    AxWin4_ResizeWindow(tAxWin4_Window *Window, unsigned int W, unsigned int H);
 extern void    AxWin4_DrawBitmap(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, void *Data);
 
 
index c7a2455..10331fb 100644 (file)
@@ -20,16 +20,18 @@ IIPCChannel*        gIPCChannel;
 
 extern "C" bool AxWin4_Connect(const char *URI)
 {
+       _SysDebug("AxWin4_Connect('%s')", URI);
        if( gIPCChannel ) {
                return false;
        }
        try {
                if( strncmp(URI, "ipcpipe://", 3+4+3) == 0 )
                {
-                       gIPCChannel = new CIPCChannel_AcessIPCPipe(URI);
+                       gIPCChannel = new CIPCChannel_AcessIPCPipe(URI+3+4+3);
                }
                else
                {
+                       _SysDebug("Unknown protocol");
                        return false;
                }
        }
@@ -54,8 +56,10 @@ extern "C" bool AxWin4_WaitEventQueue(uint64_t Timeout)
 extern "C" bool AxWin4_WaitEventQueueSelect(int nFDs, fd_set *rfds, fd_set *wfds, fd_set *efds, uint64_t Timeout)
 {
        fd_set  local_rfds;
-       if( !rfds )
+       if( !rfds ) {
+               FD_ZERO(&local_rfds);
                rfds = &local_rfds;
+       }
        
        int64_t select_timeout = Timeout;
        int64_t *select_timeout_p = (Timeout ? &select_timeout : 0);
index b7a509c..2f879ff 100644 (file)
@@ -39,7 +39,12 @@ bool CIPCChannel_AcessIPCPipe::HandleSelect(const fd_set& fds)
 
 void CIPCChannel_AcessIPCPipe::Send(CSerialiser& message)
 {
-       // TODO:
+       const ::std::vector<uint8_t>& serialised = message.Compact();
+       if(serialised.size() > 0x1000 ) {
+               throw ::std::length_error("CIPCChannel_AcessIPCPipe::Send");
+       }
+       _SysDebug("Send %i bytes", serialised.size());
+       _SysWrite(m_fd, serialised.data(), serialised.size());
 }
 
 
diff --git a/Usermode/Libraries/libaxwin4.so_src/window_drawing.cpp b/Usermode/Libraries/libaxwin4.so_src/window_drawing.cpp
new file mode 100644 (file)
index 0000000..df320ef
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * AxWin4 Interface Library
+ * - By John Hodge (thePowersGang)
+ *
+ * window_drawing.cpp
+ * - Window drawing code
+ */
+#include <axwin4/axwin.h>
+#include "include/common.hpp"
+#include <ipc_proto.hpp>
+
+namespace AxWin {
+
+extern "C" void AxWin4_DrawBitmap(tAxWin4_Window *Window, int X, int Y, unsigned int W, unsigned int H, void *Data)
+{
+       // TODO: Split message up into blocks such that it can be dispatched
+       if( W > 128 )
+       {
+               const uint32_t* data32 = static_cast<uint32_t*>(Data);
+               for( unsigned int row = 0; row < H; row ++ )
+               {
+                       CSerialiser     message;
+                       message.WriteU8(IPCMSG_PUSHDATA);
+                       message.WriteU16(Window->m_id);
+                       message.WriteU16(X);
+                       message.WriteU16(Y+row);
+                       message.WriteU16(W);
+                       message.WriteU16(1);
+                       message.WriteBuffer(W*4, data32);
+                       ::AxWin::SendMessage(message);
+                       data32 += W;
+               }
+       }
+       else
+       {
+               CSerialiser     message;
+               message.WriteU8(IPCMSG_PUSHDATA);
+               message.WriteU16(Window->m_id);
+               message.WriteU16(X);
+               message.WriteU16(Y);
+               message.WriteU16(W);
+               message.WriteU16(H);
+               message.WriteBuffer(W*H*4, Data);
+               ::AxWin::SendMessage(message);
+       }
+}
+
+};     // namespace AxWin
+
index 12c02c5..50712d4 100644 (file)
@@ -16,25 +16,62 @@ extern "C" tAxWin4_Window *AxWin4_CreateWindow(const char *Name)
        // Allocate a window ID
        // Create window structure locally
        // Request creation of window
+       CSerialiser     message;
+       message.WriteU8(IPCMSG_CREATEWIN);
+       message.WriteU16(0);
+       message.WriteString(Name);
+       ::AxWin::SendMessage(message);
 }
 
 extern "C" void AxWin4_ShowWindow(tAxWin4_Window *Window)
 {
        CSerialiser     message;
+       message.WriteU8(IPCMSG_SETWINATTR);
        message.WriteU16(Window->m_id);
        message.WriteU16(IPC_WINATTR_SHOW);
        message.WriteU8(1);
        ::AxWin::SendMessage(message);
 }
 
+extern "C" void AxWin4_MoveWindow(tAxWin4_Window *Window, int X, int Y)
+{
+       CSerialiser     message;
+       message.WriteU8(IPCMSG_SETWINATTR);
+       message.WriteU16(Window->m_id);
+       message.WriteU16(IPC_WINATTR_POSITION);
+       message.WriteS16(X);
+       message.WriteS16(Y);
+       ::AxWin::SendMessage(message);
+}
+extern "C" void AxWin4_ResizeWindow(tAxWin4_Window *Window, unsigned int W, unsigned int H)
+{
+       CSerialiser     message;
+       message.WriteU8(IPCMSG_SETWINATTR);
+       message.WriteU16(Window->m_id);
+       message.WriteU16(IPC_WINATTR_POSITION);
+       message.WriteU16(W);
+       message.WriteU16(H);
+       ::AxWin::SendMessage(message);
+}
+
 extern "C" void AxWin4_SetTitle(tAxWin4_Window *Window, const char *Title)
 {
        CSerialiser     message;
+       message.WriteU8(IPCMSG_SETWINATTR);
        message.WriteU16(Window->m_id);
        message.WriteU16(IPC_WINATTR_TITLE);
        message.WriteString(Title);
        ::AxWin::SendMessage(message);
 }
 
+extern "C" void *AxWin4_GetWindowBuffer(tAxWin4_Window *Window)
+{
+       //if( !Window->m_buffer )
+       //{
+       //      // TODO: Support non-blocking operations        
+       //}
+       return NULL;
+}
+
 };     // namespace AxWin
 

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