Corrected capitalisation.
[AROS.git] / rom / intuition / unlockpubscreen.c
blob8bd08eb40d6252ab900793e83cdab74bb4723155
1 /*
2 Copyright © 1995-2013, 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 static struct PubScreenNode *findcasename(struct List *list, const UBYTE *name);
11 /*****************************************************************************
13 NAME */
14 #include <proto/intuition.h>
16 AROS_LH2(void, UnlockPubScreen,
18 /* SYNOPSIS */
19 AROS_LHA(UBYTE *, name, A0),
20 AROS_LHA(struct Screen *, screen, A1),
22 /* LOCATION */
23 struct IntuitionBase *, IntuitionBase, 86, Intuition)
25 /* FUNCTION
26 Release a lock to a screen locked by LockPubScreen().
27 Identify screen by the pointer returned from LockPubScreen()
28 and pass NULL name in normal cases.
30 Sometimes it might be useful to specify the name string. In
31 this case the screen pointer will be ignored.
33 INPUTS
34 name - Name of the public screen to unlock. The name is case
35 insensitive.
36 screen - Pointer to the screen to unlock.
38 RESULT
39 None.
41 NOTES
42 The screen parameter will be ignored if name is non-NULL.
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 LockPubScreen()
51 INTERNALS
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 struct List *publist;
59 DEBUG_UNLOCKPUBSCREEN(dprintf("UnlockPubScreen: name <%s> screen %p\n",
60 name ? (const char *)name : "NULL", screen));
61 DEBUG_UNLOCKPUBSCREEN(dprintf("LockPubScreen: task %p <%s>\n",
62 SysBase->ThisTask,
63 SysBase->ThisTask->tc_Node.ln_Name ? SysBase->ThisTask->tc_Node.ln_Name : "NULL"));
65 publist = LockPubScreenList();
67 if (name != NULL)
69 struct PubScreenNode *psn;
71 /* Get screen by its name */
72 if ((psn = findcasename(publist, name)))
73 screen = psn->psn_Screen;
74 else
75 screen = NULL;
77 DEBUG_UNLOCKPUBSCREEN(dprintf("UnlockPubScreen: found screen %p\n",
78 screen));
81 if (screen != NULL)
83 struct PubScreenNode *ps = GetPrivScreen(screen)->pubScrNode;
85 //ASSERT(GetPrivScreen(screen)->pubScrNode != NULL);
86 //ASSERT(GetPrivScreen(screen)->pubScrNode->psn_VisitorCount > 0);
88 /* Unlock screen */
89 ps->psn_VisitorCount--;
91 DEBUG_VISITOR(dprintf("UnlockPubScreen: count %d <%s>\n",
92 ps->psn_VisitorCount,
93 FindTask(NULL)->tc_Node.ln_Name));
96 DEBUG_UNLOCKPUBSCREEN(dprintf("UnlockPubScreen: count %d\n",
97 ps->psn_VisitorCount));
99 /* Notify screen owner if this is (was) the last window on the
100 screen */
101 if(ps->psn_VisitorCount == 0)
103 if(ps->psn_SigTask != NULL)
104 Signal(ps->psn_SigTask, 1 << ps->psn_SigBit);
109 UnlockPubScreenList();
111 FireScreenNotifyMessage((IPTR) name, SNOTIFY_UNLOCKPUBSCREEN, IntuitionBase);
113 AROS_LIBFUNC_EXIT
114 } /* UnlockPubScreen */
117 /* case insensitive FindName() */
118 static struct PubScreenNode *findcasename(struct List *list, const UBYTE *name)
120 struct Node *node;
122 for (node = GetHead(list); node; node = GetSucc(node))
124 if(node->ln_Name)
126 if (!strcasecmp (node->ln_Name, name))
127 break;
130 return (struct PubScreenNode *)node;