Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / workbench / workbench_init.c
blob4bcc75997be09cb680acd467ca9a2483438f80c7
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Initialization of workbench.library.
6 */
8 #define DEBUG 1
9 #include <aros/debug.h>
10 #include <aros/atomic.h>
11 #include <aros/symbolsets.h>
13 #include "workbench_intern.h"
14 #include LC_LIBDEFS_FILE
15 #include "handler.h"
16 #include "support.h"
18 static int WBInit(LIBBASETYPEPTR LIBBASE)
20 /* Make sure that the libraries are opened in L_OpenLib() --------------*/
21 WorkbenchBase->wb_Initialized = FALSE;
23 /* Initialize our private lists ----------------------------------------*/
24 NEWLIST(&(WorkbenchBase->wb_AppWindows));
25 NEWLIST(&(WorkbenchBase->wb_AppIcons));
26 NEWLIST(&(WorkbenchBase->wb_AppMenuItems));
27 NEWLIST(&(WorkbenchBase->wb_HiddenDevices));
29 /* Initialize our semaphores -------------------------------------------*/
30 InitSemaphore(&(WorkbenchBase->wb_WorkbenchPortSemaphore));
31 InitSemaphore(&(WorkbenchBase->wb_InitializationSemaphore));
32 InitSemaphore(&(WorkbenchBase->wb_BaseSemaphore));
34 /* Initialize handler message port -------------------------------------*/
35 WorkbenchBase->wb_HandlerPort.mp_SigBit = SIGBREAKB_CTRL_F;
36 WorkbenchBase->wb_HandlerPort.mp_SigTask = NULL;
37 WorkbenchBase->wb_HandlerPort.mp_Flags = PA_IGNORE;
38 NEWLIST(&(WorkbenchBase->wb_HandlerPort.mp_MsgList));
40 /* Initialize miscellanous variables -----------------------------------*/
41 WorkbenchBase->wb_DefaultStackSize = 1024 * 32; /* 32kiB */ // FIXME: also read from preferences */
43 return TRUE;
46 static int WBOpen(LIBBASETYPEPTR LIBBASE)
48 ObtainSemaphore(&(WorkbenchBase->wb_InitializationSemaphore));
50 if (!(WorkbenchBase->wb_Initialized))
52 struct CommandLineInterface *cli;
54 /* Duplicate the search path ---------------------------------------*/
55 if ((cli = Cli()) != NULL)
57 WorkbenchBase->wb_SearchPath = DuplicateSearchPath
59 cli->cli_CommandDir
63 /* Start workbench handler -----------------------------------------*/
67 CreateNewProcTags
69 NP_Entry, (IPTR) WorkbenchHandler,
70 NP_StackSize, 8129,
71 NP_Name, (IPTR) "Workbench Handler",
72 NP_UserData, (IPTR) WorkbenchBase,
73 TAG_DONE
75 ) != NULL
78 /* Prevent expunging while the handler is running */
79 AROS_ATOMIC_INC(WorkbenchBase->LibNode.lib_OpenCnt);
81 else
83 // FIXME: free resources
84 return FALSE;
87 WorkbenchBase->wb_Initialized = TRUE;
90 ReleaseSemaphore(&(WorkbenchBase->wb_InitializationSemaphore));
92 return TRUE;
93 } /* L_OpenLib */
95 ADD2INITLIB(WBInit, 0);
96 ADD2OPENLIB(WBOpen, 0);