AxWin3 - More RichText work
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / main.c
1 /*
2  * Acess2 GUI (AxWin) Version 3
3  * - By John Hodge (thePowersGang)
4  *
5  * main.c
6  * - Entrypoint
7  */
8 #include <common.h>
9 #include <acess/sys.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <axwin3/keysyms.h>
13
14 // === IMPORTS ===
15 extern void     Video_Setup(void);
16 extern void     WM_Initialise(void);
17 extern int      Renderer_Menu_Init(void);
18 extern int      Renderer_Widget_Init(void);
19 extern int      Renderer_Background_Init(void);
20 extern int      Renderer_Framebuffer_Init(void);
21 extern int      Renderer_RichText_Init(void);
22 extern void     WM_Update(void);
23 extern void     WM_Hotkey_Register(int nKeys, uint32_t *Keys, const char *ActionName);
24
25 // === PROTOTYPES ===
26 void    ParseCommandline(int argc, char **argv);
27
28 // === GLOBALS ===
29 const char      *gsTerminalDevice = NULL;
30 const char      *gsMouseDevice = NULL;
31
32  int    giScreenWidth = 640;
33  int    giScreenHeight = 480;
34
35  int    giTerminalFD = -1;
36  int    giTerminalFD_Input = 0;
37  int    giMouseFD = -1;
38
39 #define __INSTALL_ROOT  "/Acess/Apps/AxWin/3.0"
40
41 const char      *gsInstallRoot = __INSTALL_ROOT;
42
43 // === CODE ===
44 /**
45  * \brief Program Entrypoint
46  */
47 int main(int argc, char *argv[])
48 {
49          int    server_tid = gettid();
50         
51         ParseCommandline(argc, argv);
52         
53         if( gsTerminalDevice == NULL ) {
54                 gsTerminalDevice = "/Devices/VTerm/6";
55         }
56         if( gsMouseDevice == NULL ) {
57                 gsMouseDevice = "/Devices/Mouse/system";
58         }
59         
60         Video_Setup();
61         IPC_Init();
62         Input_Init();
63         
64         Renderer_Menu_Init();
65         Renderer_Widget_Init();
66         Renderer_Background_Init();
67         Renderer_Framebuffer_Init();
68         Renderer_RichText_Init();
69         WM_Initialise();
70
71         // TODO: Config
72         uint32_t        keys[4];
73         keys[0] = KEYSYM_LEFTGUI;       keys[1] = KEYSYM_r;
74         WM_Hotkey_Register(2, keys, "Interface>Run");
75         
76         // Spawn interface root
77         if( clone(CLONE_VM, 0) == 0 )
78         {
79                 static char csInterfaceApp[] = __INSTALL_ROOT"/AxWinUI";
80                 char    server_info[] = "AXWIN3_SERVER=00000";
81                 char    *envp[] = {server_info, NULL};
82                 char    *argv[] = {csInterfaceApp, NULL};
83                 _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid);
84                 sprintf(server_info, "AXWIN3_SERVER=%i", server_tid);
85                 execve(csInterfaceApp, argv, envp);
86                 exit(1);
87         }
88
89         // Main Loop
90         for(;;)
91         {
92                 fd_set  fds;
93                  int    nfds = 0;
94                 FD_ZERO(&fds);
95         
96                 WM_Update();
97
98                 Input_FillSelect(&nfds, &fds);
99                 IPC_FillSelect(&nfds, &fds);
100                 
101                 nfds ++;
102                 if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
103                         _SysDebug("ERROR: select() returned -1");
104                         return -1;
105                 }
106
107                 Input_HandleSelect(&fds);
108                 IPC_HandleSelect(&fds);
109         }
110         return 0;
111 }
112
113 void ParseCommandline(int argc, char **argv)
114 {
115         
116 }
117

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