Usermode/AxWin4 - Server implemenation moving along
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / main.cpp
index 3953e07..acea927 100644 (file)
@@ -1,8 +1,24 @@
 /*
+ * Acess2 GUI v4 (AxWin4)
+ * - By John Hodge (thePowesGang)
+ * 
+ * main.cpp
+ * - Program main
  */
+#include <CConfig.hpp>
 #include <ipc.hpp>
 #include <input.hpp>
+#include <video.hpp>
+#include <CCompositor.hpp>
 #include <timing.hpp>
+#include <exception>
+#include <algorithm>
+#include <common.hpp>
+
+extern "C" {
+#include <stdio.h>
+#include <stdint.h>
+};
 
 using namespace AxWin;
 
@@ -10,13 +26,25 @@ using namespace AxWin;
 int main(int argc, char *argv[])
 {
        // - Load configuration (from file and argv)
+       CConfig config;
+       try {
+               config.parseCommandline(argc, argv);
+       }
+       catch(const std::exception& e) {
+               fprintf(stderr, "Exception: %s\n", e.what());
+               return 1;
+       }
        // - Open graphics
-       Graphics::Open(/*config.m_displayDevice*/);
-       // - Open input
+       CVideo* vid = new CVideo(config.m_video);
        // - Initialise compositor structures
-       // - Prepare global hotkeys
+       CCompositor* compositor = new CCompositor(/*config.m_compositor,*/ *vid);
+       // - Open input
+       CInput* input = new CInput(config.m_input, *compositor);
+       //  > Handles hotkeys?
        // - Bind IPC channels
+       IPC::Initialise(config.m_ipc, *compositor);
        // - Start root child process (from config)
+       // TODO: Spin up child process
        
        // - Event loop
        for( ;; )
@@ -24,18 +52,30 @@ int main(int argc, char *argv[])
                 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();
        }
        return 0;
 }
 
+namespace AxWin {
+
+const char* InitFailure::what() const throw()
+{
+       return m_what;
+}
+
+
+}
+

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