2 Copyright 1995-2007, 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 *****************************************************************************/
76 struct ScreenDepthActionMsg msg
;
78 FireScreenNotifyMessageCode((IPTR
) screen
, flags
, SNOTIFY_SCREENDEPTH
, IntuitionBase
);
80 if (reserved
!= NULL
) return;
85 DoASyncAction((APTR
)int_screendepth
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
91 /*****************************************************************************************/
93 static VOID
int_screendepth(struct ScreenDepthActionMsg
*msg
,
94 struct IntuitionBase
*IntuitionBase
)
96 struct Screen
*screen
= msg
->screen
;
97 ULONG flags
= msg
->flags
;
98 ULONG ilock
= LockIBase(0); /* before access to FirstScreen */
99 struct Screen
*family
= NULL
,
100 *current
= IntuitionBase
->FirstScreen
,
108 /* Find the screen in the list and check for family */
109 while ( current
&& current
!=screen
)
111 if ( flags
& SDEPTH_INFAMILY
)
113 /* Check if this is the first child in a family */
114 if ( !family
&& (GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
) )
117 prefamily
= previous
;
119 /* Check if this screen is a child so next one belongs to current family */
120 if ( family
&& !(GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
) )
127 current
= current
->NextScreen
;
132 if ( ! (flags
& SDEPTH_TOBACK
) ) /* SDEPTH_TOFRONT is #defined as 0 */
134 if ( previous
) /* I'm not the very first screen */
136 if ( flags
& SDEPTH_INFAMILY
)
138 if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
)
139 { /* Move me in the front of my family */
140 if ( family
) /* I'm not the first one in my family */
142 previous
->NextScreen
= current
->NextScreen
;
143 current
->NextScreen
= family
;
146 prefamily
->NextScreen
= current
;
150 IntuitionBase
->FirstScreen
= current
;
154 else if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
155 { /* Move whole family */
156 if ( prefamily
) /* We are not the first family */
158 prefamily
->NextScreen
= current
->NextScreen
;
159 current
->NextScreen
= IntuitionBase
->FirstScreen
;
160 IntuitionBase
->FirstScreen
= family
;
164 { /* I have no family */
165 previous
->NextScreen
= current
->NextScreen
;
166 current
->NextScreen
= IntuitionBase
->FirstScreen
;
167 IntuitionBase
->FirstScreen
= current
;
170 } /* SDEPTH_INFAMILY */
173 if ( GetPrivScreen(current
)->SpecialFlags
& (SF_IsChild
|SF_IsParent
) )
174 { /* Move my whole family */
177 prefamily
= previous
;
181 { /* We are not the first family */
182 while ( !(GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
) )
184 current
= current
->NextScreen
;
186 prefamily
->NextScreen
= current
->NextScreen
;
187 current
->NextScreen
= IntuitionBase
->FirstScreen
;
188 IntuitionBase
->FirstScreen
= family
;
192 { /* I have no family */
193 previous
->NextScreen
= current
->NextScreen
;
194 current
->NextScreen
= IntuitionBase
->FirstScreen
;
195 IntuitionBase
->FirstScreen
= current
;
198 } /* ! SDEPTH_INFAMILY */
200 } /* if (previous) */
202 } /* if SDEPTH_TO_FRONT */
204 else if ( flags
& SDEPTH_TOBACK
)
206 if ( flags
& SDEPTH_INFAMILY
)
208 if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsChild
)
210 /* Go to last screen of this family */
211 while ( !GetPrivScreen(current
->NextScreen
)->SpecialFlags
& SF_IsParent
)
213 current
= current
->NextScreen
;
215 if ( current
!= screen
) /* I'm not the last screen of my family */
219 previous
->NextScreen
= screen
->NextScreen
;
223 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
225 screen
->NextScreen
= current
->NextScreen
;
226 current
->NextScreen
= screen
;
229 else if ( GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
231 if ( current
->NextScreen
) /* I'm not the last screen */
233 while ( current
->NextScreen
)
235 current
= current
->NextScreen
;
239 prefamily
->NextScreen
= screen
->NextScreen
;
243 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
247 current
->NextScreen
= family
;
251 current
->NextScreen
= screen
;
253 screen
->NextScreen
= NULL
;
258 if ( current
->NextScreen
) /* I'm not the last screen */
260 while ( current
->NextScreen
)
262 current
= current
->NextScreen
;
266 previous
->NextScreen
= screen
->NextScreen
;
270 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
272 current
->NextScreen
= screen
;
273 screen
->NextScreen
= NULL
;
277 } /* SDEPTH_INFAMILY */
282 if ( GetPrivScreen(current
)->SpecialFlags
& (SF_IsChild
|SF_IsParent
) )
287 prefamily
= previous
;
289 /* Go to last screen of this family */
290 while ( !GetPrivScreen(current
)->SpecialFlags
& SF_IsParent
)
292 current
= current
->NextScreen
;
294 if ( current
->NextScreen
) /* We are not the last family */
296 last
= current
->NextScreen
;
297 while ( last
->NextScreen
)
299 last
= last
->NextScreen
;
303 prefamily
->NextScreen
= current
->NextScreen
;
307 IntuitionBase
->FirstScreen
= current
->NextScreen
;
309 last
->NextScreen
= family
;
310 current
->NextScreen
= NULL
;
313 } /* if ( GetPrivScreen(current)->SpecialFlags & (SF_IsChild|SF_IsParent) ) */
316 if ( current
->NextScreen
) /* I'm not the last screen */
318 while ( current
->NextScreen
)
320 current
= current
->NextScreen
;
324 previous
->NextScreen
= screen
->NextScreen
;
328 IntuitionBase
->FirstScreen
= screen
->NextScreen
;
330 current
->NextScreen
= screen
;
331 screen
->NextScreen
= NULL
;
334 } /* current not SF_isChild | SF_IsParent */
336 } /* ! SDEPTH_INFAMILY */
338 } /* if SDEPTH_TO_BACK */
343 IntuitionBase
->ActiveScreen
= IntuitionBase
->FirstScreen
;
346 if (IntuitionBase
->FirstScreen
!= oldfront
)
348 SetFrontBitMap(IntuitionBase
->FirstScreen
->RastPort
.BitMap
, TRUE
);
349 IntuitionBase
->ActiveScreen
= IntuitionBase
->FirstScreen
;
354 #if 0 /* FIXME: backport, disabled */
355 if (IntuitionBase
->FirstScreen
&& GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_Flags
& ICF_SCREENACTIVATION
)
357 struct Window
*scanw
= 0;
359 for (scanw
= IntuitionBase
->FirstScreen
->FirstWindow
; scanw
; scanw
= scanw
->NextWindow
)
363 if ((IW(scanw
)->activationtime
.tv_secs
> IW(win
)->activationtime
.tv_secs
) ||
364 ((IW(scanw
)->activationtime
.tv_secs
== IW(win
)->activationtime
.tv_secs
) && (IW(scanw
)->activationtime
.tv_micro
> IW(win
)->activationtime
.tv_micro
)))
370 if (!win
) win
= scanw
;
373 if (!win
) win
= IntuitionBase
->FirstScreen
->FirstWindow
;
374 if (IntuitionBase
->ActiveWindow
&& IntuitionBase
->ActiveWindow
->WScreen
== IntuitionBase
->FirstScreen
) win
= NULL
;
378 /* now set the default pub screen */
379 /* if the screen is not a public one we just ignore this */
381 if (IntuitionBase
->FirstScreen
&& GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_Flags
& ICF_DEFPUBSCREEN
)
383 if (GetPrivScreen(IntuitionBase
->FirstScreen
)->pubScrNode
&& (IntuitionBase
->FirstScreen
->Flags
& (PUBLICSCREEN
| WBENCHSCREEN
)))
385 GetPrivIBase(IntuitionBase
)->DefaultPubScreen
= IntuitionBase
->FirstScreen
;