Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / intuition / openwindow.c
blob7f0d2190337d4ed6c9dbf0cebc89fdbc102a17f3
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
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 "intuition_customize.h"
24 #include "inputhandler.h"
25 #include "inputhandler_actions.h"
26 #include "boopsigadgets.h"
28 #ifdef SKINS
29 #include "transplayers.h"
30 #include "intuition_extend.h"
31 #endif
33 #ifndef DEBUG_OpenWindow
34 # define DEBUG_OpenWindow 0
35 #endif
36 #undef DEBUG
37 #define DEBUG DEBUG_OpenWindow
38 # include <aros/debug.h>
40 struct OpenWindowActionMsg
42 struct IntuiActionMsg msg;
43 struct Window *window;
44 struct BitMap *bitmap;
45 struct Hook *backfillhook;
46 struct Region *shape;
47 struct Hook *shapehook;
48 struct Layer *parentlayer;
49 BOOL invisible;
50 BOOL success;
53 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
54 struct IntuitionBase *IntuitionBase);
56 /*****************************************************************************
58 NAME */
59 AROS_LH1(struct Window *, OpenWindow,
61 /* SYNOPSIS */
62 AROS_LHA(struct NewWindow *, newWindow, A0),
64 /* LOCATION */
65 struct IntuitionBase *, IntuitionBase, 34, Intuition)
67 /* FUNCTION
68 Opens a new window with the characteristics specified in
69 newWindow.
71 INPUTS
72 newWindow - How you would like your new window.
74 RESULT
75 A pointer to the new window or NULL if it couldn't be opened. Reasons
76 for this might be lack of memory or illegal attributes.
78 NOTES
80 EXAMPLE
82 BUGS
84 SEE ALSO
85 CloseWindow(), ModifyIDCMP()
87 INTERNALS
89 *****************************************************************************/
91 AROS_LIBFUNC_INIT
93 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
94 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
95 struct OpenWindowActionMsg msg;
96 struct NewWindow nw;
97 struct Window *w = NULL, *helpgroupwindow = NULL, *parentwin = NULL;
98 struct TagItem *tag, *shapeti = NULL, *shapehookti = NULL;
99 struct TagItem *tagList;
100 struct RastPort *rp;
101 struct Hook *backfillhook = LAYERS_BACKFILL, *shapehook = NULL;
102 struct Region *shape = NULL;
103 struct IBox *zoombox = NULL;
104 struct Image *AmigaKey = NULL;
105 struct Image *Checkmark = NULL;
106 struct Layer *parentl = NULL;
107 #ifdef SKINS
108 struct SkinInfo *skininfo = NULL;
109 BOOL hasskininfo = FALSE;
110 struct Region *usertranspregion = NULL;
111 struct Hook *usertransphook = NULL;
112 struct MsgPort *userport = NULL;
113 #endif
114 STRPTR pubScreenName = NULL;
115 BOOL pubScreenNameSet = FALSE;
116 UBYTE *screenTitle = NULL;
117 BOOL autoAdjust = FALSE, pubScreenFallBack = FALSE;
118 ULONG innerWidth = ~0;
119 ULONG innerHeight = ~0;
120 WORD mousequeue = DEFAULTMOUSEQUEUE;
121 WORD repeatqueue = 3; /* stegerg: test on my Amiga suggests this */
122 ULONG moreFlags = 0;
123 ULONG helpgroup = 0;
124 ULONG extrabuttons = 0, extrabuttonsid = ETI_Dummy;
125 //ULONG lock;
126 ULONG windowinvisible = FALSE;
127 BOOL driver_init_done = FALSE, have_helpgroup = FALSE;
128 BOOL do_setwindowpointer = FALSE;
130 ASSERT_VALID_PTR_ROMOK(newWindow);
132 D(bug("OpenWindow (%p = { Left=%d Top=%d Width=%d Height=%d })\n"
133 , newWindow
134 , newWindow->LeftEdge
135 , newWindow->TopEdge
136 , newWindow->Width
137 , newWindow->Height
140 FireScreenNotifyMessage((IPTR) newWindow, SNOTIFY_BEFORE_OPENWINDOW, IntuitionBase);
142 nw = *newWindow;
144 #define WFLG_PRIVATEFLAGS (WFLG_WINDOWREFRESH |\
145 WFLG_WINDOWTICKED | WFLG_VISITOR | \
146 WFLG_ZOOMED |\
147 WFLG_WINDOWACTIVE )
148 /* jDc*/
149 /* WFLG_WBENCHWINDOW | \*/
150 /* this is used by WORKBENCH! */
151 /* WFLG_HASZOOM | \*/
152 /* do NOT filter this! how do you think apps could manage to get a zoom image with struct NewWindow? */
154 nw.Flags &= ~WFLG_PRIVATEFLAGS;
156 if (newWindow->Flags & WFLG_NW_EXTENDED)
158 tagList = ((struct ExtNewWindow *)newWindow)->Extension;
159 #ifdef __mc68000
160 /* Sanitycheck the taglist pointer. Some Am*gaOS 1.3/2.x era
161 * apps have WFLG_NW_EXTENDED set with bogus Extension taglist
162 * pointer... (older CygnusED for example) - Piru
164 if (((IPTR) tagList & 1) || !TypeOfMem((APTR)tagList))
166 tagList = NULL;
168 #endif
170 else
172 tagList = NULL;
175 DEBUG_OPENWINDOW(dprintf("OpenWindow: NewWindow 0x%lx TagList 0x%lx\n",
176 newWindow, tagList));
178 if (tagList)
180 ASSERT_VALID_PTR_ROMOK(tagList);
182 /* Look at WA_Flags first, since boolean tags override part of it
183 * even if they appear before it.
185 nw.Flags |= (GetTagData(WA_Flags, nw.Flags, tagList) & ~WFLG_PRIVATEFLAGS);
187 while ((tag = NextTagItem (&tagList)))
189 /* ASSERT_VALID_PTR_ROMOK(tag); */
191 DEBUG_OPENWINDOW(dprintf("OpenWindow: Tag 0x%08lx 0x%p\n",
192 (ULONG)tag->ti_Tag, tag->ti_Data));
194 switch ((ULONG)tag->ti_Tag)
196 case WA_Left:
197 nw.LeftEdge = tag->ti_Data;
198 break;
200 case WA_Top:
201 nw.TopEdge = tag->ti_Data;
202 break;
204 case WA_Width:
205 nw.Width = tag->ti_Data;
206 break;
208 case WA_Height:
209 nw.Height = tag->ti_Data;
210 break;
212 case WA_IDCMP:
213 nw.IDCMPFlags = tag->ti_Data;
214 break;
216 case WA_MinWidth:
217 nw.MinWidth = tag->ti_Data;
218 break;
220 case WA_MinHeight:
221 nw.MinHeight = tag->ti_Data;
222 break;
224 case WA_MaxWidth:
225 nw.MaxWidth = tag->ti_Data;
226 break;
228 case WA_MaxHeight:
229 nw.MaxHeight = tag->ti_Data;
230 break;
232 case WA_Gadgets:
233 nw.FirstGadget = (struct Gadget *)(tag->ti_Data);
234 break;
236 case WA_Title:
237 nw.Title = (UBYTE *)(tag->ti_Data);
238 break;
240 case WA_ScreenTitle:
241 screenTitle = (UBYTE *)tag->ti_Data;
242 break;
244 case WA_AutoAdjust:
245 autoAdjust = (tag->ti_Data != 0);
246 break;
248 case WA_InnerWidth:
249 innerWidth = tag->ti_Data;
250 break;
252 case WA_InnerHeight:
253 innerHeight = tag->ti_Data;
254 break;
256 #define MODIFY_FLAG(name) if (tag->ti_Data) \
257 nw.Flags |= (name); else nw.Flags &= ~(name)
258 #define MODIFY_MFLAG(name) if (tag->ti_Data) \
259 moreFlags |= (name); else moreFlags &= ~(name)
261 case WA_SizeGadget:
262 MODIFY_FLAG(WFLG_SIZEGADGET);
263 break;
265 case WA_DragBar:
266 MODIFY_FLAG(WFLG_DRAGBAR);
267 break;
269 case WA_DepthGadget:
270 MODIFY_FLAG(WFLG_DEPTHGADGET);
271 break;
273 case WA_CloseGadget:
274 MODIFY_FLAG(WFLG_CLOSEGADGET);
275 break;
277 case WA_Backdrop:
278 MODIFY_FLAG(WFLG_BACKDROP);
279 break;
281 case WA_ReportMouse:
282 MODIFY_FLAG(WFLG_REPORTMOUSE);
283 break;
285 case WA_NoCareRefresh:
286 MODIFY_FLAG(WFLG_NOCAREREFRESH);
287 break;
289 case WA_Borderless:
290 MODIFY_FLAG(WFLG_BORDERLESS);
291 break;
293 case WA_Activate:
294 MODIFY_FLAG(WFLG_ACTIVATE);
295 break;
297 case WA_RMBTrap:
298 MODIFY_FLAG(WFLG_RMBTRAP);
299 break;
301 case WA_WBenchWindow:
302 MODIFY_FLAG(WFLG_WBENCHWINDOW);
303 break;
305 case WA_SizeBRight:
306 MODIFY_FLAG(WFLG_SIZEBRIGHT);
307 break;
309 case WA_SizeBBottom:
310 MODIFY_FLAG(WFLG_SIZEBBOTTOM);
311 break;
313 case WA_GimmeZeroZero:
314 MODIFY_FLAG(WFLG_GIMMEZEROZERO);
315 break;
317 case WA_NewLookMenus:
318 MODIFY_FLAG(WFLG_NEWLOOKMENUS);
319 break;
321 case WA_ToolBox:
322 MODIFY_FLAG(WFLG_TOOLBOX);
323 break;
325 case WA_Zoom:
326 zoombox = (struct IBox *)tag->ti_Data;
327 DEBUG_OPENWINDOW(dprintf("OpenWindow: zoom %d %d %d %d\n",
328 zoombox->Left, zoombox->Top, zoombox->Width, zoombox->Height));
329 MODIFY_FLAG(WFLG_HASZOOM);
330 break;
332 case WA_DetailPen:
333 if (nw.DetailPen == 0xFF)
334 nw.DetailPen = tag->ti_Data;
335 break;
337 case WA_BlockPen:
338 if (nw.BlockPen == 0xFF)
339 nw.BlockPen = tag->ti_Data;
340 break;
342 case WA_CustomScreen:
343 nw.Screen = (struct Screen *)(tag->ti_Data);
344 nw.Type = CUSTOMSCREEN;
345 break;
347 case WA_SuperBitMap:
348 nw.Flags |= WFLG_SUPER_BITMAP;
349 nw.BitMap = (struct BitMap *)(tag->ti_Data);
350 break;
352 case WA_SimpleRefresh:
353 if (tag->ti_Data)
354 nw.Flags |= WFLG_SIMPLE_REFRESH;
355 break;
357 case WA_SmartRefresh:
358 if (tag->ti_Data)
359 nw.Flags |= WFLG_SMART_REFRESH;
360 break;
362 case WA_PubScreenFallBack:
363 pubScreenFallBack = (tag->ti_Data ? TRUE : FALSE);
364 break;
366 case WA_PubScreenName:
367 pubScreenNameSet = TRUE;
368 pubScreenName = (STRPTR)tag->ti_Data;
369 break;
371 case WA_PubScreen:
372 nw.Type = PUBLICSCREEN;
373 nw.Screen = (struct Screen *)tag->ti_Data;
374 break;
376 case WA_BackFill:
377 backfillhook = (struct Hook *)tag->ti_Data;
378 break;
380 case WA_MouseQueue:
381 mousequeue = tag->ti_Data;
382 break;
384 /* These two are not implemented in AmigaOS */
385 case WA_WindowName:
386 case WA_Colors:
387 break;
389 case WA_NotifyDepth:
390 MODIFY_MFLAG(WMFLG_NOTIFYDEPTH);
391 break;
393 case WA_RptQueue:
394 repeatqueue = tag->ti_Data;
395 break;
397 case WA_Checkmark:
398 Checkmark = (struct Image *)tag->ti_Data;
399 break;
401 case WA_AmigaKey:
402 AmigaKey = (struct Image *)tag->ti_Data;
403 break;
405 case WA_HelpGroup:
406 helpgroup = (ULONG)tag->ti_Data;
407 have_helpgroup = TRUE;
408 break;
410 case WA_HelpGroupWindow:
411 helpgroupwindow = (struct Window *)tag->ti_Data;
412 break;
414 case WA_MenuHelp:
415 MODIFY_MFLAG(WMFLG_MENUHELP);
416 break;
418 case WA_PointerDelay:
419 MODIFY_MFLAG(WMFLG_POINTERDELAY);
420 break;
422 case WA_TabletMessages:
423 MODIFY_MFLAG(WMFLG_TABLETMESSAGES);
424 break;
426 case WA_ExtraTitlebarGadgets:
427 extrabuttons = (ULONG)tag->ti_Data;
428 break;
430 case WA_ExtraGadgetsStartID:
431 extrabuttonsid = (ULONG)tag->ti_Data;
432 break;
434 case WA_ExtraGadget_Iconify:
435 if (tag->ti_Data)
437 extrabuttons |= ETG_ICONIFY;
439 else
441 extrabuttons &= ~ETG_ICONIFY;
443 break;
445 case WA_ExtraGadget_Lock:
446 if (tag->ti_Data)
448 extrabuttons |= ETG_LOCK;
450 else
452 extrabuttons &= ~ETG_LOCK;
454 break;
456 case WA_ExtraGadget_MUI:
457 if (tag->ti_Data)
459 extrabuttons |= ETG_MUI;
461 else
463 extrabuttons &= ~ETG_MUI;
465 break;
467 case WA_ExtraGadget_PopUp:
468 if (tag->ti_Data)
470 extrabuttons |= ETG_POPUP;
472 else
474 extrabuttons &= ~ETG_POPUP;
476 break;
478 case WA_ExtraGadget_Snapshot:
479 if (tag->ti_Data)
481 extrabuttons |= ETG_SNAPSHOT;
483 else
485 extrabuttons &= ~ETG_SNAPSHOT;
487 break;
489 case WA_ExtraGadget_Jump:
490 if (tag->ti_Data)
492 extrabuttons |= ETG_JUMP;
494 else
496 extrabuttons &= ~ETG_JUMP;
498 break;
500 #ifdef SKINS
501 case WA_SkinInfo:
502 skininfo = (struct SkinInfo *)tag->ti_Data;
503 hasskininfo = TRUE;
504 break;
506 case WA_TransparentRegion:
507 usertranspregion = (struct Region *)tag->ti_Data;
508 usertransphook = NULL; //doesn't make sense
509 break;
511 case WA_TransparentRegionHook:
512 usertransphook = (struct Hook *)tag->ti_Data;
513 usertranspregion = NULL;
514 break;
516 case WA_UserPort:
517 userport = (struct MsgPort *)tag->ti_Data;
518 break;
519 /**********************************************************************************/
521 case WA_IAmMUI:
522 MODIFY_MFLAG(WMFLG_IAMMUI);
523 break;
524 #endif
526 #ifndef __MORPHOS__
527 case WA_ShapeRegion:
528 shapeti = tag;
529 shape = (struct Region *)tag->ti_Data;
530 break;
532 case WA_ShapeHook:
533 shapehookti = tag;
534 shapehook = (struct Hook *)tag->ti_Data;
535 break;
538 case WA_Parent:
539 parentwin = ((struct Window *)tag->ti_Data);
540 parentl = parentwin->WLayer;
541 break;
543 case WA_Hidden:
544 windowinvisible = tag->ti_Data;
545 break;
546 #endif
548 case WA_Pointer:
549 case WA_BusyPointer:
550 do_setwindowpointer = TRUE;
551 break;
553 } /* switch Tag */
555 } /* while ((tag = NextTagItem (&tagList))) */
557 } /* if (tagList) */
559 if (nw.Flags & WFLG_SIZEGADGET)
561 if (!(nw.Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
563 nw.Flags |= WFLG_SIZEBRIGHT;
566 //jDc: tested behavior of intuition68k
567 nw.Flags |= WFLG_HASZOOM;
569 else
571 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM);
574 if (nw.Flags & WFLG_BORDERLESS)
576 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM|WFLG_SIZEGADGET);
579 /* Find out on which Screen the window must open */
581 /* (cyfm 03/03/03 check for nw.Type == PUBLICSCREEN as well, some programs
582 * like TurboPrint GraphicPublisher specify {WA_PubScreen, NULL} and want
583 * to open on the default public screen that way
585 if (pubScreenNameSet || (nw.Type == PUBLICSCREEN && nw.Screen == NULL))
587 struct Screen *pubs = 0;
589 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
590 pubs = LockPubScreen(pubScreenName);
591 if (!pubs && pubScreenFallBack)
593 nw.Screen = LockPubScreen(NULL);
595 if (pubs)
597 nw.Screen = pubs;
599 nw.Type = PUBLICSCREEN;
600 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
602 else if (nw.Type == PUBLICSCREEN)
604 /* There is no LockPubScreen() with a "struct Screen *" argument, so we have to do
605 * the necessary steps ourself
607 LockPubScreenList();
608 if (GetPrivScreen(nw.Screen)->pubScrNode)
610 GetPrivScreen(nw.Screen)->pubScrNode->psn_VisitorCount++;
611 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
612 nw.Flags |= WFLG_VISITOR;
613 FireScreenNotifyMessage((IPTR) nw.Screen, SNOTIFY_LOCKPUBSCREEN, IntuitionBase);
615 else
617 /* The screen wasn't a PublicScreen */
618 UnlockPubScreenList();
619 D(bug("OpenWindow: Not a PublicScreen\n"));
620 goto failexit;
622 UnlockPubScreenList();
625 if (nw.Type == WBENCHSCREEN)
627 nw.Screen = LockPubScreen("Workbench");
628 if (nw.Screen)
630 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
631 nw.Flags |= WFLG_VISITOR;
635 if (nw.Screen == NULL) {
636 D(bug("OpenWindow: No screen\n"));
637 goto failexit;
640 w = AllocMem (sizeof(struct IntWindow), MEMF_CLEAR);
642 DEBUG_OPENWINDOW(dprintf("OpenWindow: Window 0x%lx\n", w));
644 /* nlorentz: For now, creating a rastport becomes the responsibility of
645 intui_OpenWindow(). This is because intui_OpenWindow() in
646 config/hidd/intuition_driver.c must call CreateUpfrontLayer(),
647 and that will create a rastport for the layer/window, and we don't
648 want two rastports pr. window.
649 Alternatively we may create a layers_driver.c driver for layers,
650 and then call CreateUpfrontLayer() here from openwindow.
651 For the Amiga window<-->X11 window stuff, the layers driver
652 would just allocate a layer struct, a rastport and
653 put the rasport into layer->RastPort, so we
654 could get it inside this routine and put it into
655 window->RPort;.
659 if (NULL == w) {
660 D(bug("OpenWindow: No window\n"));
661 goto failexit;
664 DEBUG_OPENWINDOW(dprintf("OpenWindow: Flags 0x%lx MoreFlags 0x%lx IDCMP 0x%lx\n",
665 nw.Flags, moreFlags, nw.IDCMPFlags));
666 IPTR userbuffersize;
668 GetAttr(WDA_UserBuffer, ((struct IntScreen *)(nw.Screen))->WinDecorObj, &userbuffersize);
670 if (userbuffersize)
672 ((struct IntWindow *)w)->DecorUserBufferSize = userbuffersize;
673 ((struct IntWindow *)w)->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
674 if (0 == ((struct IntWindow *)w)->DecorUserBuffer) {
675 D(bug("OpenWindow: No decor\n"));
676 goto failexit;
680 struct wdpInitWindow initmsg;
681 BOOL ok;
683 initmsg.MethodID = WDM_INITWINDOW;
684 initmsg.wdp_TrueColor = (((struct IntScreen *) nw.Screen)->DInfo.dri_Flags & DRIF_DIRECTCOLOR) ? TRUE : FALSE;
685 initmsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
686 initmsg.wdp_ScreenUserBuffer = ((struct IntScreen *) nw.Screen)->DecorUserBuffer;
687 initmsg.wdp_Screen = nw.Screen;
689 ok = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&initmsg);
691 if (!ok) {
692 D(bug("OpenWindow: WDM_INITWINDOW failed\n"));
693 goto failexit;
696 w->WScreen = nw.Screen;
698 #ifdef SKINS
699 if (userport)
701 w->UserPort = userport;
702 ((struct IntWindow *)w)->specialflags |= SPFLAG_USERPORT;
704 #endif
706 if (!ModifyIDCMP (w, nw.IDCMPFlags)) {
707 D(bug("OpenWindow: ModifyIDCMP failed\n"));
708 goto failexit;
711 ((struct IntWindow *)w)->extrabuttons = extrabuttons;
712 ((struct IntWindow *)w)->extrabuttonsid = extrabuttonsid;
714 /* w->RPort = rp; */
716 //w->FirstGadget = nw.FirstGadget;
718 w->DetailPen = (nw.DetailPen != 0xFF) ? nw.DetailPen : w->WScreen->DetailPen;
719 w->BlockPen = (nw.BlockPen != 0xFF) ? nw.BlockPen : w->WScreen->BlockPen;
721 /* Copy flags */
722 w->Flags = nw.Flags;
723 w->MoreFlags = moreFlags;
725 if (!(w->Flags & WFLG_BORDERLESS))
727 w->BorderLeft = w->WScreen->WBorLeft;
728 w->BorderRight = w->WScreen->WBorRight;
729 #ifdef TITLEHACK
730 w->BorderTop = w->WScreen->WBorBottom;
731 #else
732 w->BorderTop = w->WScreen->WBorTop;
733 #endif
734 w->BorderBottom = w->WScreen->WBorBottom;
737 if (nw.Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET)))
739 /* this is a hack. the correct way to "correct" (increase if necessary)
740 the w->Border??? items would be to check all GACT_???BORDER gadgets
741 (inclusive sysgadgets which are GACT_????BORDER gadgets as well) in
742 nw.FirstGadget (or WA_Gadgets tag) and all sysgadgets and then
743 make sure that each window border is big enough so that none of these
744 gadgets extends outside the window border area */
746 #ifdef TITLEHACK
747 w->BorderTop = w->WScreen->WBorTop;
748 #endif
749 /* Georg Steger: ??? font ??? */
750 if (w->WScreen->Font)
751 w->BorderTop += ((struct IntScreen *)(w->WScreen))->DInfo.dri_Font->tf_YSize + 1;
752 else
753 w->BorderTop += GfxBase->DefaultFont->tf_YSize + 1;
754 #ifndef TITLEHACK
755 #ifdef SKINS
756 if (hasskininfo)
758 struct windowclassprefs *wcprefs;
759 struct IntDrawInfo *dri;
760 if ((dri = (struct IntDrawInfo *)GetScreenDrawInfo(w->WScreen)))
762 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
763 w->BorderTop += wcprefs->titlebarincrement;
764 int_FreeCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
767 #endif
768 #endif
771 /* look for GACT_???BORDER gadgets which increase the BorderSizes */
773 if (nw.FirstGadget)
775 struct Gadget *gad;
777 for(gad = nw.FirstGadget; gad; gad = gad->NextGadget)
779 WORD gadx1, gady1, gadx2, gady2;
781 if (gad->Activation & GACT_LEFTBORDER)
783 /* may never be GFLG_RELRIGHT / GFLG_RELWIDTH */
785 gadx2 = gad->LeftEdge + gad->Width - 1;
786 if (gadx2 >= w->BorderLeft) w->BorderLeft = gadx2/* + 1*/;
789 if (gad->Activation & GACT_TOPBORDER)
791 /* may never be GFLG_RELBOTTOM / GFLG_RELHEIGHT */
793 gady2 = gad->TopEdge + gad->Height - 1;
794 if (gady2 >= w->BorderTop) w->BorderTop = gady2/* + 1*/;
797 if (gad->Activation & GACT_RIGHTBORDER)
799 /* must be GFLG_RELRIGHT but never GFLG_RELWIDTH */
801 gadx1 = -gad->LeftEdge;
802 if (gadx1 >= w->BorderRight) w->BorderRight = gadx1/* + 1*/;
805 if (gad->Activation & GACT_BOTTOMBORDER)
807 /* must be GFLG_RELBOTTOM but never GFLG_RELHEIGHT */
809 gady1 = -gad->TopEdge;
810 if (gady1 >= w->BorderBottom) w->BorderBottom = gady1/* + 1*/;
813 } /* for(gad = nw.FirstGadget; gad; gad = gad->NextGadget) */
815 } /* if (nw.FirstGadget) */
817 if (!(w->Flags & WFLG_SIZEBRIGHT)) if (w->BorderRight > w->WScreen->WBorRight)
819 w->Flags |= WFLG_SIZEBRIGHT;
822 if (!(w->Flags & WFLG_SIZEBBOTTOM)) if (w->BorderBottom > w->WScreen->WBorBottom)
824 w->Flags |= WFLG_SIZEBBOTTOM;
828 // if ((w->Flags & WFLG_SIZEGADGET) &&
829 // (w->Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
831 IPTR sizewidth = 16, sizeheight = 16;
832 struct Image *im;
833 struct DrawInfo *dri;
835 if ((dri = GetScreenDrawInfo(w->WScreen)))
837 struct TagItem imtags[] =
839 {SYSIA_DrawInfo , (STACKIPTR)dri },
840 {SYSIA_Which , SIZEIMAGE },
841 {SYSIA_Size , w->WScreen->Flags & SCREENHIRES ? SYSISIZE_MEDRES : SYSISIZE_LOWRES },
842 {TAG_DONE }
845 if ((im = NewObjectA(NULL, SYSICLASS, imtags)))
847 GetAttr(IA_Width, (Object *)im, &sizewidth);
848 GetAttr(IA_Height, (Object *)im, &sizeheight);
850 DisposeObject(im);
852 FreeScreenDrawInfo(w->WScreen, dri);
855 if (w->Flags & WFLG_SIZEBRIGHT)
857 if (w->BorderRight < sizewidth) w->BorderRight = sizewidth;
860 if (w->Flags & WFLG_SIZEBBOTTOM)
862 if (w->BorderBottom < sizeheight) w->BorderBottom = sizeheight;
865 IW(w)->sizeimage_width = sizewidth;
866 IW(w)->sizeimage_height = sizeheight;
868 /* now increase window size if it's necessary */
871 #ifdef SKINS
873 IW(w)->custombackfill.h_Entry = (HOOKFUNC)HookEntry;
874 IW(w)->custombackfill.h_SubEntry = (HOOKFUNC)GradientizeBackfillFunc;
875 IW(w)->custombackfill.h_Data = &IW(w)->hd;
876 IW(w)->hd.intuitionBase = IntuitionBase;
878 IW(w)->usertranspregion = usertranspregion;
879 IW(w)->usertransphook = usertransphook;
881 #endif
882 IW(w)->DefaultWindowShapeHook.h_Entry = (HOOKFUNC)DefaultWindowShapeFunc;
883 IW(w)->DefaultWindowShapeHook.h_SubEntry = (HOOKFUNC)w;
884 IW(w)->DefaultWindowShapeHook.h_Data = (APTR)IntuitionBase;
886 if (innerWidth != ~0) nw.Width = innerWidth + w->BorderLeft + w->BorderRight;
887 if (innerHeight != ~0) nw.Height = innerHeight + w->BorderTop + w->BorderBottom;
890 LONG parentwidth;
891 LONG parentheight;
893 parentwidth = parentwin ? parentwin->Width : w->WScreen->Width;
894 parentheight = parentwin ? parentwin->Height : w->WScreen->Height;
896 w->Width = (nw.Width != ~0) ? nw.Width : parentwidth - nw.LeftEdge;
897 w->Height = (nw.Height != ~0) ? nw.Height : parentheight - nw.TopEdge;
899 if (autoAdjust)
902 if (w->Width > parentwidth) w->Width = parentwidth;
903 if (w->Height > parentheight) w->Height = parentheight;
905 if (nw.LeftEdge < 0) nw.LeftEdge = 0;
906 if (nw.TopEdge < 0) nw.TopEdge = 0;
908 if ((nw.LeftEdge + w->Width) > parentwidth)
909 nw.LeftEdge = parentwidth - w->Width;
911 if ((nw.TopEdge + w->Height) > parentheight)
912 nw.TopEdge = parentheight - w->Height;
915 w->GZZWidth = w->Width - w->BorderLeft - w->BorderRight;
916 w->GZZHeight = w->Height - w->BorderTop - w->BorderBottom;
919 if (nw.LeftEdge < 0 || nw.TopEdge < 0 ||
920 nw.LeftEdge + w->Width > w->WScreen->Width ||
921 nw.TopEdge + w->Height > w->WScreen->Height) {
922 D(bug("OpenWindow: Window size (%dx%d) @(%d,%d) is weird for a %dx%d screen\n",
923 nw.LeftEdge + w->Width, nw.TopEdge + w->Height,
924 nw.LeftEdge, nw.TopEdge ,
925 w->WScreen->Width, w->WScreen->Height));
926 goto failexit;
929 if (NULL == parentwin)
931 w->LeftEdge = nw.LeftEdge;
932 w->TopEdge = nw.TopEdge;
934 else
936 w->LeftEdge = nw.LeftEdge + parentwin->LeftEdge;
937 w->TopEdge = nw.TopEdge + parentwin->TopEdge;
940 #ifndef __MORPHOS__
941 w->RelLeftEdge = nw.LeftEdge;
942 w->RelTopEdge = nw.TopEdge;
943 #endif
945 w->MinWidth = (nw.MinWidth != 0) ? nw.MinWidth : w->Width;
946 w->MinHeight = (nw.MinHeight != 0) ? nw.MinHeight : w->Height;
947 w->MaxWidth = (nw.MaxWidth != 0) ? nw.MaxWidth : w->Width;
948 w->MaxHeight = (nw.MaxHeight != 0) ? nw.MaxHeight : w->Height;
950 //jDc: tested behavior of intuition68k
951 if ((UWORD)w->MaxWidth < w->Width) w->MaxWidth = w->Width;
952 if ((UWORD)w->MaxHeight < w->Height) w->MaxHeight = w->Height;
954 /* check if maxwidth/height is not bigger than screen */
955 if (w->MaxWidth > w->WScreen->Width) w->MaxWidth = w->WScreen->Width;
956 if (w->MaxHeight > w->WScreen->Height) w->MaxHeight = w->WScreen->Height;
958 if (zoombox)
960 ((struct IntWindow *)w)->ZipLeftEdge = zoombox->Left;
961 ((struct IntWindow *)w)->ZipTopEdge = zoombox->Top;
962 ((struct IntWindow *)w)->ZipWidth = zoombox->Width;
963 ((struct IntWindow *)w)->ZipHeight = zoombox->Height;
965 else
967 ((struct IntWindow *)w)->ZipLeftEdge = nw.LeftEdge;
968 ((struct IntWindow *)w)->ZipTopEdge = nw.TopEdge;
969 ((struct IntWindow *)w)->ZipWidth = (w->Width == w->MinWidth) ? w->MaxWidth : w->MinWidth;
970 ((struct IntWindow *)w)->ZipHeight = (w->Height == w->MinHeight) ? w->MaxHeight : w->MinHeight;
973 DEBUG_OPENWINDOW(dprintf("OpenWindow: zip %d %d %d %d\n",
974 ((struct IntWindow *)w)->ZipLeftEdge,
975 ((struct IntWindow *)w)->ZipTopEdge,
976 ((struct IntWindow *)w)->ZipWidth,
977 ((struct IntWindow *)w)->ZipHeight));
980 IW(w)->mousequeue = mousequeue;
981 IW(w)->repeatqueue = repeatqueue;
983 /* Amiga and checkmark images for menus */
985 IW(w)->Checkmark = Checkmark ? Checkmark :
986 ((struct IntScreen *)(w->WScreen))->DInfo.dri_CheckMark;
988 IW(w)->AmigaKey = AmigaKey ? AmigaKey :
989 ((struct IntScreen *)(w->WScreen))->DInfo.dri_AmigaKey;
990 IW(w)->SubMenuImage = ((struct IntScreen *)(w->WScreen))->DInfo.dri_Customize->submenu;
992 #ifndef __MORPHOS__
993 /* child support */
994 if (NULL != parentwin)
996 if (parentwin->firstchild)
997 parentwin->firstchild->prevchild = w;
999 w->nextchild = parentwin->firstchild;
1000 parentwin->firstchild = w;
1001 w->parent = parentwin;
1003 #endif
1005 #ifdef SKINS
1006 if (hasskininfo) ((struct IntWindow *)(w))->specialflags = SPFLAG_SKININFO;
1007 #endif
1009 #ifdef DAMAGECACHE
1010 if ((w->Flags & WFLG_SIMPLE_REFRESH) && (IS_DOCAREREFRESH(w)) && (!(w->Flags & WFLG_BORDERLESS))) IW(w)->trashregion = NewRegion();
1011 #endif
1013 /* Help stuff */
1015 if (!have_helpgroup && helpgroupwindow)
1017 if (IW(helpgroupwindow)->helpflags & HELPF_ISHELPGROUP)
1019 helpgroup = IW(helpgroupwindow)->helpgroup;
1020 have_helpgroup = TRUE;
1024 if (have_helpgroup)
1026 IW(w)->helpflags |= HELPF_ISHELPGROUP;
1027 IW(w)->helpgroup = helpgroup;
1030 w->Title = nw.Title;
1032 /* as mentioned in the OpenScreen() autodoc/SA_SysFont settings the default
1033 window font will be either screenfont (sysfont=0) or defaultfont (sysfont=1) */
1034 w->IFont = SafeReopenFont(IntuitionBase, (IS(w->WScreen)->SysFont) ? &GfxBase->DefaultFont : &IS(w->WScreen)->DInfo.dri_Font);
1036 if (w->IFont == NULL) goto failexit;
1038 /* jDc: intui68k waits before opening the window until
1039 ** Move/SizeWindow actions are over (does it mean it's executed on
1040 ** caller's context?).
1043 #ifdef USEWINDOWLOCK
1044 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1046 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1048 #endif
1050 IW(w)->OutlineShape = NULL;
1052 if ((shapeti != NULL) || (shapehookti != NULL)) IW(w)->CustomShape = TRUE;
1053 if (!(IW(w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1055 shapehook = &IW(w)->DefaultWindowShapeHook;
1058 msg.window = w;
1059 msg.bitmap = nw.BitMap;
1060 //msg.backfillhook = backfillhook == LAYERS_BACKFILL ? &IW(w)->custombackfill : backfillhook;
1061 msg.backfillhook = backfillhook;
1062 msg.shape = shape;
1063 msg.shapehook = shapehook;
1064 msg.parentlayer = parentl;
1065 msg.invisible = windowinvisible;
1067 DoSyncAction((APTR)int_openwindow, &msg.msg, IntuitionBase);
1069 #ifdef USEWINDOWLOCK
1070 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1072 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1074 #endif
1076 if (!msg.success) {
1077 D(bug("OpenWindow: DoSyncAction failed\n"));
1078 goto failexit;
1081 /* nlorentz: The driver has in some way or another allocated a rastport for us,
1082 which now is ready for us to use. */
1084 driver_init_done = TRUE;
1085 rp = w->RPort;
1087 D(bug("called driver, rp=%p\n", rp));
1089 /* The window RastPort always gets the font from GfxBase->DefaultFont, which
1090 is the system's default font. Usually topaz 8, but it can be changed with
1091 the Fonts prefs program to another fixed-sized font. */
1093 SetFont (rp, w->IFont);
1095 D(bug("set fonts\n"));
1097 /* FIXME: Remove workaround! */
1098 /* lbischoff: The following 4 Setxxx lines are a workaround for the InitRastPort
1099 problem (Bug #75 in docs/BUGS). They ensure that at least a window's rastport
1100 is initialized correctly. Remove them if they are not needed any longer!
1102 SetABPenDrMd (rp, rp->FgPen, rp->BgPen, rp->DrawMode);
1103 SetWriteMask (rp, rp->Mask);
1104 D(bug("set pens\n"));
1107 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
1108 /*DoGMLayout(w->FirstGadget, w, NULL, -1, TRUE, IntuitionBase);
1110 if (NULL != w->FirstGadget)
1111 RefreshGadgets (w->FirstGadget, w, NULL);
1114 if (nw.FirstGadget)
1116 struct IntDrawInfo *dri = &((struct IntScreen *)(w->WScreen))->DInfo;
1117 struct wdpLayoutBorderGadgets msg;
1119 msg.MethodID = WDM_LAYOUT_BORDERGADGETS;
1120 msg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;;
1121 msg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri_Flags & DRIF_DIRECTCOLOR) ? TRUE : FALSE;
1122 msg.wdp_Window = w;
1123 msg.wdp_Gadgets = nw.FirstGadget;
1124 msg.wdp_Flags = WDF_LBG_INITIAL | WDF_LBG_MULTIPLE;
1125 msg.wdp_ExtraButtons = ((struct IntWindow *)w)->extrabuttons;
1126 msg.wdp_Dri = (struct DrawInfo *)dri;
1128 DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&msg);
1130 AddGList(w, nw.FirstGadget, -1, -1, NULL);
1133 #if 0
1134 /* !!! This does double refreshing as the system gadgets also are refreshed
1135 in the above RfreshGadgets() call */
1136 if (nw.Flags & WFLG_ACTIVATE)
1138 /* RefreshWindowFrame() will be called from within ActivateWindow().
1139 No point in doing double refreshing. */
1141 ActivateWindow(w);
1143 else
1145 RefreshWindowFrame(w);
1147 #endif
1149 if (screenTitle != NULL)
1150 SetWindowTitles (w, (CONST_STRPTR)~0, screenTitle);
1152 UpdateMouseCoords(w);
1154 if (do_setwindowpointer)
1156 //jDc: main for () loop destroys original taglist pointer, we need to get
1157 //it once again here!
1158 tagList = (struct TagItem *)((struct ExtNewWindow *)newWindow)->Extension;
1159 SetWindowPointerA(w, (struct TagItem *)tagList);
1162 #if 0
1163 ((struct IntWindow *)w)->OutlineShape = NULL;
1165 if ((shape != NULL) || (shapehook != NULL)) ((struct IntWindow *)w)->CustomShape = TRUE;
1166 if ((!((struct IntWindow *)w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1168 struct wdpWindowShape shapemsg;
1170 shapemsg.MethodID = WDM_WINDOWSHAPE;
1171 shapemsg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri_Flags & DRIF_DIRECTCOLOR);
1172 shapemsg.wdp_Width = w->Width;
1173 shapemsg.wdp_Height = w->Height;
1174 shapemsg.wdp_Window = w;
1175 shapemsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
1177 shape = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&shapemsg);
1178 ((struct IntWindow *)w)->OutlineShape = shape;
1179 ChangeWindowShape(w, shape, NULL);
1180 ((struct IntWindow *)w)->CustomShape = FALSE;
1182 #endif
1184 goto exit;
1186 failexit:
1187 D(bug("fail\n"));
1189 if (w)
1191 ModifyIDCMP (w, 0);
1193 /* nlorentz: Freeing the rasport is now intui_CloseWindow()'s task.
1195 if (rp)
1197 FreeRastPort (rp);
1201 if (driver_init_done)
1202 intui_CloseWindow(w, IntuitionBase);
1204 if (w->IFont) CloseFont(w->IFont);
1206 if (((struct IntWindow *)w)->DecorUserBuffer)
1208 FreeMem((APTR)((struct IntWindow *)w)->DecorUserBuffer, ((struct IntWindow *)w)->DecorUserBufferSize);
1211 FreeMem (w, sizeof(struct IntWindow));
1213 w = NULL;
1216 if (nw.Screen && (moreFlags & WMFLG_DO_UNLOCKPUBSCREEN))
1218 UnlockPubScreen(NULL, nw.Screen);
1221 exit:
1223 DEBUG_OPENWINDOW(dprintf("OpenWindow: Return 0x%lx\n", w));
1225 FireScreenNotifyMessage((IPTR) w, SNOTIFY_AFTER_OPENWINDOW, IntuitionBase);
1227 ReturnPtr ("OpenWindow", struct Window *, w);
1228 AROS_LIBFUNC_EXIT
1229 } /* OpenWindow */
1233 /**********************************************************************************/
1235 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
1236 struct IntuitionBase *IntuitionBase)
1238 struct GfxBase * GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
1239 struct LayersBase * LayersBase = GetPrivIBase(IntuitionBase)->LayersBase;
1240 struct Window * w = msg->window;
1241 struct BitMap * SuperBitMap = msg->bitmap;
1242 struct Hook * backfillhook = msg->backfillhook;
1243 struct Region * shape = msg->shape;
1244 struct Hook * shapehook = msg->shapehook;
1245 struct Layer * parent = msg->parentlayer;
1246 BOOL invisible = msg->invisible;
1248 #ifdef SKINS
1249 BOOL installtransphook = FALSE;
1250 BOOL notransphook = TRUE;
1251 #endif
1253 /* Create a layer for the window */
1254 LONG layerflags = 0;
1256 EnterFunc(bug("int_OpenWindow(w=%p)\n", w));
1258 D(bug("screen: %p\n", w->WScreen));
1259 D(bug("bitmap: %p\n", w->WScreen->RastPort.BitMap));
1261 /* Just insert some default values, should be taken from
1262 w->WScreen->WBorxxxx */
1264 /* Set the layer's flags according to the flags of the
1265 ** window
1268 /* refresh type */
1269 if (w->Flags & WFLG_SIMPLE_REFRESH)
1271 layerflags |= LAYERSIMPLE;
1273 else
1275 if (w->Flags & WFLG_SUPER_BITMAP && SuperBitMap)
1277 layerflags |= LAYERSUPER;
1279 else
1281 layerflags |= LAYERSMART;
1285 if (w->Flags & WFLG_BACKDROP)
1287 layerflags |= LAYERBACKDROP;
1290 D(bug("Window dims: (%d, %d, %d, %d)\n",
1291 w->LeftEdge, w->TopEdge, w->Width, w->Height));
1293 #ifdef SKINS
1294 //install transp layer hook!
1296 struct windowclassprefs *wcprefs = NULL;
1298 wcprefs = (struct windowclassprefs*)int_GetCustomPrefs(TYPE_WINDOWCLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1299 if (wcprefs->flags & WINDOWCLASS_PREFS_ROUNDEDEDGES && (w->Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET))))
1301 IW(w)->transpregion = NewRegion();
1302 if (IW(w)->transpregion)
1304 installtransphook = TRUE; notransphook = FALSE;
1305 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1308 else
1310 if (IW(w)->usertransphook)
1312 IW(w)->transpregion = NewRegion();
1313 if (IW(w)->transpregion)
1315 installtransphook = TRUE;
1316 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1319 else if (IW(w)->usertranspregion)
1321 IW(w)->transpregion = NewRegion();
1322 if (IW(w)->transpregion)
1324 installtransphook = TRUE;
1325 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1329 int_FreeCustomPrefs(TYPE_SYSICLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1331 #endif
1333 // LockLayers(&w->WScreen->LayerInfo);
1335 /* A GimmeZeroZero window??? */
1336 if (w->Flags & WFLG_GIMMEZEROZERO)
1339 A GimmeZeroZero window is to be created:
1340 - the outer window will be a simple refresh layer
1341 - the inner window will be a layer according to the flags
1342 What is the size of the inner/outer window supposed to be???
1343 I just make it that the outer window has the size of what is requested
1346 struct TagItem layertags[] =
1348 {LA_BackfillHook, (IPTR)LAYERS_NOBACKFILL},
1349 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1350 #ifdef SKINS
1351 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1352 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1353 #else
1354 {TAG_IGNORE , 0 },
1355 {TAG_IGNORE , 0 },
1356 #endif
1357 {LA_WindowPtr, (IPTR)w },
1358 {LA_ChildOf , (IPTR)parent}, /* These two are AROS-specific */
1359 {LA_Hidden , invisible },
1360 {TAG_DONE}
1363 /* First create outer window */
1364 struct Layer * L = CreateUpfrontLayerTagList(
1365 &w->WScreen->LayerInfo
1366 , w->WScreen->RastPort.BitMap
1367 #ifndef __MORPHOS
1368 , w->RelLeftEdge
1369 , w->RelTopEdge
1370 , w->RelLeftEdge + w->Width - 1
1371 , w->RelTopEdge + w->Height - 1
1372 #else
1373 , w->LeftEdge
1374 , w->TopEdge
1375 , w->LeftEdge + w->Width - 1
1376 , w->TopEdge + w->Height - 1
1377 #endif
1378 , LAYERSIMPLE | (layerflags & LAYERBACKDROP)
1379 , (struct TagItem *)&layertags);
1381 /* Could the layer be created. Nothing bad happened so far, so simply leave */
1382 if (NULL == L)
1384 msg->success = FALSE;
1385 // UnlockLayers(&w->WScreen->LayerInfo);
1386 ReturnVoid("intui_OpenWindow(No GimmeZeroZero layer)");
1389 D(bug("created outer GimmeZeroZero layer.\n"));
1391 /* install it as the BorderRPort */
1392 w->BorderRPort = L->rp;
1393 BLAYER(w) = L;
1395 /* Now comes the inner window */
1396 layertags[0].ti_Data = (IPTR)backfillhook;
1397 if (shapehook)
1399 layertags[2].ti_Tag = LA_ShapeHook;
1400 layertags[2].ti_Data = (IPTR)shapehook;
1402 if (shape)
1404 layertags[3].ti_Tag = LA_ShapeRegion;
1405 layertags[3].ti_Data = (IPTR)shape;
1408 w->WLayer = CreateUpfrontLayerTagList(
1409 &w->WScreen->LayerInfo
1410 , w->WScreen->RastPort.BitMap
1411 #ifndef __MORPHOS__
1412 , w->RelLeftEdge + w->BorderLeft
1413 , w->RelTopEdge + w->BorderTop
1414 , w->RelLeftEdge + w->BorderLeft + w->GZZWidth - 1
1415 , w->RelTopEdge + w->BorderTop + w->GZZHeight - 1
1416 #else
1417 , w->LeftEdge + w->BorderLeft
1418 , w->TopEdge + w->BorderTop
1419 , w->LeftEdge + w->BorderLeft + w->GZZWidth - 1
1420 , w->TopEdge + w->BorderTop + w->GZZHeight - 1
1421 #endif
1422 , layerflags
1423 , (struct TagItem *)&layertags);
1425 /* could this layer be created? If not then delete the outer window and exit */
1426 if (NULL == w->WLayer)
1428 DeleteLayer(0, L);
1429 msg->success = FALSE;
1430 // UnlockLayers(&w->WScreen->LayerInfo);
1431 ReturnVoid("intui_OpenWindow(No window layer)");
1434 /* That should do it, I guess... */
1436 else
1438 struct TagItem layertags[] =
1440 {LA_BackfillHook, (IPTR)backfillhook},
1441 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1442 #ifdef SKINS
1443 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1444 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1445 #else
1446 {TAG_IGNORE , 0 },
1447 {TAG_IGNORE , 0 },
1448 #endif
1449 {LA_WindowPtr, (IPTR)w },
1450 {LA_ChildOf , (IPTR)parent}, /* These two are AROS-specific */
1451 {LA_Hidden, invisible },
1452 {TAG_DONE}
1455 if (shapehook)
1457 layertags[2].ti_Tag = LA_ShapeHook;
1458 layertags[2].ti_Data = (IPTR)shapehook;
1460 if (shape)
1462 layertags[3].ti_Tag = LA_ShapeRegion;
1463 layertags[3].ti_Data = (IPTR)shape;
1466 D(dprintf("CreateUpfrontLayerTagList(taglist 0x%lx)\n", &layertags));
1468 w->WLayer = CreateUpfrontLayerTagList( &w->WScreen->LayerInfo,
1469 w->WScreen->RastPort.BitMap,
1470 #ifndef __MORPHOS__
1471 w->RelLeftEdge,
1472 w->RelTopEdge,
1473 w->RelLeftEdge + w->Width - 1,
1474 w->RelTopEdge + w->Height - 1,
1475 #else
1476 w->LeftEdge,
1477 w->TopEdge,
1478 w->LeftEdge + w->Width - 1,
1479 w->TopEdge + w->Height - 1,
1480 #endif
1481 layerflags,
1482 (struct TagItem *)&layertags);
1484 /* Install the BorderRPort here! see GZZ window above */
1485 if (NULL != w->WLayer)
1488 I am installing a totally new RastPort here so window and frame can
1489 have different fonts etc.
1491 w->BorderRPort = AllocMem(sizeof(struct RastPort), MEMF_ANY);
1493 if (w->BorderRPort)
1495 InitRastPort(w->BorderRPort);
1496 w->BorderRPort->Layer = w->WLayer;
1497 w->BorderRPort->BitMap = w->WLayer->rp->BitMap;
1499 else
1501 /* no memory for RastPort! Simply close the window */
1502 intui_CloseWindow(w, IntuitionBase);
1503 msg->success = FALSE;
1504 // UnlockLayers(&w->WScreen->LayerInfo);
1505 ReturnVoid("intui_OpenWindow(No BorderRPort)");
1510 D(bug("Layer created: %p\n", w->WLayer));
1511 D(bug("Window created: %p\n", w));
1513 /* common code for GZZ and regular windows */
1515 if (w->WLayer)
1518 if ((layerflags & LAYERBACKDROP) && (w->WScreen->Flags & SHOWTITLE))
1520 #ifdef __MORPHOS__
1521 struct Layer *blayer;
1523 /* make sure the screen titlebar is in front of all user created */
1524 /* backdrop windows */
1526 blayer = w->WScreen->BarLayer;
1528 #ifdef SKINS
1529 if (GetPrivScreen(w->WScreen)->SpecialFlags & (SF_InvisibleBar|SF_AppearingBar)) blayer = 0;
1530 #endif
1532 if (blayer) MoveLayerInFrontOf(blayer,w->WLayer);
1534 D(bug("move screen bar layer in front of window backdrop layer\n"));
1535 #else
1536 /* backdrop window was created over screen barlayer, but it must be
1537 under the screen barlayer if screen has flag SHOWTITLE set */
1539 AROS_ATOMIC_AND(w->WScreen->Flags, ~SHOWTITLE);
1541 ShowTitle(w->WScreen, TRUE);
1542 #endif
1545 /* Layer gets pointer to the window */
1546 WLAYER(w) = w->WLayer;
1548 CheckLayers(w->WScreen,IntuitionBase);
1550 // UnlockLayers(&w->WScreen->LayerInfo);
1552 #ifndef __MORPHOS__
1553 w->WLayer->Window = (APTR)w;
1554 #endif
1555 /* Window needs a rastport */
1556 w->RPort = w->WLayer->rp;
1558 /* installation of the correct BorderRPort already happened above !! */
1560 if (CreateWinSysGadgets(w, IntuitionBase))
1562 LONG lock;
1564 lock = LockIBase (0);
1566 /* insert new window into parent/descendant list
1568 ** before: parent win xyz
1569 ** |
1570 ** |
1571 ** |
1572 ** descendant win abc
1574 ** after: parent win xyz
1575 ** \
1576 ** \
1577 ** newwindow w
1578 ** /
1579 ** /
1580 ** /
1581 ** descendant win abc
1584 #if 1
1586 struct Window *parent, *descendant_of_parent;
1588 parent = IntuitionBase->ActiveWindow;
1589 if (!parent) parent = w->WScreen->FirstWindow;
1590 if (parent)
1592 descendant_of_parent = parent->Descendant;
1593 parent->Descendant = w;
1594 if (descendant_of_parent) descendant_of_parent->Parent = w;
1596 else
1598 descendant_of_parent = NULL;
1601 w->Descendant = descendant_of_parent;
1602 w->Parent = parent;
1604 #endif
1606 w->NextWindow = w->WScreen->FirstWindow;
1607 w->WScreen->FirstWindow = w;
1609 w->WindowPort = GetPrivIBase(IntuitionBase)->IntuiReplyPort;
1611 UnlockIBase (lock);
1613 AddResourceToList(w, RESOURCE_WINDOW, IntuitionBase);
1615 if (w->Flags & WFLG_ACTIVATE)
1617 ActivateWindow(w);
1619 else
1621 RefreshWindowFrame(w);
1624 msg->success = TRUE;
1625 ReturnVoid("int_openwindow");
1628 CloseWindow(w);
1629 //int_closewindow(w, IntuitionBase);
1631 } /* if (layer created) */
1633 // UnlockLayers(&w->WScreen->LayerInfo);
1636 D(bug("int_openwindow(General failure)"));
1638 msg->success = FALSE;
1639 ReturnVoid("int_openwindow");