Usermode/AxWin4 - Code now compiling (if STL is present)
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / main.cpp
1 /*
2  */
3 #include <CConfig.hpp>
4 #include <ipc.hpp>
5 #include <input.hpp>
6 #include <video.hpp>
7 #include <CCompositor.hpp>
8 #include <timing.hpp>
9 #include <exception>
10 #include <algorithm>
11
12 extern "C" {
13 #include <stdio.h>
14 #include <stdint.h>
15 };
16
17 using namespace AxWin;
18
19 // === CODE ===
20 int main(int argc, char *argv[])
21 {
22         // - Load configuration (from file and argv)
23         CConfig config;
24         try {
25                 config.parseCommandline(argc, argv);
26         }
27         catch(const std::exception& e) {
28                 fprintf(stderr, "Exception: %s\n", e.what());
29                 return 1;
30         }
31         // - Open graphics
32         Graphics::Initialise(config.m_video);
33         // - Initialise compositor structures
34         CCompositor* compositor = new CCompositor(/*config.m_compositor*/);
35         // - Open input
36         Input::Initialise(config.m_input);
37         //  > Handles hotkeys?
38         // - Bind IPC channels
39         IPC::Initialise(config.m_ipc, compositor);
40         // - Start root child process (from config)
41         // TODO: Spin up child process
42
43         // - Event loop
44         for( ;; )
45         {
46                  int    nfd = 0;
47                 fd_set  rfds;
48                 
49                 nfd = ::std::max(nfd, Input::FillSelect(rfds));
50                 nfd = ::std::max(nfd, IPC::FillSelect(rfds));
51                 
52                 // TODO: Support _SysSendMessage IPC?
53                 int64_t timeout = Timing::GetTimeToNextEvent();
54                 int rv = ::_SysSelect(nfd, &rfds, NULL, &rfds, &timeout, 0);
55                 
56                 Timing::CheckEvents();
57                 
58                 Input::HandleSelect(rfds);
59                 IPC::HandleSelect(rfds);
60                 
61                 compositor->Redraw();
62         }
63         return 0;
64 }
65

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