2 Copyright 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Change order of screens.
9 #include <proto/graphics.h>
11 #include "intuition_intern.h"
12 #include "inputhandler.h"
13 #include "inputhandler_actions.h"
15 struct ScreenDepthActionMsg
17 struct IntuiActionMsg msg
;
18 struct Screen
*screen
;
22 static VOID
int_screendepth(struct ScreenDepthActionMsg
*msg
,
23 struct IntuitionBase
*IntuitionBase
);
25 /*****************************************************************************
28 #include <proto/intuition.h>
30 AROS_LH3(void, ScreenDepth
,
33 AROS_LHA(struct Screen
*, screen
, A0
),
34 AROS_LHA(ULONG
, flags
, D0
),
35 AROS_LHA(APTR
, reserved
, A1
),
38 struct IntuitionBase
*, IntuitionBase
, 131, Intuition
)
41 Move the specified screen to the front or back, based on passed flag.
42 If the screen is in a group, the screen will change its position in
43 the group only. If the screen is the parent of a group, the whole
47 screen - Move this screen.
48 flags - SDEPTH_TOFRONT or SDEPTH_TOBACK for bringing the screen to
50 If the screen is a child of another screen you may specify
51 SDEPTH_INFAMILY to move the screen within the family. If
52 not specified the whole family will move.
53 reserved - For future use. MUST be NULL by now.
59 Only the owner of the screen should use SDEPTH_INFAMILY.
60 Intentionally commodities should not change the internal arrangement
68 ScreenToBack(), ScreenToFront()
72 *****************************************************************************/
75 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
77 struct ScreenDepthActionMsg msg
;
79 FireScreenNotifyMessageCode((IPTR
) screen
, flags
, SNOTIFY_SCREENDEPTH
, IntuitionBase
);
81 if (reserved
!= NULL
) return;
86 DoASyncAction((APTR
)int_screendepth
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
92 /*****************************************************************************************/
94 static VOID
int_screendepth(struct ScreenDepthActionMsg
*msg
,
95 struct IntuitionBase
*IntuitionBase
)
97 struct Screen
*screen
= msg
->screen
;
98 ULONG flags
= msg
->flags
;
99 ULONG ilock
= LockIBase(0); /* before access to FirstScreen */
100 struct Screen
*family
= NULL
,
101 *current
= IntuitionBase
->FirstScreen
,
109 /* Find the screen in the list and check for family */
110 while ( current
&& current
!=screen
)
112 if ( flags
& SDEPTH_INFAMILY
)
114 /* Check if this is the first child in a family */
115 if ( !family
&& (GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
) )
118 prefamily
= previous
;
120 /* Check if this screen is a child so next one belongs to current family */
121 if ( family
&& !(GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
) )
128 current
= current
->NextScreen
;
133 if ( ! (flags
& SDEPTH_TOBACK
) ) /* SDEPTH_TOFRONT is #defined as 0 */
135 if ( previous
) /* I'm not the very first screen */
137 if ( flags
& SDEPTH_INFAMILY
)
139 if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
)
140 { /* Move me in the front of my family */
141 if ( family
) /* I'm not the first one in my family */
143 previous
->NextScreen
= current
->NextScreen
;
144 current
->NextScreen
= family
;
147 prefamily
->NextScreen
= current
;
151 IntuitionBase
->FirstScreen
= current
;
155 else if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
156 { /* Move whole family */
157 if ( prefamily
) /* We are not the first family */
159 prefamily
->NextScreen
= current
->NextScreen
;
160 current
->NextScreen
= IntuitionBase
->FirstScreen
;
161 IntuitionBase
->FirstScreen
= family
;
165 { /* I have no family */
166 previous
->NextScreen
= current
->NextScreen
;
167 current
->NextScreen
= IntuitionBase
->FirstScreen
;
168 IntuitionBase
->FirstScreen
= current
;
171 } /* SDEPTH_INFAMILY */
174 if ( GetPrivScreen(current
)->SpecialFlags
& (SF_IsChild
|SF_IsParent
) )
175 { /* Move my whole family */
178 prefamily
= previous
;
182 { /* We are not the first family */
183 while ( !(GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
) )
185 current
= current
->NextScreen
;
187 prefamily
->NextScreen
= current
->NextScreen
;
188 current
->NextScreen
= IntuitionBase
->FirstScreen
;
189 IntuitionBase
->FirstScreen
= family
;
193 { /* I have no family */
194 previous
->NextScreen
= current
->NextScreen
;
195 current
->NextScreen
= IntuitionBase
->FirstScreen
;
196 IntuitionBase
->FirstScreen
= current
;
199 } /* ! SDEPTH_INFAMILY */
201 } /* if (previous) */
203 } /* if SDEPTH_TO_FRONT */
205 else if ( flags
& SDEPTH_TOBACK
)
207 if ( flags
& SDEPTH_INFAMILY
)
209 if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
)
211 /* Go to last screen of this family */
212 while ( !GetPrivScreen(current
->NextScreen
)->SpecialFlags
& SF_IsParent
)
214 current
= current
->NextScreen
;
216 if ( current
!= screen
) /* I'm not the last screen of my family */
220 previous
->NextScreen
= screen
->NextScreen
;
224 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
226 screen
->NextScreen
= current
->NextScreen
;
227 current
->NextScreen
= screen
;
230 else if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
232 if ( current
->NextScreen
) /* I'm not the last screen */
234 while ( current
->NextScreen
)
236 current
= current
->NextScreen
;
240 prefamily
->NextScreen
= screen
->NextScreen
;
244 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
248 current
->NextScreen
= family
;
252 current
->NextScreen
= screen
;
254 screen
->NextScreen
= NULL
;
259 if ( current
->NextScreen
) /* I'm not the last screen */
261 while ( current
->NextScreen
)
263 current
= current
->NextScreen
;
267 previous
->NextScreen
= screen
->NextScreen
;
271 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
273 current
->NextScreen
= screen
;
274 screen
->NextScreen
= NULL
;
278 } /* SDEPTH_INFAMILY */
283 if ( GetPrivScreen(current
)->SpecialFlags
& (SF_IsChild
|SF_IsParent
) )
288 prefamily
= previous
;
290 /* Go to last screen of this family */
291 while ( !GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
293 current
= current
->NextScreen
;
295 if ( current
->NextScreen
) /* We are not the last family */
297 last
= current
->NextScreen
;
298 while ( last
->NextScreen
)
300 last
= last
->NextScreen
;
304 prefamily
->NextScreen
= current
->NextScreen
;
308 IntuitionBase
->FirstScreen
= current
->NextScreen
;
310 last
->NextScreen
= family
;
311 current
->NextScreen
= NULL
;
314 } /* if ( GetPrivScreen(current)->SpecialFlags & (SF_IsChild|SF_IsParent) ) */
317 if ( current
->NextScreen
) /* I'm not the last screen */
319 while ( current
->NextScreen
)
321 current
= current
->NextScreen
;
325 previous
->NextScreen
= screen
->NextScreen
;
329 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
331 current
->NextScreen
= screen
;
332 screen
->NextScreen
= NULL
;
335 } /* current not SF_isChild | SF_IsParent */
337 } /* ! SDEPTH_INFAMILY */
339 } /* if SDEPTH_TO_BACK */
344 IntuitionBase
->ActiveScreen
= IntuitionBase
->FirstScreen
;
347 if (IntuitionBase
->FirstScreen
!= oldfront
)
349 SetFrontBitMap(IntuitionBase
->FirstScreen
->RastPort
.BitMap
, TRUE
);
350 IntuitionBase
->ActiveScreen
= IntuitionBase
->FirstScreen
;
355 #if 0 /* FIXME: backport, disabled */
356 if (IntuitionBase
->FirstScreen
&& GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_Flags
& ICF_SCREENACTIVATION
)
358 struct Window
*scanw
= 0;
360 for (scanw
= IntuitionBase
->FirstScreen
->FirstWindow
; scanw
; scanw
= scanw
->NextWindow
)
364 if ((IW(scanw
)->activationtime
.tv_secs
> IW(win
)->activationtime
.tv_secs
) ||
365 ((IW(scanw
)->activationtime
.tv_secs
== IW(win
)->activationtime
.tv_secs
) && (IW(scanw
)->activationtime
.tv_micro
> IW(win
)->activationtime
.tv_micro
)))
371 if (!win
) win
= scanw
;
374 if (!win
) win
= IntuitionBase
->FirstScreen
->FirstWindow
;
375 if (IntuitionBase
->ActiveWindow
&& IntuitionBase
->ActiveWindow
->WScreen
== IntuitionBase
->FirstScreen
) win
= NULL
;
379 /* now set the default pub screen */
380 /* if the screen is not a public one we just ignore this */
382 if (IntuitionBase
->FirstScreen
&& GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_Flags
& ICF_DEFPUBSCREEN
)
384 if (GetPrivScreen(IntuitionBase
->FirstScreen
)->pubScrNode
&& (IntuitionBase
->FirstScreen
->Flags
& (PUBLICSCREEN
| WBENCHSCREEN
)))
386 GetPrivIBase(IntuitionBase
)->DefaultPubScreen
= IntuitionBase
->FirstScreen
;