- Wait for mouse acks properly.
[cake.git] / rom / hyperlayers / isfrontmostlayer.c
blob3535502465bac1ce7f62155d9ee81369ffbf713b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include "layers_intern.h"
12 #include <aros/libcall.h>
13 #include <proto/graphics.h>
14 #include "basicfuncs.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/layers.h>
20 AROS_LH2(BOOL, IsFrontmostLayer,
22 /* SYNOPSIS */
23 AROS_LHA(struct Layer *, l , A0),
24 AROS_LHA(BOOL , check_invisible, D0),
26 /* LOCATION */
27 struct LayersBase *, LayersBase, 43, Layers)
29 /* FUNCTION
30 Checks whether this layer is the frontmost layer within
31 its priority. If this layer has children then all of
32 its children will be disregarded. Comparisons are only
33 done with layers that have the same 'depth' of relation-
34 ship (=nesting counter) to the root layer.
35 It can be specified whether invisible siblings are to be
36 considered in the comparison.
38 INPUTS
39 L - pointer to layer
40 check_invisible - whether invisible siblings are to be considered
43 RESULT
44 TRUE - layer is frontmost layer within its priority
45 FALSE - layer is not frontmost layer within its priority
47 NOTES
49 EXAMPLE
51 BUGS
53 SEE ALSO
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct Layer * _l;
64 BOOL result = TRUE;
66 if (NULL == l)
67 return FALSE;
69 LockLayers(l->LayerInfo);
71 _l = l->front;
73 while (NULL != _l) {
75 * If they differ in priority then return TRUE.
76 * I did not meet another (elegible) sibling so
77 * far.
79 if (_l->priority != l->priority)
80 break;
82 * If the nesting counter of one layer in front
83 * of the layer l is equal (or less) then return FALSE.
85 if (_l->nesting <= l->nesting &&
86 ( IS_VISIBLE(_l) || TRUE == check_invisible)) {
87 result = FALSE;
88 break;
90 _l = _l->front;
93 UnlockLayers(l->LayerInfo);
95 return result;
97 AROS_LIBFUNC_EXIT
98 } /* IsFrontmostLayer */