From: John Hodge Date: Fri, 23 May 2014 00:13:19 +0000 (+0800) Subject: Usermode/axwin4 - Continuing X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f0ca31bc3f9c66a7fced9afcab9a6cacc8d1d647;p=tpg%2Facess2.git Usermode/axwin4 - Continuing --- diff --git a/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp b/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp new file mode 100644 index 00000000..16863496 --- /dev/null +++ b/Usermode/Applications/axwin4_src/Server/CIPCChannel_AcessIPCPipe.cpp @@ -0,0 +1,30 @@ +/* + * Acess2 GUI v4 + * - By John Hodge (thePowersGang) + * + * CIPCChannel_AcessIPCPipe.cpp + * - IPC Channel :: Acess' IPC Pipe /Devices/ipcpipe/ + */ +#include + +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) +{ +} + +}; + diff --git a/Usermode/Applications/axwin4_src/Server/Makefile b/Usermode/Applications/axwin4_src/Server/Makefile index 2b8089f2..2c7a74e9 100644 --- a/Usermode/Applications/axwin4_src/Server/Makefile +++ b/Usermode/Applications/axwin4_src/Server/Makefile @@ -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 diff --git a/Usermode/Applications/axwin4_src/Server/compositor.cpp b/Usermode/Applications/axwin4_src/Server/compositor.cpp index 9306e413..61d42e37 100644 --- a/Usermode/Applications/axwin4_src/Server/compositor.cpp +++ b/Usermode/Applications/axwin4_src/Server/compositor.cpp @@ -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 } diff --git a/Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp b/Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp index 0b051be2..48b17c68 100644 --- a/Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp +++ b/Usermode/Applications/axwin4_src/Server/include/CCompositor.hpp @@ -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); }; diff --git a/Usermode/Applications/axwin4_src/Server/include/CConfigIPC.hpp b/Usermode/Applications/axwin4_src/Server/include/CConfigIPC.hpp index 9e10dd9a..053e3761 100644 --- a/Usermode/Applications/axwin4_src/Server/include/CConfigIPC.hpp +++ b/Usermode/Applications/axwin4_src/Server/include/CConfigIPC.hpp @@ -8,8 +8,17 @@ #ifndef _CCONFIGIPC_H_ #define _CCONFIGIPC_H_ +#include + 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 index 00000000..1e24b0e7 --- /dev/null +++ b/Usermode/Applications/axwin4_src/Server/include/CIPCChannel_AcessIPCPipe.hpp @@ -0,0 +1,38 @@ +/* + * Acess2 GUI v4 + * - By John Hodge (thePowersGang) + * + * CIPCChannel_AcessIPCPipe.hpp + * - IPC Channel :: Acess' IPC Pipe /Devices/ipcpipe/ + */ +#ifndef _CIPCCHANNEL_ACESSIPCPIPE_HPP_ +#define _CIPCCHANNEL_ACESSIPCPIPE_HPP_ + +#include +#include +#include + +namespace AxWin { + +class CClient_AcessIPCPipe +{ +public: +}; + +class CIPCChannel_AcessIPCPipe: + public IIPCChannel +{ + int m_mainFD; + ::std::list 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 + diff --git a/Usermode/Applications/axwin4_src/Server/include/IIPCChannel.hpp b/Usermode/Applications/axwin4_src/Server/include/IIPCChannel.hpp index 5063c4a9..5dc88e2f 100644 --- a/Usermode/Applications/axwin4_src/Server/include/IIPCChannel.hpp +++ b/Usermode/Applications/axwin4_src/Server/include/IIPCChannel.hpp @@ -8,6 +8,10 @@ #ifndef _IIPCCHANNEL_H_ #define _IIPCCHANNEL_H_ +extern "C" { +#include +} + 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; }; diff --git a/Usermode/Applications/axwin4_src/Server/include/input.hpp b/Usermode/Applications/axwin4_src/Server/include/input.hpp index 6a430340..952e2e92 100644 --- a/Usermode/Applications/axwin4_src/Server/include/input.hpp +++ b/Usermode/Applications/axwin4_src/Server/include/input.hpp @@ -11,14 +11,21 @@ #include 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 diff --git a/Usermode/Applications/axwin4_src/Server/include/ipc.hpp b/Usermode/Applications/axwin4_src/Server/include/ipc.hpp index 439f3eac..c51c2019 100644 --- a/Usermode/Applications/axwin4_src/Server/include/ipc.hpp +++ b/Usermode/Applications/axwin4_src/Server/include/ipc.hpp @@ -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); diff --git a/Usermode/Applications/axwin4_src/Server/input.cpp b/Usermode/Applications/axwin4_src/Server/input.cpp index bea47775..7519b877 100644 --- a/Usermode/Applications/axwin4_src/Server/input.cpp +++ b/Usermode/Applications/axwin4_src/Server/input.cpp @@ -7,26 +7,38 @@ */ #include #include +#include +#include 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 diff --git a/Usermode/Applications/axwin4_src/Server/ipc.cpp b/Usermode/Applications/axwin4_src/Server/ipc.cpp index 0d92e6ac..2a633500 100644 --- a/Usermode/Applications/axwin4_src/Server/ipc.cpp +++ b/Usermode/Applications/axwin4_src/Server/ipc.cpp @@ -11,16 +11,24 @@ extern "C" { #include }; +#include namespace AxWin { namespace IPC { CCompositor* gpCompositor; -::std::list channels; +::std::list glChannels; +//::std::map 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 diff --git a/Usermode/Applications/axwin4_src/Server/main.cpp b/Usermode/Applications/axwin4_src/Server/main.cpp index 8f0d9e87..01178069 100644 --- a/Usermode/Applications/axwin4_src/Server/main.cpp +++ b/Usermode/Applications/axwin4_src/Server/main.cpp @@ -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();