2 Copyright 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include "intuition_intern.h"
9 #include <intuition/intuition.h>
10 #include <proto/intuition.h>
12 /*****************************************************************************
16 AROS_LH0(LONG
, CloseWorkBench
,
21 struct IntuitionBase
*, IntuitionBase
, 13, Intuition
)
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)
49 *****************************************************************************/
52 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
54 struct Screen
*wbscreen
;
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"));
64 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList done\n"));
66 wbscreen
= GetPrivIBase(IntuitionBase
)->WorkBench
;
68 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: Workbench Screen 0x%lx\n",
73 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: no wbscreen, do nothing\n"));
74 UnlockPubScreenList();
76 FireScreenNotifyMessage((IPTR
) wbscreen
, SNOTIFY_AFTER_OPENWB
, IntuitionBase
);
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
));
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"));
106 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: LockPubScreenList done\n"));
108 wbscreen
= GetPrivIBase(IntuitionBase
)->WorkBench
;
110 DEBUG_CLOSEWORKBENCH(dprintf("CloseWorkBench: current wbscreen 0x%lx\n",
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
;
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
++;
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",
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"));
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
));
170 /* Workbench screen failed to close, notify that the screen is open again */
171 FireScreenNotifyMessage((IPTR
) wbscreen
, SNOTIFY_AFTER_OPENWB
, IntuitionBase
);
175 FireScreenNotifyMessage((IPTR
) wbscreen
, SNOTIFY_AFTER_CLOSEWB
, IntuitionBase
);
182 } /* CloseWorkBench */