X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Fmain.c;h=a9266b41e955f562b0535e09d82fcb9f563c7380;hb=608ec5aa6e1bd522777faa63323beaeaef928928;hp=2ae11aa7454bc71ee413b3ff15586bb1de9d67a5;hpb=f5c5d4bd1b3a32db4e8b115d2c71773dd58d77bf;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index 2ae11aa7..a9266b41 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -7,10 +7,20 @@ */ #include #include +#include +#include +#include // === 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); @@ -21,11 +31,16 @@ const char *gsMouseDevice = NULL; int giScreenWidth = 640; int giScreenHeight = 480; -uint32_t *gpScreenBuffer = NULL; int giTerminalFD = -1; + int giTerminalFD_Input = 0; int giMouseFD = -1; - + +#define __INSTALL_ROOT "/Acess/Apps/AxWin/3.0" + +const char *gsInstallRoot = __INSTALL_ROOT; +const char *gsInterfaceApp = __INSTALL_ROOT"/AxWinUI"; + int gbNoSpawnUI = 0; // === CODE === /** @@ -39,16 +54,46 @@ int main(int argc, char *argv[]) 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"); + keys[0] = KEYSYM_LEFTGUI; keys[1] = KEYSYM_e; + WM_Hotkey_Register(2, keys, "Interface>TextEdit"); + // Spawn interface root + if( !gbNoSpawnUI ) + { + int server_tid = gettid(); + _SysDebug("server_tid = %i", server_tid); + char server_info[] = "AXWIN3_SERVER=00000"; + const char *envp[] = {server_info, NULL}; + const char *argv[] = {gsInterfaceApp, NULL}; + _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid); + sprintf(server_info, "AXWIN3_SERVER=%i", server_tid); + // TODO: Does the client need FDs? + int rv = _SysSpawn(gsInterfaceApp, argv, envp, 0, NULL, NULL); + if( rv < 0 ) { + _SysDebug("_SysSpawn chucked a sad, rv=%i, errno=%i", rv, _errno); + } + } + // Main Loop for(;;) { @@ -56,11 +101,16 @@ int main(int argc, char *argv[]) int nfds = 0; FD_ZERO(&fds); + WM_Update(); + Input_FillSelect(&nfds, &fds); IPC_FillSelect(&nfds, &fds); nfds ++; - select(nfds, &fds, NULL, NULL, NULL); + if( _SysSelect(nfds, &fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG) == -1 ) { + _SysDebug("ERROR: select() returned -1"); + return -1; + } Input_HandleSelect(&fds); IPC_HandleSelect(&fds); @@ -68,8 +118,37 @@ int main(int argc, char *argv[]) return 0; } +void PrintUsage(void) +{ + fprintf(stderr, "Arguments:\n"); + fprintf(stderr, " --no-ui : Don't spawn the UI process\n"); +} + void ParseCommandline(int argc, char **argv) { - + for( int i = 1; i < argc; i ++ ) + { + if( argv[i][0] != '-' ) { + // Error? + PrintUsage(); + exit(-1); + } + else if( argv[i][1] != '-' ) { + // Short + PrintUsage(); + exit(-1); + } + else { + // Long + if( strcmp(argv[i], "--no-ui") == 0 ) { + gbNoSpawnUI = 1; + } + else { + // Error. + PrintUsage(); + exit(-1); + } + } + } }