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

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