- Wait for mouse acks properly.
[cake.git] / rom / hyperlayers / upfrontlayer.c
blob954708ae6eea48254f54108fac8d1a1ba2d9c9d8
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 <aros/libcall.h>
12 #include <proto/graphics.h>
13 #include <proto/layers.h>
14 #include "layers_intern.h"
17 /*****************************************************************************
19 NAME */
21 AROS_LH2(LONG, UpfrontLayer,
23 /* SYNOPSIS */
24 AROS_LHA(LONG , dummy, A0),
25 AROS_LHA(struct Layer *, l , A1),
27 /* LOCATION */
28 struct LayersBase *, LayersBase, 8, Layers)
30 /* FUNCTION
31 Brings a layer to the front. If this layer is a backdrop layer
32 it is brought in front of all backdrop layers and behind the
33 last non-backdrop layer. By clearing the BACKDROP flag of a layer
34 a backdrop layer can be brought in front of all other layers.
35 Parts of a simple layer that become visible are added to the
36 damage list and the REFRESH flag is set.
38 INPUTS
39 dummy - unused
40 L - pointer to layer
42 RESULT
43 TRUE - layer was moved
44 FALSE - layer could not be moved (probably out of memory)
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 CreateUpfrontLayer(), CreateUpfrontHookLayer(), BehindLayer()
54 CreateBehindLayer(), CreateBehindHookLayer()
56 INTERNALS
58 HISTORY
59 27-11-96 digulla automatically created from
60 layers_lib.fd and clib/layers_protos.h
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
66 struct Layer * first, * _l;
67 int found = FALSE;
68 LONG ret;
70 //kprintf("\t\t%s called!\n",__FUNCTION__);
71 LockLayers(l->LayerInfo);
74 * Move the layer in front of that layer with the same
75 * priority.
76 * Also keep its children in front of itself.
78 first = GetFirstFamilyMember(l);
81 * If there is nobody in front of the first family member
82 * I don't have to do anything.
83 * first can also be l.
85 if (NULL == first->front)
87 UnlockLayers(l->LayerInfo);
88 return TRUE;
91 * Search for the new place
92 * search all layers that have the same priority.
93 * If I find another layer with the same nesting
94 * as the one to be moved I have a place to move.
95 * Stop at the frontmost layer
97 _l = first->front;
100 if (_l -> priority == l->priority)
102 while (1)
104 if (_l->nesting == l->nesting)
105 found = TRUE;
106 if (NULL == _l->front || _l->front->priority != l->priority)
107 break;
108 _l = _l->front;
112 if (FALSE == found)
114 UnlockLayers(l->LayerInfo);
115 return TRUE;
118 ret = _MoveLayerToFront(l,_l, LayersBase);
122 * Unlock all locked layers.
124 UnlockLayers(l->LayerInfo);
126 return TRUE;
128 AROS_LIBFUNC_EXIT
129 } /* UpfrontLayer */