Usermode/axwin4 - Starting on implementation
[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 <timing.hpp>
8
9 using namespace AxWin;
10
11 // === CODE ===
12 int main(int argc, char *argv[])
13 {
14         // - Load configuration (from file and argv)
15         CConfig config;
16         try {
17                 config.parseCommandline(argc, argv);
18         }
19         catch(const std::exception& e) {
20                 fprintf(stderr, "Exception: %s\n", e.what());
21                 return 1;
22         }
23         // - Open graphics
24         Graphics::Initialise(config.m_video);
25         // - Open input
26         Input::Initialise(config.m_input);
27         //  > Handles hotkeys?
28         // - Initialise compositor structures
29         Compositor::Initialise(config.m_compositor);
30         // - Bind IPC channels
31         IPC::Initialise(config.m_ipc);
32         // - Start root child process (from config)
33         // TODO: Spin up child process
34
35         // - Event loop
36         for( ;; )
37         {
38                  int    nfd = 0;
39                 fd_set  rfds;
40                 
41                 Input::FillSelect(&nfd, &rfds);
42                 IPC::FillSelect(&nfd, &rfds);
43                 
44                 // TODO: Timer events
45                 int64_t timeout = Timing::GetTimeToNextEvent();
46                 int rv = ::_SysSelect(nfd, &rfds, NULL, &rfds, NULL, 0);
47                 
48                 Timing::CheckEvents();
49                 
50                 Input::HandleSelect(&rfds);
51                 IPC::HandleSelect(&rfds);
52                 
53                 Compositor::Redraw();
54         }
55         return 0;
56 }
57

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