Include <X11/Xlib.h> even if USE_VIDMODE is
[tangerine.git] / rom / hyperlayers / movelayerinfrontof.c
blob7eb0c7e883b1b3ba98c5bed9e0c1d8f253fdb559
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/libcall.h>
10 #include <proto/layers.h>
11 #include <proto/graphics.h>
12 #include <graphics/clip.h>
13 #include <graphics/layers.h>
14 #include "layers_intern.h"
16 /*****************************************************************************
18 NAME */
19 #include <proto/layers.h>
21 AROS_LH2(LONG, MoveLayerInFrontOf,
23 /* SYNOPSIS */
24 AROS_LHA(struct Layer *, layer_to_move, A0),
25 AROS_LHA(struct Layer *, other_layer, A1),
27 /* LOCATION */
28 struct LayersBase *, LayersBase, 28, Layers)
30 /* FUNCTION
31 Moves layer directly in front of another layer. Other layers
32 might become visible. You cannot move a backdrop layer in front
33 of a non-backdrop layer. You can also not move a layer in front
34 of a layer with different relationship to the root layer. Boot
35 have to be children of grandchildren or grandgrandchildren etc.
36 of the root layer. The root layer is not visible to you and
37 should never be accessed.
38 If parts of a simple layer become visible these areas are added
39 to the damage list.
41 INPUTS
42 layer_to_move - pointer to layer that is to be moved
43 other_layer - pointer to other layer that will be behind the
44 layer_to_move.
46 RESULT
47 TRUE - layer was moved
48 FALSE - layer could not be moved. (probably out of memory)
50 NOTES
52 EXAMPLE
54 BUGS
56 SEE ALSO
58 INTERNALS
60 HISTORY
61 27-11-96 digulla automatically created from
62 layers_lib.fd and clib/layers_protos.h
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
67 AROS_LIBBASE_EXT_DECL(struct LayersBase *,LayersBase)
69 struct Layer * first, *_l;
70 int toback = TRUE;
71 LONG ret;
73 if (layer_to_move->parent != other_layer->parent ||
74 layer_to_move->priority < other_layer->priority)
75 return FALSE;
77 LockLayers(layer_to_move->LayerInfo);
79 first = GetFirstFamilyMember(layer_to_move);
81 _l = layer_to_move->parent->front;
82 while (1)
85 * If I run into the other layer before I find l
86 * then I know I have to move it to the back.
87 */
88 if (_l == other_layer)
89 break;
91 if (_l == layer_to_move)
93 toback = FALSE;
94 break;
96 _l = _l->front;
97 if (NULL == _l)
99 UnlockLayers(layer_to_move->LayerInfo);
100 return FALSE;
104 _l = GetFirstFamilyMember(other_layer);
106 if (TRUE == toback)
109 * If the topmost child of the other layer is
110 * behind my layer I don't have to do anything.
112 if (layer_to_move->back == _l)
114 UnlockLayers(layer_to_move->LayerInfo);
115 return TRUE;
117 ret = _MoveLayerBehind(layer_to_move, _l, LayersBase);
119 else
121 ret = _MoveLayerToFront(layer_to_move, _l, LayersBase);
124 UnlockLayers(layer_to_move->LayerInfo);
125 return ret;
127 AROS_LIBFUNC_EXIT
128 } /* MoveLayerInFrontOf */