Usermode/AxWin4 - Server implemenation moving along
authorJohn Hodge <[email protected]>
Sat, 24 May 2014 09:19:54 +0000 (17:19 +0800)
committerJohn Hodge <[email protected]>
Sat, 24 May 2014 09:19:54 +0000 (17:19 +0800)
13 files changed:
Usermode/Applications/Makefile.cfg
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/CWindow.hpp
Usermode/Applications/axwin4_src/Server/include/ipc.hpp
Usermode/Applications/axwin4_src/Server/include/ipc_proto.hpp
Usermode/Applications/axwin4_src/Server/include/serialisation.hpp
Usermode/Applications/axwin4_src/Server/include/video.hpp
Usermode/Applications/axwin4_src/Server/ipc.cpp
Usermode/Applications/axwin4_src/Server/main.cpp
Usermode/Applications/axwin4_src/Server/serialisation.cpp
Usermode/Applications/axwin4_src/Server/video.cpp

index 583ae58..e170329 100644 (file)
@@ -5,8 +5,6 @@
 _appsdir := $(dir $(lastword $(MAKEFILE_LIST)))
 include $(_appsdir)../Makefile.cfg
 
-CXXFLAGS += -std=gnu++11
-
 ifeq ($(ARCHDIR),native)
  ASFLAGS = -felf
  CPPFLAGS = -Wall
@@ -23,6 +21,7 @@ endif
 
 -include $(_appsdir)../common_settings.mk
 LDFLAGS += -rpath-link $(OUTPUTDIR)Libs
+CXXFLAGS += -std=gnu++11
 
 # Extra-verbose errors!
 #CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op  -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings
index 4d1416e..bd952aa 100644 (file)
@@ -6,13 +6,16 @@
  * - Window
  */
 #include <CWindow.hpp>
+#include <CCompositor.hpp>
+#include <assert.h>
 
 namespace AxWin {
 
-CWindow::CWindow(CClient& client, const ::std::string& name):
+CWindow::CWindow(CCompositor& compositor, CClient& client, const ::std::string& name):
+       m_surface(0,0,0,0),
+       m_compositor(compositor),
        m_client(client),
-       m_name(name),
-       m_surface(0,0,0,0)
+       m_name(name)
 {
        
 }
@@ -29,11 +32,42 @@ void CWindow::Repaint(const CRect& rect)
                if( rect.Contains(rgn->m_rect) )
                {
                        CRect   rel_rect(rect, rgn->m_rect);
-                       rgn->Repaint();
+                       rgn->Repaint(m_surface, rel_rect);
                } 
        }
        #endif
 }
 
+void CWindow::Show(bool bShow)
+{
+       assert(!"TODO: CWindow::Show");
+}
+
+void CWindow::Move(int X, int Y)
+{
+       assert(!"TODO: CWindow::Move");
+}
+void CWindow::Resize(unsigned int W, unsigned int H)
+{
+       assert(!"TODO: CWindow::Resize");
+}
+uint64_t CWindow::ShareSurface()
+{
+       assert(!"TODO: CWindow::ShareSurface");
+       return 0;
+}
+
+void CWindow::MouseButton(int ButtonID, int X, int Y, bool Down)
+{
+}
+
+void CWindow::MouseMove(int NewX, int NewY)
+{
+}
+
+void CWindow::KeyEvent(::uint32_t Scancode, const ::std::string &Translated, bool Down)
+{
+}
+
 };
 
index 61d42e3..4052145 100644 (file)
@@ -6,8 +6,8 @@
  * - Window compositor
  */
 #include <video.hpp>
-#include <compositor.hpp>
 #include <CCompositor.hpp>
+#include <cassert>
 
 namespace AxWin {
 
@@ -17,9 +17,25 @@ CCompositor::CCompositor(CVideo& video):
        // 
 }
 
-CWindow* CCompositor::CreateWindow(CClient& client)
+CWindow* CCompositor::CreateWindow(CClient& client, const ::std::string& name)
 {
-       return new CWindow(client, "TODO");
+       return new CWindow(*this, client, name);
+}
+
+bool CCompositor::GetScreenDims(unsigned int ScreenID, unsigned int* W, unsigned int* H)
+{
+       assert(W && H);
+       if( ScreenID != 0 )
+       {
+               *W = 0;
+               *H = 0;
+               return false;
+       }
+       else
+       {
+               m_video.GetDims(*W, *H);
+               return true;
+       }
 }
 
 void CCompositor::Redraw()
@@ -50,6 +66,7 @@ void CCompositor::Redraw()
        }
 
        m_damageRects.clear();
+       m_video.Flush();
 }
 
 void CCompositor::DamageArea(const CRect& area)
index 48b17c6..51f04c9 100644 (file)
@@ -8,6 +8,7 @@
 #ifndef _CCOMPOSITOR_H_
 #define _CCOMPOSITOR_H_
 
+#include <string>
 #include <list>
 #include <vector>
 #include "CRect.hpp"
@@ -45,7 +46,9 @@ class CCompositor
 public:
        CCompositor(CVideo& video);
 
-       CWindow* CreateWindow(CClient& client);
+       CWindow* CreateWindow(CClient& client, const ::std::string& name);
+
+       bool    GetScreenDims(unsigned int ScrenID, unsigned int *Width, unsigned int *Height);
 
        void    Redraw();
        void    DamageArea(const CRect& rect);
index 00bc7e8..2248853 100644 (file)
 namespace AxWin {
 
 class CClient;
+class CCompositor;
+class CRegion;
 
 class CWindow
 {
 public:
-       CWindow(CClient& client, const ::std::string &name);
+       CWindow(CCompositor& compositor, CClient& client, const ::std::string &name);
        ~CWindow();
        
        void Repaint(const CRect& rect);
+
+       void Show(bool bShow);  
+       void Move(int X, int Y);
+       void Resize(unsigned int W, unsigned int H);
+       
+       uint64_t ShareSurface();
        
        void MouseButton(int ButtonID, int X, int Y, bool Down);
        void MouseMove(int NewX, int NewY);
@@ -32,9 +40,10 @@ public:
 
        CSurface        m_surface;
 private:
-       const ::std::string     m_name;
+       CCompositor&    m_compositor;
        CClient&        m_client;
-       //::std::list<CRegion*> m_regions;
+       const ::std::string     m_name;
+       ::std::vector<CRegion*> m_regions;
 };
 
 };     // namespace AxWin
index c51c201..d801953 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef _IPC_H_
 #define _IPC_H_
 
+#include <exception>
+
 extern "C" {
 #include <acess/sys.h>
 };
@@ -23,6 +25,16 @@ extern void  Initialise(const CConfigIPC& config, CCompositor& compositor);
 extern int     FillSelect(::fd_set& rfds);
 extern void    HandleSelect(::fd_set& rfds);
 
+class CClientFailure:
+       public ::std::exception
+{
+       const std::string m_what;
+public:
+       CClientFailure(std::string&& what);
+       ~CClientFailure() throw();
+       const char *what() const throw();
+};
+
 };     // namespace IPC
 };     // namespace AxWin
 
index f78bfbb..a346424 100644 (file)
@@ -12,19 +12,40 @@ namespace AxWin {
 
 enum
 {
-       IPCMSG_PING,
+       IPCMSG_NULL,
        IPCMSG_REPLY,
+       IPCMSG_PING,
+       IPCMSG_GETGLOBAL,
+       IPCMSG_SETGLOBAL,
+
        IPCMSG_CREATEWIN,
        IPCMSG_CLOSEWIN,
        IPCMSG_SETWINATTR,
        IPCMSG_GETWINATTR,
-       
-       IPCMSG_RGNADD,
-       IPCMSG_RGNDEL,
-       IPCMSG_RGNSETATTR,
-       IPCMSG_RGNPUSHDATA,
-       
        IPCMSG_SENDIPC,
+       IPCMSG_GETWINBUF,       // get a handle to the window's buffer
+       
+       // - Window drawing commands
+       //IPCMSG_DRAWGROUP,     // (u16 win, u16 group_id) - (hint) Switch to this group
+       //IPCMSG_CLEAR, // (u16 win) - (hint) Clear current drawing group
+       IPCMSG_PUSHDATA,        // (u16 win, u16 x, u16 y, u16 w, u16 h, void data)
+       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
+};
+
+enum eIPC_GlobalAttrs
+{
+       IPC_GLOBATTR_SCREENDIMS,        // Screen dimensions - Readonly
+       IPC_GLOBATTR_MAXAREA,   // Maximum window area for screen (hint, not enforced)
+};
+
+enum eIPC_WinAttrs
+{
+       IPC_WINATTR_SHOW,
+       IPC_WINATTR_FLAGS,      // Decoration enabled, always-on-top
+       IPC_WINATTR_POSITION,
+       IPC_WINATTR_DIMENSIONS,
 };
 
 };
index f0cc600..ca397b4 100644 (file)
@@ -11,6 +11,7 @@
 #include <cstdint>
 #include <cstddef>
 #include <exception>
+#include <string>
 
 namespace AxWin {
 
@@ -25,6 +26,8 @@ public:
        CDeserialiser(size_t Length, const void *Buffer);
        ::uint8_t       ReadU8();
        ::uint16_t      ReadU16();
+       ::int16_t       ReadS16();
+       ::std::string   ReadString();
 };
 
 class CSerialiser
index baa75d2..539410b 100644 (file)
@@ -18,10 +18,19 @@ class CVideo
         int    m_fd;
        unsigned int    m_width;
        unsigned int    m_height;
+        int    m_bufferFormat;
 public:
        CVideo(const CConfigVideo& config);
-       
+
+       void GetDims(unsigned int& w, unsigned int& h); 
+
        void BlitLine(const uint32_t* src, unsigned int dst_y, unsigned int dst_x, unsigned int width);
+       void Flush();
+
+private:
+       void SetBufFormat(unsigned int FormatID);
+       void SetCursorBitmap();
+       void SetCursorPos(int X, int Y);
 };
 
 };
index 2a63350..f842578 100644 (file)
@@ -1,5 +1,6 @@
 /*
  */
+#define __STDC_LIMIT_MACROS
 #include <ipc.hpp>
 #include <list>
 #include <IIPCChannel.hpp>
@@ -67,46 +68,9 @@ void DeregisterClient(CClient& client)
 
 
 
-typedef void   MessageHandler_op_t(CClient& client, CDeserialiser& message);
-MessageHandler_op_t    HandleMessage_Ping;
-MessageHandler_op_t    HandleMessage_GetWindowAttr;
-MessageHandler_op_t    HandleMessage_Reply;
-MessageHandler_op_t    HandleMessage_CreateWindow;
-MessageHandler_op_t    HandleMessage_CloseWindow;
-MessageHandler_op_t    HandleMessage_SetWindowAttr;
-MessageHandler_op_t    HandleMessage_AddRegion;
-MessageHandler_op_t    HandleMessage_DelRegion;
-MessageHandler_op_t    HandleMessage_SetRegionAttr;
-MessageHandler_op_t    HandleMessage_PushData;
-MessageHandler_op_t    HandleMessage_SendIPC;
-
-MessageHandler_op_t    *message_handlers[] = {
-       [IPCMSG_PING]       = &HandleMessage_Ping,
-       [IPCMSG_REPLY]      = &HandleMessage_Reply,
-       
-       [IPCMSG_CREATEWIN]  = &HandleMessage_CreateWindow,
-       [IPCMSG_CLOSEWIN]   = &HandleMessage_CloseWindow,
-       [IPCMSG_SETWINATTR] = &HandleMessage_SetWindowAttr,
-       [IPCMSG_GETWINATTR] = &HandleMessage_GetWindowAttr,
-       
-       [IPCMSG_RGNADD]     = &HandleMessage_AddRegion,
-       [IPCMSG_RGNDEL]     = &HandleMessage_DelRegion,
-       [IPCMSG_RGNSETATTR] = &HandleMessage_SetRegionAttr,
-       [IPCMSG_RGNPUSHDATA]= &HandleMessage_PushData,  // to a region
-       [IPCMSG_SENDIPC]    = &HandleMessage_SendIPC,   // Use the GUI server for low-bandwith inter-process messaging
-};
-
-void HandleMessage(CClient& client, CDeserialiser& message)
+void HandleMessage_Nop(CClient& client, CDeserialiser& message)
 {
-       unsigned int command = message.ReadU8();
-       if( command >= sizeof(message_handlers)/sizeof(IPC::MessageHandler_op_t*) ) {
-               // Drop, invalid command
-               return ;
-       }
-       
-       (message_handlers[command])(client, message);
 }
-
 void HandleMessage_Reply(CClient& client, CDeserialiser& message)
 {
        // Reply to a sent message
@@ -132,23 +96,100 @@ void HandleMessage_Ping(CClient& client, CDeserialiser& message)
        client.SendMessage(reply);
 }
 
+void HandleMessage_GetGlobalAttr(CClient& client, CDeserialiser& message)
+{
+       uint16_t        attr_id = message.ReadU16();
+       
+       CSerialiser     reply;
+       reply.WriteU8(IPCMSG_REPLY);
+       reply.WriteU8(IPCMSG_GETGLOBAL);
+       reply.WriteU16(attr_id);
+       
+       switch(attr_id)
+       {
+       case IPC_GLOBATTR_SCREENDIMS: {
+               uint8_t screen_id = message.ReadU8();
+               unsigned int w, h;
+               gpCompositor->GetScreenDims(screen_id, &w, &h);
+               reply.WriteU16( (w <= UINT16_MAX ? w : UINT16_MAX) );
+               reply.WriteU16( (h <= UINT16_MAX ? h : UINT16_MAX) );
+               break; }
+       default:
+               throw IPC::CClientFailure("Bad global attribute ID");
+       }
+       
+       client.SendMessage(reply);
+}
+
+void HandleMessage_SetGlobalAttr(CClient& client, CDeserialiser& message)
+{
+       uint16_t        attr_id = message.ReadU16();
+       
+       switch(attr_id)
+       {
+       case IPC_GLOBATTR_SCREENDIMS:
+               // Setting readonly
+               break;
+       case IPC_GLOBATTR_MAXAREA:
+               assert(!"TODO: IPC_GLOBATTR_MAXAREA");
+               break;
+       default:
+               throw IPC::CClientFailure("Bad global attribute ID");
+       }
+}
+
 void HandleMessage_CreateWindow(CClient& client, CDeserialiser& message)
 {
-       uint16_t        parent_id = message.ReadU16();
        uint16_t        new_id = message.ReadU16();
-       CWindow* parent = client.GetWindow( parent_id );
+       //uint16_t      parent_id = message.ReadU16();
+       //CWindow* parent = client.GetWindow( parent_id );
+       ::std::string   name = message.ReadString();
        
-       client.SetWindow( new_id, gpCompositor->CreateWindow(client) );
+       client.SetWindow( new_id, gpCompositor->CreateWindow(client, name) );
 }
 
-void HandleMessage_CloseWindow(CClient& client, CDeserialiser& message)
+void HandleMessage_DestroyWindow(CClient& client, CDeserialiser& message)
 {
-       assert(!"TODO");
+       uint16_t        win_id = message.ReadU16();
+       
+       CWindow*        win = client.GetWindow(win_id);
+       if(!win) {
+               throw IPC::CClientFailure("Bad window");
+       }
+       client.SetWindow(win_id, 0);    
+       
+       // TODO: Directly inform compositor?
+       delete win;
 }
 
 void HandleMessage_SetWindowAttr(CClient& client, CDeserialiser& message)
 {
-       assert(!"TODO");
+       uint16_t        win_id = message.ReadU16();
+       uint16_t        attr_id = message.ReadU16();
+
+       CWindow*        win = client.GetWindow(win_id);
+       if(!win) {
+               throw IPC::CClientFailure("Bad window");
+       }
+       
+       switch(attr_id)
+       {
+       case IPC_WINATTR_DIMENSIONS: {
+               uint16_t new_w = message.ReadU16();
+               uint16_t new_h = message.ReadU16();
+               win->Resize(new_w, new_h);
+               assert(!"TODO: IPC_WINATTR_DIMENSIONS");
+               break; }
+       case IPC_WINATTR_POSITION: {
+               int16_t new_x = message.ReadS16();
+               int16_t new_y = message.ReadS16();
+               win->Move(new_x, new_y);
+               assert(!"TODO: IPC_WINATTR_POSITION");
+               break; }
+       default:
+               _SysDebug("HandleMessage_SetWindowAttr - Bad attr %u", attr_id);
+               throw IPC::CClientFailure("Bad window attr");
+       }
 }
 
 void HandleMessage_GetWindowAttr(CClient& client, CDeserialiser& message)
@@ -156,31 +197,77 @@ void HandleMessage_GetWindowAttr(CClient& client, CDeserialiser& message)
        assert(!"TODO");
 }
 
-void HandleMessage_AddRegion(CClient& client, CDeserialiser& message)
+void HandleMessage_SendIPC(CClient& client, CDeserialiser& message)
 {
        assert(!"TODO");
 }
 
-void HandleMessage_DelRegion(CClient& client, CDeserialiser& message)
+void HandleMessage_GetWindowBuffer(CClient& client, CDeserialiser& message)
 {
        assert(!"TODO");
 }
 
-void HandleMessage_SetRegionAttr(CClient& client, CDeserialiser& message)
+void HandleMessage_PushData(CClient& client, CDeserialiser& message)
 {
        assert(!"TODO");
 }
-
-void HandleMessage_PushData(CClient& client, CDeserialiser& message)
+void HandleMessage_Blit(CClient& client, CDeserialiser& message)
 {
        assert(!"TODO");
 }
-
-void HandleMessage_SendIPC(CClient& client, CDeserialiser& message)
+void HandleMessage_DrawCtl(CClient& client, CDeserialiser& message)
+{
+       assert(!"TODO");
+}
+void HandleMessage_DrawText(CClient& client, CDeserialiser& message)
 {
        assert(!"TODO");
 }
 
+typedef void   MessageHandler_op_t(CClient& client, CDeserialiser& message);
+
+MessageHandler_op_t    *message_handlers[] = {
+       [IPCMSG_NULL]       = &HandleMessage_Nop,
+       [IPCMSG_REPLY]      = &HandleMessage_Reply,
+       [IPCMSG_PING]       = &HandleMessage_Ping,
+       [IPCMSG_GETGLOBAL]  = &HandleMessage_GetGlobalAttr,
+       [IPCMSG_SETGLOBAL]  = &HandleMessage_SetGlobalAttr,
+       
+       [IPCMSG_CREATEWIN]  = &HandleMessage_CreateWindow,
+       [IPCMSG_CLOSEWIN]   = &HandleMessage_DestroyWindow,
+       [IPCMSG_SETWINATTR] = &HandleMessage_SetWindowAttr,
+       [IPCMSG_GETWINATTR] = &HandleMessage_GetWindowAttr,
+       [IPCMSG_SENDIPC]    = &HandleMessage_SendIPC,   // Use the GUI server for low-bandwith IPC
+       [IPCMSG_GETWINBUF]  = &HandleMessage_GetWindowBuffer,
+       [IPCMSG_PUSHDATA]   = &HandleMessage_PushData,  // to a window's buffer
+       [IPCMSG_BLIT]       = &HandleMessage_Blit,      // Copy data from one part of the window to another
+       [IPCMSG_DRAWCTL]    = &HandleMessage_DrawCtl,   // Draw a control
+       [IPCMSG_DRAWTEXT]   = &HandleMessage_DrawText,  // Draw text
+};
+
+void HandleMessage(CClient& client, CDeserialiser& message)
+{
+       unsigned int command = message.ReadU8();
+       if( command >= sizeof(message_handlers)/sizeof(IPC::MessageHandler_op_t*) ) {
+               // Drop, invalid command
+               return ;
+       }
+       
+       (message_handlers[command])(client, message);
+}
+
+CClientFailure::CClientFailure(std::string&& what):
+       m_what(what)
+{
+}
+const char *CClientFailure::what() const throw()
+{
+       return m_what.c_str();
+}
+CClientFailure::~CClientFailure() throw()
+{
+}
+
 };     // namespace IPC
 
 IIPCChannel::~IIPCChannel()
index 0117806..acea927 100644 (file)
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
        IPC::Initialise(config.m_ipc, *compositor);
        // - Start root child process (from config)
        // TODO: Spin up child process
-
+       
        // - Event loop
        for( ;; )
        {
index c4338cb..7d60587 100644 (file)
@@ -24,6 +24,16 @@ CDeserialiser::CDeserialiser(size_t Length, const void *Buffer)
        return 0;
 }
 
+::int16_t CDeserialiser::ReadS16()
+{
+       return 0;
+}
+
+::std::string CDeserialiser::ReadString()
+{
+       return "";
+}
+
 CSerialiser::CSerialiser()
 {
 }
@@ -32,5 +42,9 @@ void CSerialiser::WriteU8(::uint8_t Value)
 {
 }
 
+void CSerialiser::WriteU16(::uint16_t Value)
+{
+}
+
 };     // namespace AxWin
 
index 6fde7aa..14fb76d 100644 (file)
 extern "C" {
 #include <acess/sys.h>
 #include <acess/devices/pty.h>
+#include <acess/devices/pty_cmds.h>
+#include "resources/cursor.h"
 }
 
 namespace AxWin {
 
 CVideo::CVideo(const CConfigVideo& config):
-       m_fd(0)
+       m_fd(1),
+       m_width(0),
+       m_height(0),
+       m_bufferFormat(PTYBUFFMT_TEXT)
 {
+       // Obtain dimensions
        {
                if( _SysIOCtl(m_fd, DRV_IOCTL_TYPE, NULL) != DRV_TYPE_TERMINAL )
                        throw AxWin::InitFailure("stdin isn't a terminal");
@@ -30,14 +36,74 @@ CVideo::CVideo(const CConfigVideo& config):
                if( m_width == 0 || m_height == 0 )
                        throw AxWin::InitFailure("Terminal not capable of graphics");
        }
+       
+       SetCursorBitmap();
+       
+       SetCursorPos( m_width/2, m_height/2 );
+       
+       SetBufFormat(PTYBUFFMT_FB);
+}
+
+void CVideo::GetDims(unsigned int& w, unsigned int& h)
+{
+       w = m_width;
+       h = m_height;
 }
 
 void CVideo::BlitLine(const uint32_t* src, unsigned int dst_y, unsigned int dst_x, unsigned int width)
 {
        //_SysWriteAt(m_fd, (dst_y * m_width + dst_x) * 4, width * 4, src);
+       SetBufFormat(PTYBUFFMT_FB);
        _SysSeek(m_fd, (dst_y * m_width + dst_x) * 4, SEEK_SET);
        _SysWrite(m_fd, src, width * 4);
 }
 
+void CVideo::Flush()
+{
+       // TODO: Write to a local copy of the framebuffer in BlitLine, and then flush out in this function
+}
+
+void CVideo::SetBufFormat(unsigned int FormatID)
+{
+       if( m_bufferFormat != FormatID )
+       {
+               
+               struct ptymode mode = {.OutputMode = FormatID, .InputMode = 0};
+               int rv = _SysIOCtl( m_fd, PTY_IOCTL_SETMODE, &mode );
+               if( rv ) {
+                       throw ::AxWin::InitFailure("Can't set PTY to framebuffer mode");
+               }
+               
+               m_bufferFormat = FormatID;
+       }
+}
+
+void CVideo::SetCursorBitmap()
+{
+       // Set cursor position and bitmap
+       struct ptycmd_header    hdr = {PTY2D_CMD_SETCURSORBMP,0,0};
+       size_t size = sizeof(hdr) + sizeof(cCursorBitmap) + cCursorBitmap.W*cCursorBitmap.H*4;
+       hdr.len_low = size / 4;
+       hdr.len_hi = size / (256*4);
+       
+       SetBufFormat(PTYBUFFMT_2DCMD);
+       _SysWrite(m_fd, &hdr, sizeof(hdr));
+       _SysDebug("size = %i (%04x:%02x * 4)", size, hdr.len_hi, hdr.len_low);
+       _SysWrite(m_fd, &cCursorBitmap, size-sizeof(hdr));
+}
+
+void CVideo::SetCursorPos(int X, int Y)
+{
+       struct ptycmd_setcursorpos      cmd;
+       cmd.hdr.cmd = PTY2D_CMD_SETCURSORPOS;
+       cmd.hdr.len_low = sizeof(cmd)/4;
+       cmd.hdr.len_hi = 0;
+       cmd.x = X;
+       cmd.y = Y;
+
+       SetBufFormat(PTYBUFFMT_2DCMD);  
+       _SysWrite(m_fd, &cmd, sizeof(cmd));
+}
+
 };     // namespace AxWin
 

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