Merge branch 'master' of git://localhost/acess2
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / main.c
index c6a4546..9db1c15 100644 (file)
@@ -9,10 +9,18 @@
 #include <acess/sys.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <axwin3/keysyms.h>
 
 // === IMPORTS ===
-extern void    WM_Update(void);
 extern void    Video_Setup(void);
+extern void    WM_Initialise(void);
+extern int     Renderer_Menu_Init(void);
+extern int     Renderer_Widget_Init(void);
+extern int     Renderer_Background_Init(void);
+extern int     Renderer_Framebuffer_Init(void);
+extern int     Renderer_RichText_Init(void);
+extern void    WM_Update(void);
+extern void    WM_Hotkey_Register(int nKeys, uint32_t *Keys, const char *ActionName);
 
 // === PROTOTYPES ===
 void   ParseCommandline(int argc, char **argv);
@@ -25,6 +33,7 @@ const char    *gsMouseDevice = NULL;
  int   giScreenHeight = 480;
 
  int   giTerminalFD = -1;
+ int   giTerminalFD_Input = 0;
  int   giMouseFD = -1;
 
 #define __INSTALL_ROOT "/Acess/Apps/AxWin/3.0"
@@ -37,33 +46,48 @@ const char  *gsInstallRoot = __INSTALL_ROOT;
  */
 int main(int argc, char *argv[])
 {
-        int    server_tid = gettid();
-       
        ParseCommandline(argc, argv);
        
        if( gsTerminalDevice == NULL ) {
                gsTerminalDevice = "/Devices/VTerm/6";
        }
        if( gsMouseDevice == NULL ) {
-               gsMouseDevice = "/Devices/PS2Mouse";
+               gsMouseDevice = "/Devices/Mouse/system";
        }
        
        Video_Setup();
-//     Interface_Init();
        IPC_Init();
        Input_Init();
        
-//     WM_Update();
+       Renderer_Menu_Init();
+       Renderer_Widget_Init();
+       Renderer_Background_Init();
+       Renderer_Framebuffer_Init();
+       Renderer_RichText_Init();
+       WM_Initialise();
+
+       // TODO: Move these to config
+       uint32_t        keys[4];
+       keys[0] = KEYSYM_LEFTGUI;       keys[1] = KEYSYM_r;
+       WM_Hotkey_Register(2, keys, "Interface>Run");
+       keys[0] = KEYSYM_LEFTGUI;       keys[1] = KEYSYM_t;
+       WM_Hotkey_Register(2, keys, "Interface>Terminal");
        
        // Spawn interface root
-       if( clone(CLONE_VM, 0) == 0 )
        {
+               int     server_tid = gettid();
+               _SysDebug("server_tid = %i", server_tid);
                static char csInterfaceApp[] = __INSTALL_ROOT"/AxWinUI";
                char    server_info[] = "AXWIN3_SERVER=00000";
-               char    *envp[] = {server_info, NULL};
-               char    *argv[] = {csInterfaceApp, NULL};
+               const char      *envp[] = {server_info, NULL};
+               const char      *argv[] = {csInterfaceApp, NULL};
+               _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid);
                sprintf(server_info, "AXWIN3_SERVER=%i", server_tid);
-               execve(csInterfaceApp, argv, envp);
+               // TODO: Does the client need FDs?
+                int    rv = _SysSpawn(csInterfaceApp, argv, envp, 0, NULL, NULL);
+               if( rv < 0 ) {
+                       _SysDebug("_SysSpawn chucked a sad, rv=%i, errno=%i", rv, _errno);
+               }
        }
 
        // Main Loop
@@ -73,11 +97,13 @@ int main(int argc, char *argv[])
                 int    nfds = 0;
                FD_ZERO(&fds);
        
+               WM_Update();
+
                Input_FillSelect(&nfds, &fds);
                IPC_FillSelect(&nfds, &fds);
                
                nfds ++;
-               if( select(nfds, &fds, NULL, NULL, NULL) == -1 ) {
+               if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) {
                        _SysDebug("ERROR: select() returned -1");
                        return -1;
                }

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