fix properties
[AROS.git] / rom / intuition / getmonitorlist.c
blob2f496d39de23da428dfa9358e2a4a98740042094
1 /*
2 Copyright © 2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Get a copy of monitors list
6 */
8 #include <intuition/extensions.h>
9 #include <proto/exec.h>
10 #include <proto/utility.h>
12 #include "intuition_intern.h"
13 #include "monitorclass_private.h"
15 /*****************************************************************************
17 NAME */
19 #include <proto/intuition.h>
21 AROS_LH1(Object **, GetMonitorList,
23 /* SYNOPSIS */
24 AROS_LHA(struct TagItem *, tags, A1),
26 /* LOCATION */
27 struct IntuitionBase *, IntuitionBase, 163, Intuition)
29 /* FUNCTION
30 Obtain an array of monitorclass objects installed in the
31 system
33 INPUTS
34 tags - an optional pointer to a taglist with additional options.
35 Currently only one tag is defined:
37 GMLA_DisplayID - list only monitors matching the given
38 display ID
40 RESULT
41 A pointer to a NULL-terminated array of BOOPSI object pointers.
42 This is a copy of internal list, you need to free it using
43 FreeMonitorList()
45 NOTES
46 This function is compatible with MorphOS v2.
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 FreeMonitorList()
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct MinNode *n;
64 Object **res;
65 ULONG num = 1;
66 ULONG id = GetTagData(GMLA_DisplayID, INVALID_ID, tags);
68 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase)->MonitorListSem);
70 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
71 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
72 num++;
75 res = AllocVec(num * sizeof(Object *), MEMF_ANY);
77 if (res) {
78 num = 0;
79 for (n = GetPrivIBase(IntuitionBase)->MonitorList.mlh_Head; n->mln_Succ; n = n->mln_Succ) {
80 if ((id == INVALID_ID) || DoMethod((Object *)n, MM_CheckID, id))
81 res[num++] = (Object *)n;
83 res[num] = NULL;
86 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
88 return res;
90 AROS_LIBFUNC_EXIT