New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / intuition / lockpubscreen.c
blob81235a0b3434404bcb0711dec1b4b1e8880d1301
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 <string.h>
8 #include "intuition_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/intuition.h>
15 AROS_LH1(struct Screen *, LockPubScreen,
17 /* SYNOPSIS */
18 AROS_LHA(CONST_STRPTR, name, A0),
20 /* LOCATION */
21 struct IntuitionBase *, IntuitionBase, 85, Intuition)
23 /* FUNCTION
25 Locks a public screen, thus preventing it from closing.
26 This is useful if you want to put up a visitor window on a public screen
27 and need to check some of the public screen's field first -- not locking
28 the screen may lead to the public screen not existing when your visitor
29 window is ready.
31 If you try to lock the Workbench screen or the default public screen
32 and there isn'tany, the Workbench screen will be automatically opened
33 and locked.
35 INPUTS
37 Name -- Name of the public screen or NULL for the default public
38 screen. The name "Workbench" refers to the Workbench screen.
40 RESULT
42 A pointer to the screen or NULL if something went wrong. Failure can
43 happen for instance when the public screen is in private state or doesn't
44 exist.
46 NOTES
48 You don't need to hold the lock when your visitor window is opened as
49 the pubscreen cannot be closed as long as there are visitor windows
50 on it.
52 EXAMPLE
54 To open a visitor window which needs information from the screen structure
55 of the public screen to open on, do this:
57 if((pubscreen = LockPubScreen("PubScreentoOpenon")) != NULL)
59 ...check pubscreen's internal data...
60 OpenWindow(VisitorWindow, pubscreen);
61 UnlockPubScreen(NULL, pubscreen);
62 ...use your visitor window...
63 CloseWindow(VisitorWindow);
66 BUGS
68 SEE ALSO
70 OpenWindow(), UnlockPubScreen(), GetScreenData()
72 INTERNALS
74 HISTORY
75 29-10-95 digulla automatically created from
76 intuition_lib.fd and clib/intuition_protos.h
78 *****************************************************************************/
80 AROS_LIBFUNC_INIT
81 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
83 struct Screen *screen = NULL;
84 struct List *list;
86 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: name <%s>\n",
87 name ? name : (CONST_STRPTR)"NULL"));
88 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: task %p <%s>\n",
89 SysBase->ThisTask,
90 SysBase->ThisTask->tc_Node.ln_Name ? SysBase->ThisTask->tc_Node.ln_Name : "NULL"));
92 list = LockPubScreenList();
94 if( !name )
97 screen = GetPrivIBase(IntuitionBase)->DefaultPubScreen;
99 /* If IntuitionBase->DefaultPubScreen is NULL, then Workbench screen
100 is default public screen. But note that, Workbench screen might
101 here not be open either. */
103 if (!screen) screen = GetPrivIBase(IntuitionBase)->WorkBench;
105 if (screen)
107 ASSERT_VALID_PTR(screen);
108 GetPrivScreen(screen)->pubScrNode->psn_VisitorCount++;
109 DEBUG_VISITOR(dprintf("LockPubScreen: 1 screen %p count %ld Task <%s>\n",
110 screen, GetPrivScreen(screen)->pubScrNode->psn_VisitorCount,
111 FindTask(NULL)->tc_Node.ln_Name));
112 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: screen %p count %d\n",
113 screen, GetPrivScreen(screen)->pubScrNode->psn_VisitorCount));
117 else
119 struct PubScreenNode *psn;
121 ASSERT_VALID_PTR_ROMOK(name);
123 /* Browse the public screen list */
124 if( (psn = (struct PubScreenNode *) FindName(list, (UBYTE *)name )) )
126 ASSERT_VALID_PTR(psn);
128 /* Don't lock screens in private state */
129 if( (psn != NULL) && !(psn->psn_Flags & PSNF_PRIVATE) )
131 /* Increment screen lock count */
132 psn->psn_VisitorCount++;
133 screen = psn->psn_Screen;
134 DEBUG_VISITOR(dprintf("LockPubScreen: 2 node %p screen %p count %ld <%s>\n",
135 psn, screen, psn->psn_VisitorCount,
136 FindTask(NULL)->tc_Node.ln_Name));
137 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: node %p screen %p count %d\n",
138 psn, screen, psn->psn_VisitorCount));
139 ASSERT_VALID_PTR(screen);
145 UnlockPubScreenList();
147 /* If no screen was found and the requested one was the Workbench screen or
148 * the default public screen, open the Workbench screen and lock it. */
149 if( (screen == NULL) && ((name == NULL) || (strcmp( name, "Workbench" ) == 0)) )
151 OpenWorkBench();
152 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: opened workbench\n"));
154 LockPubScreenList();
156 screen = GetPrivIBase(IntuitionBase)->WorkBench;
157 if (!screen)
159 struct PubScreenNode *psn;
161 /* Maybe something patched OpenWorkbench, and there is a 'Workbench'
162 * screen in the list. Our private pointer is just not set. */
163 if( (psn = (struct PubScreenNode *) FindName(list, "Workbench" )) )
165 /* Don't lock screens in private state */
166 if( (psn != NULL) && !(psn->psn_Flags & PSNF_PRIVATE) )
167 screen = psn->psn_Screen;
171 if( screen )
173 ASSERT_VALID_PTR(screen);
174 GetPrivScreen(screen)->pubScrNode->psn_VisitorCount++;
175 DEBUG_VISITOR(dprintf("LockPubScreen: 3 screen %p count %d <%s>\n",
176 screen, GetPrivScreen(screen)->pubScrNode->psn_VisitorCount,
177 FindTask(NULL)->tc_Node.ln_Name));
179 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: screen %p count %d\n",
180 screen, GetPrivScreen(screen)->pubScrNode->psn_VisitorCount));
183 UnlockPubScreenList();
186 FireScreenNotifyMessage((IPTR) screen, SNOTIFY_LOCKPUBSCREEN, IntuitionBase);
188 DEBUG_LOCKPUBSCREEN(dprintf("LockPubScreen: return %p\n", screen));
190 return screen;
192 AROS_LIBFUNC_EXIT
193 } /* LockPubScreen */