--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CClient.cpp
+ * - IPC Client
+ */
+#include <CClient.hpp>
+
+namespace AxWin {
+
+CClient::CClient(IIPCChannel& channel):
+ m_channel(channel)
+{
+
+}
+
+CWindow* CClient::GetWindow(int ID)
+{
+ if( ID == 0 )
+ return 0;
+
+ return m_windows[ID];
+}
+
+void CClient::SetWindow(int ID, CWindow* window)
+{
+ if( m_windows[ID] ) {
+ delete m_windows[ID];
+ }
+ m_windows[ID] = window;
+}
+
+void CClient::SendMessage(CSerialiser& reply)
+{
+}
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CConfig.cpp
+ * - Configuration
+ */
+#include <CConfig.hpp>
+
+namespace AxWin {
+
+CConfig::CConfig()
+{
+}
+
+bool CConfig::parseCommandline(int argc, char *argv[])
+{
+ return false;
+}
+
+CConfigVideo::CConfigVideo()
+{
+}
+
+CConfigInput::CConfigInput()
+{
+}
+
+CConfigIPC::CConfigIPC()
+{
+}
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CRect.cpp
+ * - Rectangle
+ */
+#include <CRect.hpp>
+
+namespace AxWin {
+
+CRect::CRect(int x, int y, int w, int h)
+ //m_x(x), m_y(y), m_w(w), m_h(h)
+{
+}
+
+bool CRect::Contains(const CRect& other) const
+{
+ return false;
+}
+
+};
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CWindow.cpp
+ * - Window
+ */
+#include <CWindow.hpp>
+
+namespace AxWin {
+
+CWindow::CWindow(CClient& client, const ::std::string& name):
+ m_client(client),
+ m_name(name),
+ m_rect(0,0,0,0)
+{
+
+}
+
+CWindow::~CWindow()
+{
+}
+
+void CWindow::Repaint(const CRect& rect)
+{
+
+}
+
+};
+
+++ /dev/null
-/*
- *
- */
-#include <IWindow.hpp>
-
-namespace AxWin {
-
-
-IWindow::IWindow(const std::string &name):
- m_name(name)
-{
-}
-
-} // namespace AxWin
-
include ../../Makefile.cfg
CPPFLAGS += -Iinclude/
-OBJ := IWindow.o
+OBJ := main.o ipc.o CConfig.o video.o input.o timing.o
+OBJ += compositor.o CWindow.o
+OBJ += serialisation.o CClient.o
+OBJ += CRect.o
BIN := AxWinServer
+LDFLAGS += -lc++
+
include ../../Makefile.tpl
* compositor.cpp
* - Window compositor
*/
-#include <CVideo.hpp>
+#include <video.hpp>
+#include <compositor.hpp>
#include <CCompositor.hpp>
namespace AxWin {
-CCompositor* CCompositor::s_instance;
-
-void CCompositor::Initialise(const CConfigCompositor& config)
-{
- assert(!CCompositor::s_instance);
- CCompositor::s_instance = new CCompositor(config);
-}
-
-CCompositor::CCompositor(const CConfigCompositor& config):
- m_config(config)
+CCompositor::CCompositor()
{
//
}
-IWindow* CCompositor::CreateWindow(CClient& client)
+CWindow* CCompositor::CreateWindow(CClient& client)
{
- return new CWindow(client);
+ return new CWindow(client, "TODO");
}
void CCompositor::Redraw()
if( m_damageRects.empty() )
return ;
- // For all windows, check for intersection with damage rect
+ // Build up foreground grid (Rects and windows)
+ // - This should already be built (mutated on window move/resize/reorder)
+
+ // For all windows, check for intersection with damage rects
+ for( auto rect : m_damageRects )
+ {
+ for( auto window : m_windows )
+ {
+ if( rect.Contains( window->m_rect ) )
+ {
+ window->Repaint( rect );
+ }
+ }
+ }
+
+ m_damageRects.clear();
}
-void CCompositor::DamageArea(const Rect& area)
+void CCompositor::DamageArea(const CRect& area)
{
-
+ // 1. Locate intersection with any existing damaged areas
+ // 2. Append after removing intersections
}
} // namespace AxWin
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CClient.hpp
+ * - IPC Client
+ */
+#ifndef _CCLIENT_H_
+#define _CCLIENT_H_
+
+#include "CWindow.hpp"
+#include "serialisation.hpp"
+
+class IIPCChannel;
+
+namespace AxWin {
+
+class CClient
+{
+ IIPCChannel& m_channel;
+
+ //::std::map<unsigned int,CWindow*> m_windows;
+ CWindow* m_windows[1];
+public:
+ CClient(IIPCChannel& channel);
+ ~CClient();
+
+ CWindow* GetWindow(int ID);
+ void SetWindow(int ID, CWindow* window);
+
+ void SendMessage(CSerialiser& reply);
+};
+
+
+};
+
+#endif
+
#ifndef _CCOMPOSITOR_H_
#define _CCOMPOSITOR_H_
+#include <list>
+#include "CRect.hpp"
+#include "CWindow.hpp"
+namespace AxWin {
+
+class CClient;
+
+class CCompositor
+{
+ ::std::list<CRect> m_damageRects;
+ ::std::list<CWindow*> m_windows;
+
+public:
+ CCompositor();
+
+ CWindow* CreateWindow(CClient& client);
+
+ void Redraw();
+ void DamageArea(const CRect& rect);
+};
+
+
+};
#endif
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CConfigIPC.hpp
+ * - Configuration class
+ */
+#ifndef _CCONFIGIPC_H_
+#define _CCONFIGIPC_H_
+
+namespace AxWin {
+
+class CConfigIPC
+{
+public:
+ CConfigIPC();
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CConfig.hpp
+ * - Configuration class
+ */
+#ifndef _CCONFIGINPUT_H_
+#define _CCONFIGINPUT_H_
+
+namespace AxWin {
+
+class CConfigInput
+{
+public:
+ CConfigInput();
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CConfigVideo.hpp
+ * - Configuration class
+ */
+#ifndef _CCONFIGVIDEO_H_
+#define _CCONFIGVIDEO_H_
+
+namespace AxWin {
+
+class CConfigVideo
+{
+public:
+ CConfigVideo();
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ */
+#ifndef _CRECT_H_
+#define _CRECT_H_
+
+namespace AxWin {
+
+class CRect
+{
+public:
+ CRect(int X, int Y, int W, int H);
+
+ bool Contains(const CRect& other) const;
+};
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * CWindow.hpp
+ * - Window class
+ */
+#ifndef _CWINDOW_HPP_
+#define _CWINDOW_HPP_
+
+#include <string>
+#include <vector>
+#include <cstdint>
+#include "CRect.hpp"
+
+namespace AxWin {
+
+class CClient;
+
+class CWindow
+{
+ CClient& m_client;
+public:
+ CWindow(CClient& client, const ::std::string &name);
+ ~CWindow();
+
+ void Repaint(const CRect& rect);
+
+ void MouseButton(int ButtonID, int X, int Y, bool Down);
+ void MouseMove(int NewX, int NewY);
+ void KeyEvent(::uint32_t Scancode, const ::std::string &Translated, bool Down);
+
+ CRect m_rect;
+private:
+ const ::std::string m_name;
+};
+
+}; // namespace AxWin
+
+#endif
+
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * IIPCChannel.hpp
+ * - IPC Channel interface
+ */
+#ifndef _IIPCCHANNEL_H_
+#define _IIPCCHANNEL_H_
+
+namespace AxWin {
+
+class IIPCChannel
+{
+public:
+ virtual ~IIPCChannel();
+
+ virtual int FillSelect(::fd_set& rfds) = 0;
+ virtual void HandleSelect(::fd_set& rfds) = 0;
+};
+
+
+};
+
+#endif
+
#include <string>
#include <vector>
+#include <cstdint>
#include "CRect.hpp"
namespace AxWin {
class IWindow
{
public:
- virtual IWindow(const ::std::string &name);
+ IWindow(const ::std::string &name);
virtual ~IWindow();
virtual void Repaint() = 0;
virtual void MouseButton(int ButtonID, int X, int Y, bool Down);
virtual void MouseMove(int NewX, int NewY);
- virtual void KeyEvent(uint32_t Scancode, const ::std::string &Translated, bool Down);
+ virtual void KeyEvent(::uint32_t Scancode, const ::std::string &Translated, bool Down);
protected:
const ::std::string m_name;
};
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * compositor.hpp
+ * - Compositor Interface Header
+ */
+#ifndef _COMPOSITOR_H_
+#define _COMPOSITOR_H_
+
+namespace AxWin {
+
+class CCompositor;
+
+namespace Compositor {
+
+}; // namespace Compositor
+
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * input.hpp
+ * - Input Interface Header
+ */
+#ifndef _INPUT_H_
+#define _INPUT_H_
+
+#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);
+
+};
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * ipc.hpp
+ * - IPC Interface Header
+ */
+#ifndef _IPC_H_
+#define _IPC_H_
+
+extern "C" {
+#include <acess/sys.h>
+};
+
+#include <CConfigIPC.hpp>
+
+namespace AxWin {
+class CCompositor;
+
+namespace IPC {
+
+extern void Initialise(const CConfigIPC& config, CCompositor* compositor);
+extern int FillSelect(::fd_set& rfds);
+extern void HandleSelect(::fd_set& rfds);
+
+}; // namespace IPC
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * ipc_proto.hpp
+ * - IPC Protocol Header
+ */
+#ifndef _IPC_PROTO_H_
+#define _IPC_PROTO_H_
+
+namespace AxWin {
+
+enum
+{
+ IPCMSG_PING,
+ IPCMSG_REPLY,
+ IPCMSG_CREATEWIN,
+ IPCMSG_CLOSEWIN,
+ IPCMSG_SETWINATTR,
+ IPCMSG_GETWINATTR,
+
+ IPCMSG_RGNADD,
+ IPCMSG_RGNDEL,
+ IPCMSG_RGNSETATTR,
+ IPCMSG_RGNPUSHDATA,
+
+ IPCMSG_SENDIPC,
+};
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * serialisation.hpp
+ * - Generic (de)serialisation code
+ */
+#ifndef _SERIALISATION_H_
+#define _SERIALISATION_H_
+
+#include <cstdint>
+#include <cstddef>
+#include <exception>
+
+namespace AxWin {
+
+class CDeserialiseException:
+ public ::std::exception
+{
+};
+
+class CDeserialiser
+{
+public:
+ CDeserialiser(size_t Length, const void *Buffer);
+ ::uint8_t ReadU8();
+ ::uint16_t ReadU16();
+};
+
+class CSerialiser
+{
+public:
+ CSerialiser();
+ void WriteU8(::uint8_t val);
+ void WriteU16(::uint16_t val);
+};
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * timing.hpp
+ * - Timing Interface Header
+ */
+#ifndef _TIMING_H_
+#define _TIMING_H_
+
+#include <cstdint>
+
+namespace AxWin {
+namespace Timing {
+
+extern ::int64_t GetTimeToNextEvent();
+extern void CheckEvents();
+
+}; // namespace Timing
+}; // namespace AxWin
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * video.hpp
+ * - Graphics Interface Header
+ */
+#ifndef _VIDEO_H_
+#define _VIDEO_H_
+
+#include "CConfigVideo.hpp"
+
+namespace AxWin {
+namespace Graphics {
+
+extern void Initialise(const CConfigVideo& config);
+
+};
+
+};
+
+#endif
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * input.cpp
+ * - Input
+ */
+#include <CConfigInput.hpp>
+#include <input.hpp>
+
+namespace AxWin {
+
+namespace Input {
+
+void Initialise(const ::AxWin::CConfigInput& config)
+{
+
+}
+
+int FillSelect(::fd_set& rfds)
+{
+ return 0;
+}
+
+void HandleSelect(::fd_set& rfds)
+{
+}
+
+};
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ */
+#include <ipc.hpp>
+#include <list>
+#include <IIPCChannel.hpp>
+#include <algorithm>
+#include <CClient.hpp>
+#include <serialisation.hpp>
+#include <ipc_proto.hpp>
+#include <CCompositor.hpp>
+extern "C" {
+#include <assert.h>
+};
+
+namespace AxWin {
+namespace IPC {
+
+CCompositor* gpCompositor;
+::std::list<IIPCChannel*> channels;
+
+void Initialise(const CConfigIPC& config, CCompositor* compositor)
+{
+ gpCompositor = compositor;
+ //for( auto channel : config.m_channels )
+ //{
+ // channels.push_back( );
+ //}
+}
+
+int FillSelect(fd_set& rfds)
+{
+ int ret = 0;
+ for( auto channel : channels )
+ {
+ ret = ::std::max(ret, channel->FillSelect(rfds));
+ }
+ return ret;
+}
+
+void HandleSelect(fd_set& rfds)
+{
+
+}
+
+void RegisterClient(IIPCChannel& channel, 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)
+{
+ 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
+ // - Not many messages need server-bound replies
+ int orig_command = message.ReadU8();
+ switch(orig_command)
+ {
+ case IPCMSG_PING:
+ // Ping reply, mark client as still responding
+ break;
+ default:
+ // Unexpected reply
+ break;
+ }
+}
+
+void HandleMessage_Ping(CClient& client, CDeserialiser& message)
+{
+ // A client has asked for a ping, we pong them back
+ CSerialiser reply;
+ reply.WriteU8(IPCMSG_REPLY);
+ reply.WriteU8(IPCMSG_PING);
+ client.SendMessage(reply);
+}
+
+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 );
+
+ client.SetWindow( new_id, gpCompositor->CreateWindow(client) );
+}
+
+void HandleMessage_CloseWindow(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_SetWindowAttr(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_GetWindowAttr(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_AddRegion(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_DelRegion(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_SetRegionAttr(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_PushData(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+void HandleMessage_SendIPC(CClient& client, CDeserialiser& message)
+{
+ assert(!"TODO");
+}
+
+};
+}; // namespace AxWin
+
#include <ipc.hpp>
#include <input.hpp>
#include <video.hpp>
+#include <CCompositor.hpp>
#include <timing.hpp>
+#include <exception>
+#include <algorithm>
+
+extern "C" {
+#include <stdio.h>
+#include <stdint.h>
+};
using namespace AxWin;
}
// - Open graphics
Graphics::Initialise(config.m_video);
+ // - Initialise compositor structures
+ CCompositor* compositor = new CCompositor(/*config.m_compositor*/);
// - Open input
Input::Initialise(config.m_input);
// > Handles hotkeys?
- // - Initialise compositor structures
- Compositor::Initialise(config.m_compositor);
// - Bind IPC channels
- IPC::Initialise(config.m_ipc);
+ IPC::Initialise(config.m_ipc, compositor);
// - Start root child process (from config)
// TODO: Spin up child process
int nfd = 0;
fd_set rfds;
- Input::FillSelect(&nfd, &rfds);
- IPC::FillSelect(&nfd, &rfds);
+ nfd = ::std::max(nfd, Input::FillSelect(rfds));
+ nfd = ::std::max(nfd, IPC::FillSelect(rfds));
- // TODO: Timer events
+ // TODO: Support _SysSendMessage IPC?
int64_t timeout = Timing::GetTimeToNextEvent();
- int rv = ::_SysSelect(nfd, &rfds, NULL, &rfds, NULL, 0);
+ int rv = ::_SysSelect(nfd, &rfds, NULL, &rfds, &timeout, 0);
Timing::CheckEvents();
- Input::HandleSelect(&rfds);
- IPC::HandleSelect(&rfds);
+ Input::HandleSelect(rfds);
+ IPC::HandleSelect(rfds);
- Compositor::Redraw();
+ compositor->Redraw();
}
return 0;
}
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * serialisation.cpp
+ * - IPC Serialisation
+ */
+#include <serialisation.hpp>
+#include <cstddef>
+
+namespace AxWin {
+
+CDeserialiser::CDeserialiser(size_t Length, const void *Buffer)
+{
+}
+
+::uint8_t CDeserialiser::ReadU8()
+{
+ return 0;
+}
+
+::uint16_t CDeserialiser::ReadU16()
+{
+ return 0;
+}
+
+CSerialiser::CSerialiser()
+{
+}
+
+void CSerialiser::WriteU8(::uint8_t Value)
+{
+}
+
+}; // namespace AxWin
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * timing.cpp
+ * - Timing code
+ */
+#include <timing.hpp>
+
+namespace AxWin {
+namespace Timing {
+
+int64_t GetTimeToNextEvent()
+{
+ return 10*1000;
+}
+
+void CheckEvents()
+{
+
+}
+
+}; // namespace Timing
+}; // namespace AxWin
+
--- /dev/null
+/*
+ * Acess2 GUI v4
+ * - By John Hodge (thePowersGang)
+ *
+ * video.cpp
+ * - Graphics output
+ */
+#include <video.hpp>
+
+namespace AxWin {
+
+namespace Graphics {
+
+void Initialise(const CConfigVideo& config)
+{
+}
+
+};
+
+}; // namespace AxWin
+