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
$(_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)
+
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);
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;
}
}
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);
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());
}
--- /dev/null
+/*
+ * 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
+
// 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