New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / closeworkbench.c
blobe6729fc82ddafdad742346dbed463d2aefc6a4f1
1 /*
2 Copyright 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include "intuition_intern.h"
9 #include <intuition/intuition.h>
10 #include <proto/intuition.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH0(LONG, CloseWorkBench,
18 /* SYNOPSIS */
20 /* LOCATION */
21 struct IntuitionBase *, IntuitionBase, 13, Intuition)
23 /* FUNCTION
24 Attempt to close the Workbench screen:
25 - Check for open application windows. return FALSE if there are any
26 - Clean up all special buffers
27 - Close the Workbench screen
28 - Make the Workbench program mostly inactive
29 (disk activity will still be monitored)
30 - Return TRUE
32 INPUTS
34 RESULT
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 OpenWorkBench()
45 INTERNALS
47 HISTORY
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
52 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
54 struct Screen *wbscreen;
55 BOOL retval = TRUE;
57 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: <%s>\n",
58 FindTask(NULL)->tc_Node.ln_Name));
60 if (wbscreen) FireScreenNotifyMessage((IPTR) wbscreen, SNOTIFY_BEFORE_CLOSEWB, IntuitionBase);
62 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList\n"));
63 LockPubScreenList();
64 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList done\n"));
66 wbscreen = GetPrivIBase(IntuitionBase)->WorkBench;
68 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Workbench Screen 0x%lx\n",
69 (ULONG) wbscreen));
71 if (!wbscreen)
73 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: no wbscreen, do nothing\n"));
74 UnlockPubScreenList();
76 FireScreenNotifyMessage((IPTR) wbscreen, SNOTIFY_AFTER_OPENWB, IntuitionBase);
78 return(FALSE);
80 else
82 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Workbench Screen's pubnode 0x%lx\n",
83 (ULONG) GetPrivScreen(wbscreen)->pubScrNode));
84 if (GetPrivScreen(wbscreen)->pubScrNode->psn_VisitorCount != 0)
86 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: visitor count %ld, do nothing\n",
87 (ULONG) GetPrivScreen(wbscreen)->pubScrNode->psn_VisitorCount));
88 retval = FALSE;
92 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnlockPubScreenList\n"));
93 UnlockPubScreenList();
94 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnlockPubScreenList done\n"));
97 /* If there is a Workbench process running, tell it to close it's windows. */
99 /* Don't call this function while pub screen list is locked! */
101 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Tell WB to close windows\n"));
102 TellWBTaskToCloseWindows(IntuitionBase);
104 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList\n"));
105 LockPubScreenList();
106 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList done\n"));
108 wbscreen = GetPrivIBase(IntuitionBase)->WorkBench;
110 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: current wbscreen 0x%lx\n",
111 (ULONG) wbscreen));
113 /* Try to close the Workbench screen, if there is any. */
114 if( wbscreen != NULL )
116 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: CloseScreen\n"));
117 if( CloseScreen( wbscreen ) == TRUE )
119 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: CloseScreen worked\n"));
120 GetPrivIBase(IntuitionBase)->WorkBench = NULL;
121 wbscreen = NULL;
122 retval = TRUE;
124 else
126 /* Grrr ... closing screen failed. I inc psn_VisitorCount by hand here,
127 * to avoid that someone else can kill it, because I must tell Workbench
128 * task that it shall open its windows again
131 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: CloseScreen failed\n"));
132 GetPrivScreen(wbscreen)->pubScrNode->psn_VisitorCount++;
133 retval = FALSE;
136 else
138 retval = FALSE;
141 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnLockPubScreenList\n"));
142 UnlockPubScreenList();
143 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnLockPubScreenList done\n"));
145 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: wbscreen 0x%lx retval %ld\n",
146 (ULONG) wbscreen,
147 (ULONG) retval));
148 if (wbscreen && (retval == FALSE))
150 /* Don't call this function while pub screen list is locked! */
151 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Tell WB to reopen windows\n"));
152 TellWBTaskToOpenWindows(IntuitionBase);
154 /* Fix psn_VisitorCount which was increased above */
155 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList\n"));
156 LockPubScreenList();
157 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList done\n"));
158 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: WBScreen's pubnode 0x%lx\n",
159 (ULONG) GetPrivScreen(wbscreen)->pubScrNode));
160 GetPrivScreen(wbscreen)->pubScrNode->psn_VisitorCount--;
161 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnLockPubScreenList\n"));
162 UnlockPubScreenList();
163 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: UnLockPubScreenList done\n"));
166 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Return %d\n", retval));
168 if (!retval)
170 /* Workbench screen failed to close, notify that the screen is open again */
171 FireScreenNotifyMessage((IPTR) wbscreen, SNOTIFY_AFTER_OPENWB, IntuitionBase);
173 else
175 FireScreenNotifyMessage((IPTR) wbscreen, SNOTIFY_AFTER_CLOSEWB, IntuitionBase);
178 return retval;
180 AROS_LIBFUNC_EXIT
182 } /* CloseWorkBench */