2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <exec/memory.h>
8 #include <graphics/layers.h>
9 #include <graphics/gfx.h>
10 #include <intuition/intuition.h>
11 #include <intuition/imageclass.h>
12 #include <intuition/windecorclass.h>
13 #include <intuition/gadgetclass.h>
14 #include <intuition/extensions.h>
15 #include <utility/tagitem.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/utility.h>
19 #include <proto/intuition.h>
20 #include <proto/layers.h>
21 #include <exec/ports.h>
22 #include "intuition_intern.h"
23 #include "inputhandler.h"
24 #include "inputhandler_actions.h"
25 #include "boopsigadgets.h"
28 #include "transplayers.h"
29 #include "intuition_extend.h"
32 #ifndef DEBUG_OpenWindow
33 # define DEBUG_OpenWindow 0
36 #define DEBUG DEBUG_OpenWindow
37 # include <aros/debug.h>
39 struct OpenWindowActionMsg
41 struct IntuiActionMsg msg
;
42 struct Window
*window
;
43 struct BitMap
*bitmap
;
44 struct Hook
*backfillhook
;
46 struct Hook
*shapehook
;
47 struct Layer
*parentlayer
;
52 static VOID
int_openwindow(struct OpenWindowActionMsg
*msg
,
53 struct IntuitionBase
*IntuitionBase
);
55 /*****************************************************************************
59 AROS_LH1(struct Window
*, OpenWindow
,
62 AROS_LHA(struct NewWindow
*, newWindow
, A0
),
65 struct IntuitionBase
*, IntuitionBase
, 34, Intuition
)
68 Opens a new window with the characteristics specified in
72 newWindow - How you would like your new window.
75 A pointer to the new window or NULL if it couldn't be
76 opened. Reasons for this might be lack of memory or illegal
86 CloseWindow(), ModifyIDCMP()
90 *****************************************************************************/
94 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
95 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
96 struct OpenWindowActionMsg msg
;
98 struct Window
*w
= NULL
, *helpgroupwindow
= NULL
, *parentwin
= NULL
;
99 struct TagItem
*tag
, *shapeti
= NULL
, *shapehookti
= NULL
;
100 struct TagItem
*tagList
;
102 struct Hook
*backfillhook
= LAYERS_BACKFILL
, *shapehook
= NULL
;
103 struct Region
*shape
= NULL
;
104 struct IBox
*zoombox
= NULL
;
105 struct Image
*AmigaKey
= NULL
;
106 struct Image
*Checkmark
= NULL
;
107 struct Layer
*parentl
= NULL
;
109 struct SkinInfo
*skininfo
= NULL
;
110 BOOL hasskininfo
= FALSE
;
111 struct Region
*usertranspregion
= NULL
;
112 struct Hook
*usertransphook
= NULL
;
113 struct MsgPort
*userport
= NULL
;
115 STRPTR pubScreenName
= NULL
;
116 BOOL pubScreenNameSet
= FALSE
;
117 UBYTE
*screenTitle
= NULL
;
118 BOOL autoAdjust
= FALSE
, pubScreenFallBack
= FALSE
;
119 ULONG innerWidth
= ~0;
120 ULONG innerHeight
= ~0;
121 WORD mousequeue
= DEFAULTMOUSEQUEUE
;
122 WORD repeatqueue
= 3; /* stegerg: test on my Amiga suggests this */
125 ULONG extrabuttons
= 0, extrabuttonsid
= ETI_Dummy
;
127 ULONG windowinvisible
= FALSE
;
128 BOOL driver_init_done
= FALSE
, have_helpgroup
= FALSE
;
129 BOOL do_setwindowpointer
= FALSE
;
131 ASSERT_VALID_PTR_ROMOK(newWindow
);
133 D(bug("OpenWindow (%p = { Left=%d Top=%d Width=%d Height=%d })\n"
135 , newWindow
->LeftEdge
141 FireScreenNotifyMessage((IPTR
) newWindow
, SNOTIFY_BEFORE_OPENWINDOW
, IntuitionBase
);
145 #define WFLG_PRIVATEFLAGS (WFLG_WINDOWREFRESH |\
146 WFLG_WINDOWTICKED | WFLG_VISITOR | \
150 /* WFLG_WBENCHWINDOW | \*/
151 /* this is used by WORKBENCH! */
152 /* WFLG_HASZOOM | \*/
153 /* do NOT filter this! how do you think apps could manage to get a zoom image with struct NewWindow? */
155 nw
.Flags
&= ~WFLG_PRIVATEFLAGS
;
157 if (newWindow
->Flags
& WFLG_NW_EXTENDED
)
159 tagList
= ((struct ExtNewWindow
*)newWindow
)->Extension
;
161 /* Sanitycheck the taglist pointer. Some Am*gaOS 1.3/2.x era
162 * apps have WFLG_NW_EXTENDED set with bogus Extension taglist
163 * pointer... (older CygnusED for example) - Piru
165 if (((IPTR
) tagList
& 1) || !TypeOfMem((APTR
)tagList
))
176 DEBUG_OPENWINDOW(dprintf("OpenWindow: NewWindow 0x%lx TagList 0x%lx\n",
177 newWindow
, tagList
));
181 ASSERT_VALID_PTR_ROMOK(tagList
);
183 /* Look at WA_Flags first, since boolean tags override part of it
184 * even if they appear before it.
186 nw
.Flags
|= (GetTagData(WA_Flags
, nw
.Flags
, tagList
) & ~WFLG_PRIVATEFLAGS
);
188 while ((tag
= NextTagItem (&tagList
)))
190 /* ASSERT_VALID_PTR_ROMOK(tag); */
192 DEBUG_OPENWINDOW(dprintf("OpenWindow: Tag 0x%08lx 0x%08lx\n",
193 tag
->ti_Tag
, tag
->ti_Data
));
198 nw
.LeftEdge
= tag
->ti_Data
;
202 nw
.TopEdge
= tag
->ti_Data
;
206 nw
.Width
= tag
->ti_Data
;
210 nw
.Height
= tag
->ti_Data
;
214 nw
.IDCMPFlags
= tag
->ti_Data
;
218 nw
.MinWidth
= tag
->ti_Data
;
222 nw
.MinHeight
= tag
->ti_Data
;
226 nw
.MaxWidth
= tag
->ti_Data
;
230 nw
.MaxHeight
= tag
->ti_Data
;
234 nw
.FirstGadget
= (struct Gadget
*)(tag
->ti_Data
);
238 nw
.Title
= (UBYTE
*)(tag
->ti_Data
);
242 screenTitle
= (UBYTE
*)tag
->ti_Data
;
246 autoAdjust
= (tag
->ti_Data
!= 0);
250 innerWidth
= tag
->ti_Data
;
254 innerHeight
= tag
->ti_Data
;
257 #define MODIFY_FLAG(name) if (tag->ti_Data) \
258 nw.Flags |= (name); else nw.Flags &= ~(name)
259 #define MODIFY_MFLAG(name) if (tag->ti_Data) \
260 moreFlags |= (name); else moreFlags &= ~(name)
263 MODIFY_FLAG(WFLG_SIZEGADGET
);
267 MODIFY_FLAG(WFLG_DRAGBAR
);
271 MODIFY_FLAG(WFLG_DEPTHGADGET
);
275 MODIFY_FLAG(WFLG_CLOSEGADGET
);
279 MODIFY_FLAG(WFLG_BACKDROP
);
283 MODIFY_FLAG(WFLG_REPORTMOUSE
);
286 case WA_NoCareRefresh
:
287 MODIFY_FLAG(WFLG_NOCAREREFRESH
);
291 MODIFY_FLAG(WFLG_BORDERLESS
);
295 MODIFY_FLAG(WFLG_ACTIVATE
);
299 MODIFY_FLAG(WFLG_RMBTRAP
);
302 case WA_WBenchWindow
:
303 MODIFY_FLAG(WFLG_WBENCHWINDOW
);
307 MODIFY_FLAG(WFLG_SIZEBRIGHT
);
311 MODIFY_FLAG(WFLG_SIZEBBOTTOM
);
314 case WA_GimmeZeroZero
:
315 MODIFY_FLAG(WFLG_GIMMEZEROZERO
);
318 case WA_NewLookMenus
:
319 MODIFY_FLAG(WFLG_NEWLOOKMENUS
);
323 MODIFY_FLAG(WFLG_TOOLBOX
);
327 zoombox
= (struct IBox
*)tag
->ti_Data
;
328 DEBUG_OPENWINDOW(dprintf("OpenWindow: zoom %d %d %d %d\n",
329 zoombox
->Left
, zoombox
->Top
, zoombox
->Width
, zoombox
->Height
));
330 MODIFY_FLAG(WFLG_HASZOOM
);
334 if (nw
.DetailPen
== 0xFF)
335 nw
.DetailPen
= tag
->ti_Data
;
339 if (nw
.BlockPen
== 0xFF)
340 nw
.BlockPen
= tag
->ti_Data
;
343 case WA_CustomScreen
:
344 nw
.Screen
= (struct Screen
*)(tag
->ti_Data
);
345 nw
.Type
= CUSTOMSCREEN
;
349 nw
.Flags
|= WFLG_SUPER_BITMAP
;
350 nw
.BitMap
= (struct BitMap
*)(tag
->ti_Data
);
353 case WA_SimpleRefresh
:
355 nw
.Flags
|= WFLG_SIMPLE_REFRESH
;
358 case WA_SmartRefresh
:
360 nw
.Flags
|= WFLG_SMART_REFRESH
;
363 case WA_PubScreenFallBack
:
364 pubScreenFallBack
= (tag
->ti_Data
? TRUE
: FALSE
);
367 case WA_PubScreenName
:
368 pubScreenNameSet
= TRUE
;
369 pubScreenName
= (STRPTR
)tag
->ti_Data
;
373 nw
.Type
= PUBLICSCREEN
;
374 nw
.Screen
= (struct Screen
*)tag
->ti_Data
;
378 backfillhook
= (struct Hook
*)tag
->ti_Data
;
382 mousequeue
= tag
->ti_Data
;
385 /* These two are not implemented in AmigaOS */
391 MODIFY_MFLAG(WMFLG_NOTIFYDEPTH
);
395 repeatqueue
= tag
->ti_Data
;
399 Checkmark
= (struct Image
*)tag
->ti_Data
;
403 AmigaKey
= (struct Image
*)tag
->ti_Data
;
407 helpgroup
= (ULONG
)tag
->ti_Data
;
408 have_helpgroup
= TRUE
;
411 case WA_HelpGroupWindow
:
412 helpgroupwindow
= (struct Window
*)tag
->ti_Data
;
416 MODIFY_MFLAG(WMFLG_MENUHELP
);
419 case WA_PointerDelay
:
420 MODIFY_MFLAG(WMFLG_POINTERDELAY
);
423 case WA_TabletMessages
:
424 MODIFY_MFLAG(WMFLG_TABLETMESSAGES
);
427 case WA_ExtraTitlebarGadgets
:
428 extrabuttons
= (ULONG
)tag
->ti_Data
;
431 case WA_ExtraGadgetsStartID
:
432 extrabuttonsid
= (ULONG
)tag
->ti_Data
;
435 case WA_ExtraGadget_Iconify
:
438 extrabuttons
|= ETG_ICONIFY
;
442 extrabuttons
&= ~ETG_ICONIFY
;
446 case WA_ExtraGadget_Lock
:
449 extrabuttons
|= ETG_LOCK
;
453 extrabuttons
&= ~ETG_LOCK
;
457 case WA_ExtraGadget_MUI
:
460 extrabuttons
|= ETG_MUI
;
464 extrabuttons
&= ~ETG_MUI
;
468 case WA_ExtraGadget_PopUp
:
471 extrabuttons
|= ETG_POPUP
;
475 extrabuttons
&= ~ETG_POPUP
;
479 case WA_ExtraGadget_Snapshot
:
482 extrabuttons
|= ETG_SNAPSHOT
;
486 extrabuttons
&= ~ETG_SNAPSHOT
;
490 case WA_ExtraGadget_Jump
:
493 extrabuttons
|= ETG_JUMP
;
497 extrabuttons
&= ~ETG_JUMP
;
503 skininfo
= (struct SkinInfo
*)tag
->ti_Data
;
507 case WA_TransparentRegion
:
508 usertranspregion
= (struct Region
*)tag
->ti_Data
;
509 usertransphook
= NULL
; //doesn't make sense
512 case WA_TransparentRegionHook
:
513 usertransphook
= (struct Hook
*)tag
->ti_Data
;
514 usertranspregion
= NULL
;
518 userport
= (struct MsgPort
*)tag
->ti_Data
;
520 /**********************************************************************************/
523 MODIFY_MFLAG(WMFLG_IAMMUI
);
530 shape
= (struct Region
*)tag
->ti_Data
;
535 shapehook
= (struct Hook
*)tag
->ti_Data
;
540 parentwin
= ((struct Window
*)tag
->ti_Data
);
541 parentl
= parentwin
->WLayer
;
545 windowinvisible
= tag
->ti_Data
;
551 do_setwindowpointer
= TRUE
;
556 } /* while ((tag = NextTagItem (&tagList))) */
560 if (nw
.Flags
& WFLG_SIZEGADGET
)
562 if (!(nw
.Flags
& (WFLG_SIZEBRIGHT
| WFLG_SIZEBBOTTOM
)))
564 nw
.Flags
|= WFLG_SIZEBRIGHT
;
567 //jDc: tested behavior of intuition68k
568 nw
.Flags
|= WFLG_HASZOOM
;
572 nw
.Flags
&= ~(WFLG_SIZEBRIGHT
|WFLG_SIZEBBOTTOM
);
575 if (nw
.Flags
& WFLG_BORDERLESS
)
577 nw
.Flags
&= ~(WFLG_SIZEBRIGHT
|WFLG_SIZEBBOTTOM
|WFLG_SIZEGADGET
);
580 /* Find out on which Screen the window must open */
582 /* (cyfm 03/03/03 check for nw.Type == PUBLICSCREEN as well, some programs
583 * like TurboPrint GraphicPublisher specify {WA_PubScreen, NULL} and want
584 * to open on the default public screen that way
586 if (pubScreenNameSet
|| (nw
.Type
== PUBLICSCREEN
&& nw
.Screen
== NULL
))
588 struct Screen
*pubs
= 0;
590 moreFlags
|= WMFLG_DO_UNLOCKPUBSCREEN
;
591 pubs
= LockPubScreen(pubScreenName
);
592 if (!pubs
&& pubScreenFallBack
)
594 nw
.Screen
= LockPubScreen(NULL
);
600 nw
.Type
= PUBLICSCREEN
;
601 if (nw
.Screen
) nw
.Flags
|= WFLG_VISITOR
;
603 else if (nw
.Type
== PUBLICSCREEN
)
605 /* There is no LockPubScreen() with a "struct Screen *" argument, so we have to do
606 * the necessary steps ourself
609 if (GetPrivScreen(nw
.Screen
)->pubScrNode
)
611 GetPrivScreen(nw
.Screen
)->pubScrNode
->psn_VisitorCount
++;
612 moreFlags
|= WMFLG_DO_UNLOCKPUBSCREEN
;
613 nw
.Flags
|= WFLG_VISITOR
;
614 FireScreenNotifyMessage((IPTR
) nw
.Screen
, SNOTIFY_LOCKPUBSCREEN
, IntuitionBase
);
618 /* The screen wasn't a PublicScreen */
619 UnlockPubScreenList();
620 D(bug("OpenWindow: Not a PublicScreen\n"));
623 UnlockPubScreenList();
626 if (nw
.Type
== WBENCHSCREEN
)
628 nw
.Screen
= LockPubScreen("Workbench");
631 moreFlags
|= WMFLG_DO_UNLOCKPUBSCREEN
;
632 nw
.Flags
|= WFLG_VISITOR
;
636 if (nw
.Screen
== NULL
) {
637 D(bug("OpenWindow: No screen\n"));
641 w
= AllocMem (sizeof(struct IntWindow
), MEMF_CLEAR
);
643 DEBUG_OPENWINDOW(dprintf("OpenWindow: Window 0x%lx\n", w
));
645 /* nlorentz: For now, creating a rastport becomes the responsibility of
646 intui_OpenWindow(). This is because intui_OpenWindow() in
647 config/hidd/intuition_driver.c must call CreateUpfrontLayer(),
648 and that will create a rastport for the layer/window, and we don't
649 want two rastports pr. window.
650 Alternatively we may create a layers_driver.c driver for layers,
651 and then call CreateUpfrontLayer() here from openwindow.
652 For the Amiga window<-->X11 window stuff, the layers driver
653 would just allocate a layer struct, a rastport and
654 put the rasport into layer->RastPort, so we
655 could get it inside this routine and put it into
661 D(bug("OpenWindow: No window\n"));
665 DEBUG_OPENWINDOW(dprintf("OpenWindow: Flags 0x%lx MoreFlags 0x%lx IDCMP 0x%lx\n",
666 nw
.Flags
, moreFlags
, nw
.IDCMPFlags
));
669 GetAttr(WDA_UserBuffer
, ((struct IntScreen
*)(nw
.Screen
))->WinDecorObj
, &userbuffersize
);
673 ((struct IntWindow
*)w
)->DecorUserBufferSize
= userbuffersize
;
674 ((struct IntWindow
*)w
)->DecorUserBuffer
= (IPTR
) AllocMem(userbuffersize
, MEMF_ANY
| MEMF_CLEAR
);
675 if (0 == ((struct IntWindow
*)w
)->DecorUserBuffer
) {
676 D(bug("OpenWindow: No decor\n"));
681 struct wdpInitWindow initmsg
;
684 initmsg
.MethodID
= WDM_INITWINDOW
;
685 initmsg
.wdp_TrueColor
= (((struct IntScreen
*) nw
.Screen
)->DInfo
.dri
.dri_Flags
& DRIF_DIRECTCOLOR
);
686 initmsg
.wdp_UserBuffer
= ((struct IntWindow
*)w
)->DecorUserBuffer
;
687 initmsg
.wdp_ScreenUserBuffer
= ((struct IntScreen
*) nw
.Screen
)->DecorUserBuffer
;
688 initmsg
.wdp_Screen
= nw
.Screen
;
690 ok
= DoMethodA(((struct IntScreen
*)(nw
.Screen
))->WinDecorObj
, (Msg
)&initmsg
);
693 D(bug("OpenWindow: WDM_INITWINDOW failed\n"));
697 w
->WScreen
= nw
.Screen
;
702 w
->UserPort
= userport
;
703 ((struct IntWindow
*)w
)->specialflags
|= SPFLAG_USERPORT
;
707 if (!ModifyIDCMP (w
, nw
.IDCMPFlags
)) {
708 D(bug("OpenWindow: ModifyIDCMP failed\n"));
712 ((struct IntWindow
*)w
)->extrabuttons
= extrabuttons
;
713 ((struct IntWindow
*)w
)->extrabuttonsid
= extrabuttonsid
;
717 //w->FirstGadget = nw.FirstGadget;
719 w
->DetailPen
= (nw
.DetailPen
!= 0xFF) ? nw
.DetailPen
: w
->WScreen
->DetailPen
;
720 w
->BlockPen
= (nw
.BlockPen
!= 0xFF) ? nw
.BlockPen
: w
->WScreen
->BlockPen
;
724 w
->MoreFlags
= moreFlags
;
726 if (!(w
->Flags
& WFLG_BORDERLESS
))
728 w
->BorderLeft
= w
->WScreen
->WBorLeft
;
729 w
->BorderRight
= w
->WScreen
->WBorRight
;
731 w
->BorderTop
= w
->WScreen
->WBorBottom
;
733 w
->BorderTop
= w
->WScreen
->WBorTop
;
735 w
->BorderBottom
= w
->WScreen
->WBorBottom
;
738 if (nw
.Title
|| (w
->Flags
& (WFLG_DRAGBAR
| WFLG_CLOSEGADGET
| WFLG_DEPTHGADGET
)))
740 /* this is a hack. the correct way to "correct" (increase if necessary)
741 the w->Border??? items would be to check all GACT_???BORDER gadgets
742 (inclusive sysgadgets which are GACT_????BORDER gadgets as well) in
743 nw.FirstGadget (or WA_Gadgets tag) and all sysgadgets and then
744 make sure that each window border is big enough so that none of these
745 gadgets extends outside the window border area */
748 w
->BorderTop
= w
->WScreen
->WBorTop
;
750 /* Georg Steger: ??? font ??? */
751 if (w
->WScreen
->Font
)
752 w
->BorderTop
+= ((struct IntScreen
*)(w
->WScreen
))->DInfo
.dri
.dri_Font
->tf_YSize
+ 1;
754 w
->BorderTop
+= GfxBase
->DefaultFont
->tf_YSize
+ 1;
759 struct windowclassprefs
*wcprefs
;
760 struct IntDrawInfo
*dri
;
761 if ((dri
= (struct IntDrawInfo
*)GetScreenDrawInfo(w
->WScreen
)))
763 wcprefs
= (struct windowclassprefs
*)int_GetCustomPrefs(TYPE_WINDOWCLASS
,dri
,IntuitionBase
);
764 w
->BorderTop
+= wcprefs
->titlebarincrement
;
765 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,dri
,IntuitionBase
);
772 /* look for GACT_???BORDER gadgets which increase the BorderSizes */
778 for(gad
= nw
.FirstGadget
; gad
; gad
= gad
->NextGadget
)
780 WORD gadx1
, gady1
, gadx2
, gady2
;
782 if (gad
->Activation
& GACT_LEFTBORDER
)
784 /* may never be GFLG_RELRIGHT / GFLG_RELWIDTH */
786 gadx2
= gad
->LeftEdge
+ gad
->Width
- 1;
787 if (gadx2
>= w
->BorderLeft
) w
->BorderLeft
= gadx2
/* + 1*/;
790 if (gad
->Activation
& GACT_TOPBORDER
)
792 /* may never be GFLG_RELBOTTOM / GFLG_RELHEIGHT */
794 gady2
= gad
->TopEdge
+ gad
->Height
- 1;
795 if (gady2
>= w
->BorderTop
) w
->BorderTop
= gady2
/* + 1*/;
798 if (gad
->Activation
& GACT_RIGHTBORDER
)
800 /* must be GFLG_RELRIGHT but never GFLG_RELWIDTH */
802 gadx1
= -gad
->LeftEdge
;
803 if (gadx1
>= w
->BorderRight
) w
->BorderRight
= gadx1
/* + 1*/;
806 if (gad
->Activation
& GACT_BOTTOMBORDER
)
808 /* must be GFLG_RELBOTTOM but never GFLG_RELHEIGHT */
810 gady1
= -gad
->TopEdge
;
811 if (gady1
>= w
->BorderBottom
) w
->BorderBottom
= gady1
/* + 1*/;
814 } /* for(gad = nw.FirstGadget; gad; gad = gad->NextGadget) */
816 } /* if (nw.FirstGadget) */
818 if (!(w
->Flags
& WFLG_SIZEBRIGHT
)) if (w
->BorderRight
> w
->WScreen
->WBorRight
)
820 w
->Flags
|= WFLG_SIZEBRIGHT
;
823 if (!(w
->Flags
& WFLG_SIZEBBOTTOM
)) if (w
->BorderBottom
> w
->WScreen
->WBorBottom
)
825 w
->Flags
|= WFLG_SIZEBBOTTOM
;
829 // if ((w->Flags & WFLG_SIZEGADGET) &&
830 // (w->Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
832 IPTR sizewidth
= 16, sizeheight
= 16;
834 struct DrawInfo
*dri
;
836 if ((dri
= GetScreenDrawInfo(w
->WScreen
)))
838 struct TagItem imtags
[] =
840 {SYSIA_DrawInfo
, (STACKIPTR
)dri
},
841 {SYSIA_Which
, SIZEIMAGE
},
842 {SYSIA_Size
, w
->WScreen
->Flags
& SCREENHIRES
? SYSISIZE_MEDRES
: SYSISIZE_LOWRES
},
846 if ((im
= NewObjectA(NULL
, SYSICLASS
, imtags
)))
848 GetAttr(IA_Width
, (Object
*)im
, &sizewidth
);
849 GetAttr(IA_Height
, (Object
*)im
, &sizeheight
);
853 FreeScreenDrawInfo(w
->WScreen
, dri
);
856 if (w
->Flags
& WFLG_SIZEBRIGHT
)
858 if (w
->BorderRight
< sizewidth
) w
->BorderRight
= sizewidth
;
861 if (w
->Flags
& WFLG_SIZEBBOTTOM
)
863 if (w
->BorderBottom
< sizeheight
) w
->BorderBottom
= sizeheight
;
866 IW(w
)->sizeimage_width
= sizewidth
;
867 IW(w
)->sizeimage_height
= sizeheight
;
869 /* now increase window size if it's necessary */
874 IW(w
)->custombackfill
.h_Entry
= (HOOKFUNC
)HookEntry
;
875 IW(w
)->custombackfill
.h_SubEntry
= (HOOKFUNC
)GradientizeBackfillFunc
;
876 IW(w
)->custombackfill
.h_Data
= &IW(w
)->hd
;
877 IW(w
)->hd
.intuitionBase
= IntuitionBase
;
879 IW(w
)->usertranspregion
= usertranspregion
;
880 IW(w
)->usertransphook
= usertransphook
;
883 IW(w
)->DefaultWindowShapeHook
.h_Entry
= (HOOKFUNC
)DefaultWindowShapeFunc
;
884 IW(w
)->DefaultWindowShapeHook
.h_SubEntry
= (HOOKFUNC
)w
;
885 IW(w
)->DefaultWindowShapeHook
.h_Data
= (APTR
)IntuitionBase
;
887 if (innerWidth
!= ~0) nw
.Width
= innerWidth
+ w
->BorderLeft
+ w
->BorderRight
;
888 if (innerHeight
!= ~0) nw
.Height
= innerHeight
+ w
->BorderTop
+ w
->BorderBottom
;
894 parentwidth
= parentwin
? parentwin
->Width
: w
->WScreen
->Width
;
895 parentheight
= parentwin
? parentwin
->Height
: w
->WScreen
->Height
;
897 w
->Width
= (nw
.Width
!= ~0) ? nw
.Width
: parentwidth
- nw
.LeftEdge
;
898 w
->Height
= (nw
.Height
!= ~0) ? nw
.Height
: parentheight
- nw
.TopEdge
;
903 if (w
->Width
> parentwidth
) w
->Width
= parentwidth
;
904 if (w
->Height
> parentheight
) w
->Height
= parentheight
;
906 if (nw
.LeftEdge
< 0) nw
.LeftEdge
= 0;
907 if (nw
.TopEdge
< 0) nw
.TopEdge
= 0;
909 if ((nw
.LeftEdge
+ w
->Width
) > parentwidth
)
910 nw
.LeftEdge
= parentwidth
- w
->Width
;
912 if ((nw
.TopEdge
+ w
->Height
) > parentheight
)
913 nw
.TopEdge
= parentheight
- w
->Height
;
916 w
->GZZWidth
= w
->Width
- w
->BorderLeft
- w
->BorderRight
;
917 w
->GZZHeight
= w
->Height
- w
->BorderTop
- w
->BorderBottom
;
920 if (nw
.LeftEdge
< 0 || nw
.TopEdge
< 0 ||
921 nw
.LeftEdge
+ w
->Width
> w
->WScreen
->Width
||
922 nw
.TopEdge
+ w
->Height
> w
->WScreen
->Height
) {
923 D(bug("OpenWindow: Window size (%dx%d) @(%d,%d) is weird for a %dx%d screen\n",
924 nw
.LeftEdge
+ w
->Width
, nw
.TopEdge
+ w
->Height
,
925 nw
.LeftEdge
, nw
.TopEdge
,
926 w
->WScreen
->Width
, w
->WScreen
->Height
));
930 if (NULL
== parentwin
)
932 w
->LeftEdge
= nw
.LeftEdge
;
933 w
->TopEdge
= nw
.TopEdge
;
937 w
->LeftEdge
= nw
.LeftEdge
+ parentwin
->LeftEdge
;
938 w
->TopEdge
= nw
.TopEdge
+ parentwin
->TopEdge
;
942 w
->RelLeftEdge
= nw
.LeftEdge
;
943 w
->RelTopEdge
= nw
.TopEdge
;
946 w
->MinWidth
= (nw
.MinWidth
!= 0) ? nw
.MinWidth
: w
->Width
;
947 w
->MinHeight
= (nw
.MinHeight
!= 0) ? nw
.MinHeight
: w
->Height
;
948 w
->MaxWidth
= (nw
.MaxWidth
!= 0) ? nw
.MaxWidth
: w
->Width
;
949 w
->MaxHeight
= (nw
.MaxHeight
!= 0) ? nw
.MaxHeight
: w
->Height
;
951 //jDc: tested behavior of intuition68k
952 if ((UWORD
)w
->MaxWidth
< w
->Width
) w
->MaxWidth
= w
->Width
;
953 if ((UWORD
)w
->MaxHeight
< w
->Height
) w
->MaxHeight
= w
->Height
;
955 /* check if maxwidth/height is not bigger than screen */
956 if (w
->MaxWidth
> w
->WScreen
->Width
) w
->MaxWidth
= w
->WScreen
->Width
;
957 if (w
->MaxHeight
> w
->WScreen
->Height
) w
->MaxHeight
= w
->WScreen
->Height
;
961 ((struct IntWindow
*)w
)->ZipLeftEdge
= zoombox
->Left
;
962 ((struct IntWindow
*)w
)->ZipTopEdge
= zoombox
->Top
;
963 ((struct IntWindow
*)w
)->ZipWidth
= zoombox
->Width
;
964 ((struct IntWindow
*)w
)->ZipHeight
= zoombox
->Height
;
968 ((struct IntWindow
*)w
)->ZipLeftEdge
= nw
.LeftEdge
;
969 ((struct IntWindow
*)w
)->ZipTopEdge
= nw
.TopEdge
;
970 ((struct IntWindow
*)w
)->ZipWidth
= (w
->Width
== w
->MinWidth
) ? w
->MaxWidth
: w
->MinWidth
;
971 ((struct IntWindow
*)w
)->ZipHeight
= (w
->Height
== w
->MinHeight
) ? w
->MaxHeight
: w
->MinHeight
;
974 DEBUG_OPENWINDOW(dprintf("OpenWindow: zip %d %d %d %d\n",
975 ((struct IntWindow
*)w
)->ZipLeftEdge
,
976 ((struct IntWindow
*)w
)->ZipTopEdge
,
977 ((struct IntWindow
*)w
)->ZipWidth
,
978 ((struct IntWindow
*)w
)->ZipHeight
));
981 IW(w
)->mousequeue
= mousequeue
;
982 IW(w
)->repeatqueue
= repeatqueue
;
984 /* Amiga and checkmark images for menus */
986 IW(w
)->Checkmark
= Checkmark
? Checkmark
:
987 ((struct IntScreen
*)(w
->WScreen
))->DInfo
.dri
.dri_CheckMark
;
989 IW(w
)->AmigaKey
= AmigaKey
? AmigaKey
:
990 ((struct IntScreen
*)(w
->WScreen
))->DInfo
.dri
.dri_AmigaKey
;
991 IW(w
)->SubMenuImage
= ((struct IntScreen
*)(w
->WScreen
))->DInfo
.dri
.dri_SubMenuImage
;
995 if (NULL
!= parentwin
)
997 if (parentwin
->firstchild
)
998 parentwin
->firstchild
->prevchild
= w
;
1000 w
->nextchild
= parentwin
->firstchild
;
1001 parentwin
->firstchild
= w
;
1002 w
->parent
= parentwin
;
1007 if (hasskininfo
) ((struct IntWindow
*)(w
))->specialflags
= SPFLAG_SKININFO
;
1011 if ((w
->Flags
& WFLG_SIMPLE_REFRESH
) && (IS_DOCAREREFRESH(w
)) && (!(w
->Flags
& WFLG_BORDERLESS
))) IW(w
)->trashregion
= NewRegion();
1016 if (!have_helpgroup
&& helpgroupwindow
)
1018 if (IW(helpgroupwindow
)->helpflags
& HELPF_ISHELPGROUP
)
1020 helpgroup
= IW(helpgroupwindow
)->helpgroup
;
1021 have_helpgroup
= TRUE
;
1027 IW(w
)->helpflags
|= HELPF_ISHELPGROUP
;
1028 IW(w
)->helpgroup
= helpgroup
;
1031 w
->Title
= nw
.Title
;
1036 /* Use safe OpenFont.. - Piru
1039 if (GetPrivScreen(w
->WScreen
)->SpecialFlags
& SF_SysFont
)
1041 w
->IFont
= SafeReopenFont(IntuitionBase
, &GfxBase
->DefaultFont
);
1045 w
->IFont
= SafeReopenFont(IntuitionBase
, &(GetPrivScreen(w
->WScreen
)->DInfo
.dri
.dri_Font
));
1048 if (w
->IFont
== NULL
) {
1049 D(bug("OpenWindow: No font\n"));
1055 #warning: Really hacky way of re-opening GfxBase->DefaultFont
1058 w
->IFont
= GfxBase
->DefaultFont
;
1059 w
->IFont
->tf_Accessors
++;
1064 /* jDc: intui68k waits before opening the window until
1065 ** Move/SizeWindow actions are over (does it mean it's executed on
1066 ** caller's context?).
1069 #ifdef USEWINDOWLOCK
1070 if (!(FindTask(0) == ((struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
)->InputDeviceTask
))
1072 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
1076 IW(w
)->OutlineShape
= NULL
;
1078 if ((shapeti
!= NULL
) || (shapehookti
!= NULL
)) IW(w
)->CustomShape
= TRUE
;
1079 if (!(IW(w
)->CustomShape
) && (!(w
->Flags
& WFLG_BORDERLESS
)) && !IS_GZZWINDOW(w
))
1081 shapehook
= &IW(w
)->DefaultWindowShapeHook
;
1085 msg
.bitmap
= nw
.BitMap
;
1086 //msg.backfillhook = backfillhook == LAYERS_BACKFILL ? &IW(w)->custombackfill : backfillhook;
1087 msg
.backfillhook
= backfillhook
;
1089 msg
.shapehook
= shapehook
;
1090 msg
.parentlayer
= parentl
;
1091 msg
.invisible
= windowinvisible
;
1093 DoSyncAction((APTR
)int_openwindow
, &msg
.msg
, IntuitionBase
);
1095 #ifdef USEWINDOWLOCK
1096 if (!(FindTask(0) == ((struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
)->InputDeviceTask
))
1098 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
1103 D(bug("OpenWindow: DoSyncAction failed\n"));
1107 /* nlorentz: The driver has in some way or another allocated a rastport for us,
1108 which now is ready for us to use. */
1110 driver_init_done
= TRUE
;
1113 D(bug("called driver, rp=%p\n", rp
));
1115 /* The window RastPort always gets the font from GfxBase->DefaultFont, which
1116 is the system's default font. Usually topaz 8, but it can be changed with
1117 the Fonts prefs program to another fixed-sized font. */
1119 SetFont (rp
, w
->IFont
);
1121 D(bug("set fonts\n"));
1123 /* FIXME: Remove workaround! */
1124 /* lbischoff: The following 4 Setxxx lines are a workaround for the InitRastPort
1125 problem (Bug #75 in docs/BUGS). They ensure that at least a window's rastport
1126 is initialized correctly. Remove them if they are not needed any longer!
1128 SetABPenDrMd (rp
, rp
->FgPen
, rp
->BgPen
, rp
->DrawMode
);
1129 SetWriteMask (rp
, rp
->Mask
);
1130 D(bug("set pens\n"));
1133 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
1134 /*DoGMLayout(w->FirstGadget, w, NULL, -1, TRUE, IntuitionBase);
1136 if (NULL != w->FirstGadget)
1137 RefreshGadgets (w->FirstGadget, w, NULL);
1142 struct IntDrawInfo
*dri
= &((struct IntScreen
*)(w
->WScreen
))->DInfo
;
1143 struct wdpLayoutBorderGadgets msg
;
1145 msg
.MethodID
= WDM_LAYOUT_BORDERGADGETS
;
1146 msg
.wdp_UserBuffer
= ((struct IntWindow
*)w
)->DecorUserBuffer
;;
1147 msg
.wdp_TrueColor
= (((struct IntScreen
*)nw
.Screen
)->DInfo
.dri
.dri_Flags
& DRIF_DIRECTCOLOR
);
1149 msg
.wdp_Gadgets
= nw
.FirstGadget
;
1150 msg
.wdp_Flags
= WDF_LBG_INITIAL
| WDF_LBG_MULTIPLE
;
1151 msg
.wdp_ExtraButtons
= ((struct IntWindow
*)w
)->extrabuttons
;
1152 msg
.wdp_Dri
= (struct DrawInfo
*)dri
;
1154 DoMethodA(((struct IntScreen
*)(nw
.Screen
))->WinDecorObj
, (Msg
)&msg
);
1156 AddGList(w
, nw
.FirstGadget
, -1, -1, NULL
);
1160 /* !!! This does double refreshing as the system gadgets also are refreshed
1161 in the above RfreshGadgets() call */
1162 if (nw
.Flags
& WFLG_ACTIVATE
)
1164 /* RefreshWindowFrame() will be called from within ActivateWindow().
1165 No point in doing double refreshing. */
1171 RefreshWindowFrame(w
);
1175 if (screenTitle
!= NULL
)
1176 SetWindowTitles (w
, (CONST_STRPTR
)~0, screenTitle
);
1178 UpdateMouseCoords(w
);
1180 if (do_setwindowpointer
)
1182 //jDc: main for () loop destroys original taglist pointer, we need to get
1183 //it once again here!
1184 tagList
= (struct TagItem
*)((struct ExtNewWindow
*)newWindow
)->Extension
;
1185 SetWindowPointerA(w
, (struct TagItem
*)tagList
);
1189 ((struct IntWindow
*)w
)->OutlineShape
= NULL
;
1191 if ((shape
!= NULL
) || (shapehook
!= NULL
)) ((struct IntWindow
*)w
)->CustomShape
= TRUE
;
1192 if ((!((struct IntWindow
*)w
)->CustomShape
) && (!(w
->Flags
& WFLG_BORDERLESS
)) && !IS_GZZWINDOW(w
))
1194 struct wdpWindowShape shapemsg
;
1196 shapemsg
.MethodID
= WDM_WINDOWSHAPE
;
1197 shapemsg
.wdp_TrueColor
= (((struct IntScreen
*)nw
.Screen
)->DInfo
.dri
.dri_Flags
& DRIF_DIRECTCOLOR
);
1198 shapemsg
.wdp_Width
= w
->Width
;
1199 shapemsg
.wdp_Height
= w
->Height
;
1200 shapemsg
.wdp_Window
= w
;
1201 shapemsg
.wdp_UserBuffer
= ((struct IntWindow
*)w
)->DecorUserBuffer
;
1203 shape
= DoMethodA(((struct IntScreen
*)(nw
.Screen
))->WinDecorObj
, (Msg
)&shapemsg
);
1204 ((struct IntWindow
*)w
)->OutlineShape
= shape
;
1205 ChangeWindowShape(w
, shape
, NULL
);
1206 ((struct IntWindow
*)w
)->CustomShape
= FALSE
;
1219 /* nlorentz: Freeing the rasport is now intui_CloseWindow()'s task.
1227 if (driver_init_done
)
1228 intui_CloseWindow(w
, IntuitionBase
);
1230 if (w
->IFont
) CloseFont(w
->IFont
);
1232 if (((struct IntWindow
*)w
)->DecorUserBuffer
)
1234 FreeMem((APTR
)((struct IntWindow
*)w
)->DecorUserBuffer
, ((struct IntWindow
*)w
)->DecorUserBufferSize
);
1237 FreeMem (w
, sizeof(struct IntWindow
));
1242 if (nw
.Screen
&& (moreFlags
& WMFLG_DO_UNLOCKPUBSCREEN
))
1244 UnlockPubScreen(NULL
, nw
.Screen
);
1249 DEBUG_OPENWINDOW(dprintf("OpenWindow: Return 0x%lx\n", w
));
1251 FireScreenNotifyMessage((IPTR
) w
, SNOTIFY_AFTER_OPENWINDOW
, IntuitionBase
);
1253 ReturnPtr ("OpenWindow", struct Window
*, w
);
1259 /**********************************************************************************/
1261 static VOID
int_openwindow(struct OpenWindowActionMsg
*msg
,
1262 struct IntuitionBase
*IntuitionBase
)
1264 struct GfxBase
* GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
1265 struct LayersBase
* LayersBase
= GetPrivIBase(IntuitionBase
)->LayersBase
;
1266 struct Window
* w
= msg
->window
;
1267 struct BitMap
* SuperBitMap
= msg
->bitmap
;
1268 struct Hook
* backfillhook
= msg
->backfillhook
;
1269 struct Region
* shape
= msg
->shape
;
1270 struct Hook
* shapehook
= msg
->shapehook
;
1271 struct Layer
* parent
= msg
->parentlayer
;
1272 BOOL invisible
= msg
->invisible
;
1275 BOOL installtransphook
= FALSE
;
1276 BOOL notransphook
= TRUE
;
1279 /* Create a layer for the window */
1280 LONG layerflags
= 0;
1282 EnterFunc(bug("int_OpenWindow(w=%p)\n", w
));
1284 D(bug("screen: %p\n", w
->WScreen
));
1285 D(bug("bitmap: %p\n", w
->WScreen
->RastPort
.BitMap
));
1287 /* Just insert some default values, should be taken from
1288 w->WScreen->WBorxxxx */
1290 /* Set the layer's flags according to the flags of the
1295 if (w
->Flags
& WFLG_SIMPLE_REFRESH
)
1297 layerflags
|= LAYERSIMPLE
;
1301 if (w
->Flags
& WFLG_SUPER_BITMAP
&& SuperBitMap
)
1303 layerflags
|= LAYERSUPER
;
1307 layerflags
|= LAYERSMART
;
1311 if (w
->Flags
& WFLG_BACKDROP
)
1313 layerflags
|= LAYERBACKDROP
;
1316 D(bug("Window dims: (%d, %d, %d, %d)\n",
1317 w
->LeftEdge
, w
->TopEdge
, w
->Width
, w
->Height
));
1320 //install transp layer hook!
1322 struct windowclassprefs
*wcprefs
= NULL
;
1324 wcprefs
= (struct windowclassprefs
*)int_GetCustomPrefs(TYPE_WINDOWCLASS
,&((struct IntScreen
*)(w
->WScreen
))->DInfo
,IntuitionBase
);
1325 if (wcprefs
->flags
& WINDOWCLASS_PREFS_ROUNDEDEDGES
&& (w
->Title
|| (w
->Flags
& (WFLG_DRAGBAR
| WFLG_CLOSEGADGET
| WFLG_DEPTHGADGET
))))
1327 IW(w
)->transpregion
= NewRegion();
1328 if (IW(w
)->transpregion
)
1330 installtransphook
= TRUE
; notransphook
= FALSE
;
1331 IW(w
)->specialflags
|= SPFLAG_TRANSPHOOK
;
1336 if (IW(w
)->usertransphook
)
1338 IW(w
)->transpregion
= NewRegion();
1339 if (IW(w
)->transpregion
)
1341 installtransphook
= TRUE
;
1342 IW(w
)->specialflags
|= SPFLAG_TRANSPHOOK
;
1345 else if (IW(w
)->usertranspregion
)
1347 IW(w
)->transpregion
= NewRegion();
1348 if (IW(w
)->transpregion
)
1350 installtransphook
= TRUE
;
1351 IW(w
)->specialflags
|= SPFLAG_TRANSPHOOK
;
1355 int_FreeCustomPrefs(TYPE_SYSICLASS
,&((struct IntScreen
*)(w
->WScreen
))->DInfo
,IntuitionBase
);
1359 // LockLayers(&w->WScreen->LayerInfo);
1361 /* A GimmeZeroZero window??? */
1362 if (w
->Flags
& WFLG_GIMMEZEROZERO
)
1365 A GimmeZeroZero window is to be created:
1366 - the outer window will be a simple refresh layer
1367 - the inner window will be a layer according to the flags
1368 What is the size of the inner/outer window supposed to be???
1369 I just make it that the outer window has the size of what is requested
1372 struct TagItem layertags
[] =
1374 {LA_BackfillHook
, (IPTR
)LAYERS_NOBACKFILL
},
1375 {SuperBitMap
? LA_SuperBitMap
: TAG_IGNORE
, (IPTR
)SuperBitMap
},
1377 {installtransphook
? LA_TransHook
: TAG_IGNORE
, notransphook
? (IPTR
)&((struct IntIntuitionBase
*)(IntuitionBase
))->notransphook
: (IPTR
)&((struct IntIntuitionBase
*)(IntuitionBase
))->transphook
},
1378 {installtransphook
? LA_TransRegion
: TAG_IGNORE
, (IPTR
)IW(w
)->transpregion
},
1383 {LA_WindowPtr
, (IPTR
)w
},
1384 {LA_ChildOf
, (IPTR
)parent
}, /* These two are AROS-specific */
1385 {LA_Hidden
, invisible
},
1389 /* First create outer window */
1390 struct Layer
* L
= CreateUpfrontLayerTagList(
1391 &w
->WScreen
->LayerInfo
1392 , w
->WScreen
->RastPort
.BitMap
1395 , w
->LeftEdge
+ w
->Width
- 1
1396 , w
->TopEdge
+ w
->Height
- 1
1397 , LAYERSIMPLE
| (layerflags
& LAYERBACKDROP
)
1398 , (struct TagItem
*)&layertags
);
1400 /* Could the layer be created. Nothing bad happened so far, so simply leave */
1403 msg
->success
= FALSE
;
1404 // UnlockLayers(&w->WScreen->LayerInfo);
1405 ReturnVoid("intui_OpenWindow(No GimmeZeroZero layer)");
1408 D(bug("created outer GimmeZeroZero layer.\n"));
1410 /* install it as the BorderRPort */
1411 w
->BorderRPort
= L
->rp
;
1414 /* Now comes the inner window */
1415 layertags
[0].ti_Data
= (IPTR
)backfillhook
;
1418 layertags
[2].ti_Tag
= LA_ShapeHook
;
1419 layertags
[2].ti_Data
= (IPTR
)shapehook
;
1423 layertags
[3].ti_Tag
= LA_ShapeRegion
;
1424 layertags
[3].ti_Data
= (IPTR
)shape
;
1427 w
->WLayer
= CreateUpfrontLayerTagList(
1428 &w
->WScreen
->LayerInfo
1429 , w
->WScreen
->RastPort
.BitMap
1430 , w
->LeftEdge
+ w
->BorderLeft
1431 , w
->TopEdge
+ w
->BorderTop
1432 , w
->LeftEdge
+ w
->BorderLeft
+ w
->GZZWidth
- 1
1433 , w
->TopEdge
+ w
->BorderTop
+ w
->GZZHeight
- 1
1435 , (struct TagItem
*)&layertags
);
1437 /* could this layer be created? If not then delete the outer window and exit */
1438 if (NULL
== w
->WLayer
)
1441 msg
->success
= FALSE
;
1442 // UnlockLayers(&w->WScreen->LayerInfo);
1443 ReturnVoid("intui_OpenWindow(No window layer)");
1446 /* That should do it, I guess... */
1450 struct TagItem layertags
[] =
1452 {LA_BackfillHook
, (IPTR
)backfillhook
},
1453 {SuperBitMap
? LA_SuperBitMap
: TAG_IGNORE
, (IPTR
)SuperBitMap
},
1455 {installtransphook
? LA_TransHook
: TAG_IGNORE
, notransphook
? (IPTR
)&((struct IntIntuitionBase
*)(IntuitionBase
))->notransphook
: (IPTR
)&((struct IntIntuitionBase
*)(IntuitionBase
))->transphook
},
1456 {installtransphook
? LA_TransRegion
: TAG_IGNORE
, (IPTR
)IW(w
)->transpregion
},
1461 {LA_WindowPtr
, (IPTR
)w
},
1462 {LA_ChildOf
, (IPTR
)parent
}, /* These two are AROS-specific */
1463 {LA_Hidden
, invisible
},
1469 layertags
[2].ti_Tag
= LA_ShapeHook
;
1470 layertags
[2].ti_Data
= (IPTR
)shapehook
;
1474 layertags
[3].ti_Tag
= LA_ShapeRegion
;
1475 layertags
[3].ti_Data
= (IPTR
)shape
;
1478 D(dprintf("CreateUpfontLayerTagList(taglist 0x%lx)\n",&layertags
));
1480 w
->WLayer
= CreateUpfrontLayerTagList( &w
->WScreen
->LayerInfo
,
1481 w
->WScreen
->RastPort
.BitMap
,
1484 w
->LeftEdge
+ w
->Width
- 1,
1485 w
->TopEdge
+ w
->Height
- 1,
1487 (struct TagItem
*)&layertags
);
1489 /* Install the BorderRPort here! see GZZ window above */
1490 if (NULL
!= w
->WLayer
)
1493 I am installing a totally new RastPort here so window and frame can
1494 have different fonts etc.
1496 w
->BorderRPort
= AllocMem(sizeof(struct RastPort
), MEMF_ANY
);
1500 InitRastPort(w
->BorderRPort
);
1501 w
->BorderRPort
->Layer
= w
->WLayer
;
1502 w
->BorderRPort
->BitMap
= w
->WLayer
->rp
->BitMap
;
1506 /* no memory for RastPort! Simply close the window */
1507 intui_CloseWindow(w
, IntuitionBase
);
1508 msg
->success
= FALSE
;
1509 // UnlockLayers(&w->WScreen->LayerInfo);
1510 ReturnVoid("intui_OpenWindow(No BorderRPort)");
1515 D(bug("Layer created: %p\n", w
->WLayer
));
1516 D(bug("Window created: %p\n", w
));
1518 /* common code for GZZ and regular windows */
1523 if ((layerflags
& LAYERBACKDROP
) && (w
->WScreen
->Flags
& SHOWTITLE
))
1526 struct Layer
*blayer
;
1528 /* make sure the screen titlebar is in front of all user created */
1529 /* backdrop windows */
1531 blayer
= w
->WScreen
->BarLayer
;
1534 if (GetPrivScreen(w
->WScreen
)->SpecialFlags
& (SF_InvisibleBar
|SF_AppearingBar
)) blayer
= 0;
1537 if (blayer
) MoveLayerInFrontOf(blayer
,w
->WLayer
);
1539 D(bug("move screen bar layer in front of window backdrop layer\n"));
1541 /* backdrop window was created over screen barlayer, but it must be
1542 under the screen barlayer if screen has flag SHOWTITLE set */
1544 AROS_ATOMIC_AND(w
->WScreen
->Flags
, ~SHOWTITLE
);
1546 ShowTitle(w
->WScreen
, TRUE
);
1550 /* Layer gets pointer to the window */
1551 WLAYER(w
) = w
->WLayer
;
1553 CheckLayers(w
->WScreen
,IntuitionBase
);
1555 // UnlockLayers(&w->WScreen->LayerInfo);
1558 w
->WLayer
->Window
= (APTR
)w
;
1560 /* Window needs a rastport */
1561 w
->RPort
= w
->WLayer
->rp
;
1563 /* installation of the correct BorderRPort already happened above !! */
1565 if (CreateWinSysGadgets(w
, IntuitionBase
))
1569 lock
= LockIBase (0);
1571 /* insert new window into parent/descendant list
1573 ** before: parent win xyz
1577 ** descendant win abc
1579 ** after: parent win xyz
1586 ** descendant win abc
1591 struct Window
*parent
, *descendant_of_parent
;
1593 parent
= IntuitionBase
->ActiveWindow
;
1594 if (!parent
) parent
= w
->WScreen
->FirstWindow
;
1597 descendant_of_parent
= parent
->Descendant
;
1598 parent
->Descendant
= w
;
1599 if (descendant_of_parent
) descendant_of_parent
->Parent
= w
;
1603 descendant_of_parent
= NULL
;
1606 w
->Descendant
= descendant_of_parent
;
1611 w
->NextWindow
= w
->WScreen
->FirstWindow
;
1612 w
->WScreen
->FirstWindow
= w
;
1614 w
->WindowPort
= GetPrivIBase(IntuitionBase
)->IntuiReplyPort
;
1618 AddResourceToList(w
, RESOURCE_WINDOW
, IntuitionBase
);
1620 if (w
->Flags
& WFLG_ACTIVATE
)
1626 RefreshWindowFrame(w
);
1629 msg
->success
= TRUE
;
1630 ReturnVoid("int_openwindow");
1634 //int_closewindow(w, IntuitionBase);
1636 } /* if (layer created) */
1638 // UnlockLayers(&w->WScreen->LayerInfo);
1641 D(bug("int_openwindow(General failure)"));
1643 msg
->success
= FALSE
;
1644 ReturnVoid("int_openwindow");