Check if volumes are bootable by checking whether C/Shell is compatible with
[cake.git] / rom / intuition / openwindow.c
blobc651d95cb4fb85e8e6ca31bb25ee162adb50e2f1
1 /*
2 Copyright 1995-2007, 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 "inputhandler.h"
24 #include "inputhandler_actions.h"
25 #include "boopsigadgets.h"
27 #ifdef SKINS
28 #include "transplayers.h"
29 #include "intuition_extend.h"
30 #endif
32 #ifndef DEBUG_OpenWindow
33 # define DEBUG_OpenWindow 0
34 #endif
35 #undef DEBUG
36 #define DEBUG 0
37 #if DEBUG_OpenWindow
38 # define DEBUG 1
39 #endif
40 # include <aros/debug.h>
42 struct OpenWindowActionMsg
44 struct IntuiActionMsg msg;
45 struct Window *window;
46 struct BitMap *bitmap;
47 struct Hook *backfillhook;
48 struct Region *shape;
49 struct Hook *shapehook;
50 struct Layer *parentlayer;
51 BOOL visible;
52 BOOL success;
55 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
56 struct IntuitionBase *IntuitionBase);
58 /*****************************************************************************
60 NAME */
62 AROS_LH1(struct Window *, OpenWindow,
64 /* SYNOPSIS */
65 AROS_LHA(struct NewWindow *, newWindow, A0),
67 /* LOCATION */
68 struct IntuitionBase *, IntuitionBase, 34, Intuition)
70 /* FUNCTION
71 Opens a new window with the characteristics specified in
72 newWindow.
74 INPUTS
75 newWindow - How you would like your new window.
77 RESULT
78 A pointer to the new window or NULL if it couldn't be
79 opened. Reasons for this might be lack of memory or illegal
80 attributes.
82 NOTES
84 EXAMPLE
86 BUGS
88 SEE ALSO
89 CloseWindow(), ModifyIDCMP()
91 INTERNALS
93 *****************************************************************************/
95 AROS_LIBFUNC_INIT
97 struct OpenWindowActionMsg msg;
98 struct NewWindow nw;
99 struct Window *w = NULL, *helpgroupwindow = NULL, *parentwin = NULL;
100 struct TagItem *tag, *tagList, *shapeti = NULL, *shapehookti = NULL;
101 struct RastPort *rp;
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;
108 #ifdef SKINS
109 struct SkinInfo *skininfo = NULL;
110 BOOL hasskininfo = FALSE;
111 struct Region *usertranspregion = NULL;
112 struct Hook *usertransphook = NULL;
113 struct MsgPort *userport = NULL;
114 #endif
115 STRPTR pubScreenName = NULL;
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 windowvisible = TRUE;
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 #if 1
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 (((ULONG) tagList & 1) || !TypeOfMem(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%08lx\n",
192 tag->ti_Tag, tag->ti_Data));
194 switch (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 //nw.Type = PUBLICSCREEN; //handled below!!
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_Shape:
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_Visible:
544 windowvisible = (ULONG)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
586 if (!nw.Screen && (pubScreenName || (nw.Type == PUBLICSCREEN)))
588 struct Screen *pubs = 0;
590 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
591 pubs = LockPubScreen(pubScreenName);
592 if (!pubs && pubScreenFallBack)
594 nw.Screen = LockPubScreen(NULL);
596 if (pubs)
598 nw.Screen = pubs;
600 nw.Type = PUBLICSCREEN;
601 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
604 if (!nw.Screen && nw.Type == WBENCHSCREEN)
606 nw.Screen = LockPubScreen("Workbench");
607 if (nw.Screen)
609 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
610 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
614 if (nw.Screen == NULL)
615 goto failexit;
617 w = AllocMem (sizeof(struct IntWindow), MEMF_CLEAR);
619 DEBUG_OPENWINDOW(dprintf("OpenWindow: Window 0x%lx\n", w));
621 /* nlorentz: For now, creating a rastport becomes the responsibility of
622 intui_OpenWindow(). This is because intui_OpenWindow() in
623 config/hidd/intuition_driver.c must call CreateUpfrontLayer(),
624 and that will create a rastport for the layer/window, and we don't
625 want two rastports pr. window.
626 Alternatively we may create a layers_driver.c driver for layers,
627 and then call CreateUpfrontLayer() here from openwindow.
628 For the Amiga window<-->X11 window stuff, the layers driver
629 would just allocate a layer struct, a rastport and
630 put the rasport into layer->RastPort, so we
631 could get it inside this routine and put it into
632 window->RPort;.
636 if (NULL == w)
637 goto failexit;
639 DEBUG_OPENWINDOW(dprintf("OpenWindow: Flags 0x%lx MoreFlags 0x%lx IDCMP 0x%lx\n",
640 nw.Flags, moreFlags, nw.IDCMPFlags));
641 IPTR userbuffersize;
643 GetAttr(WDA_UserBuffer, ((struct IntScreen *)(nw.Screen))->WinDecorObj, &userbuffersize);
645 if (userbuffersize)
647 ((struct IntWindow *)w)->DecorUserBufferSize = userbuffersize;
648 ((struct IntWindow *)w)->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
649 if (NULL == ((struct IntWindow *)w)->DecorUserBuffer)
650 goto failexit;
653 struct wdpInitWindow initmsg;
654 BOOL ok;
656 initmsg.MethodID = WDM_INITWINDOW;
657 initmsg.wdp_TrueColor = (((struct IntScreen *) nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
658 initmsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
659 initmsg.wdp_ScreenUserBuffer = ((struct IntScreen *) nw.Screen)->DecorUserBuffer;
660 initmsg.wdp_Screen = nw.Screen;
662 ok = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&initmsg);
664 if (!ok) goto failexit;
666 w->WScreen = nw.Screen;
668 #ifdef SKINS
669 if (userport)
671 w->UserPort = userport;
672 ((struct IntWindow *)w)->specialflags |= SPFLAG_USERPORT;
674 #endif
676 if (!ModifyIDCMP (w, nw.IDCMPFlags))
677 goto failexit;
679 ((struct IntWindow *)w)->extrabuttons = extrabuttons;
680 ((struct IntWindow *)w)->extrabuttonsid = extrabuttonsid;
682 /* w->RPort = rp; */
684 //w->FirstGadget = nw.FirstGadget;
686 w->DetailPen = (nw.DetailPen != 0xFF) ? nw.DetailPen : w->WScreen->DetailPen;
687 w->BlockPen = (nw.BlockPen != 0xFF) ? nw.BlockPen : w->WScreen->BlockPen;
689 /* Copy flags */
690 w->Flags = nw.Flags;
691 w->MoreFlags = moreFlags;
693 if (!(w->Flags & WFLG_BORDERLESS))
695 w->BorderLeft = w->WScreen->WBorLeft;
696 w->BorderRight = w->WScreen->WBorRight;
697 #ifdef TITLEHACK
698 w->BorderTop = w->WScreen->WBorBottom;
699 #else
700 w->BorderTop = w->WScreen->WBorTop;
701 #endif
702 w->BorderBottom = w->WScreen->WBorBottom;
705 if (nw.Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET)))
707 /* this is a hack. the correct way to "correct" (increase if necessary)
708 the w->Border??? items would be to check all GACT_???BORDER gadgets
709 (inclusive sysgadgets which are GACT_????BORDER gadgets as well) in
710 nw.FirstGadget (or WA_Gadgets tag) and all sysgadgets and then
711 make sure that each window border is big enough so that none of these
712 gadgets extends outside the window border area */
714 #ifdef TITLEHACK
715 w->BorderTop = w->WScreen->WBorTop;
716 #endif
717 /* Georg Steger: ??? font ??? */
718 if (w->WScreen->Font)
719 w->BorderTop += ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_Font->tf_YSize + 1;
720 else
721 w->BorderTop += GfxBase->DefaultFont->tf_YSize + 1;
722 #ifndef TITLEHACK
723 #ifdef SKINS
724 if (hasskininfo)
726 struct windowclassprefs *wcprefs;
727 struct IntDrawInfo *dri;
728 if ((dri = (struct IntDrawInfo *)GetScreenDrawInfo(w->WScreen)))
730 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
731 w->BorderTop += wcprefs->titlebarincrement;
732 int_FreeCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
735 #endif
736 #endif
739 /* look for GACT_???BORDER gadgets which increase the BorderSizes */
741 if (nw.FirstGadget)
743 struct Gadget *gad;
745 for(gad = nw.FirstGadget; gad; gad = gad->NextGadget)
747 WORD gadx1, gady1, gadx2, gady2;
749 if (gad->Activation & GACT_LEFTBORDER)
751 /* may never be GFLG_RELRIGHT / GFLG_RELWIDTH */
753 gadx2 = gad->LeftEdge + gad->Width - 1;
754 if (gadx2 >= w->BorderLeft) w->BorderLeft = gadx2/* + 1*/;
757 if (gad->Activation & GACT_TOPBORDER)
759 /* may never be GFLG_RELBOTTOM / GFLG_RELHEIGHT */
761 gady2 = gad->TopEdge + gad->Height - 1;
762 if (gady2 >= w->BorderTop) w->BorderTop = gady2/* + 1*/;
765 if (gad->Activation & GACT_RIGHTBORDER)
767 /* must be GFLG_RELRIGHT but never GFLG_RELWIDTH */
769 gadx1 = -gad->LeftEdge;
770 if (gadx1 >= w->BorderRight) w->BorderRight = gadx1/* + 1*/;
773 if (gad->Activation & GACT_BOTTOMBORDER)
775 /* must be GFLG_RELBOTTOM but never GFLG_RELHEIGHT */
777 gady1 = -gad->TopEdge;
778 if (gady1 >= w->BorderBottom) w->BorderBottom = gady1/* + 1*/;
781 } /* for(gad = nw.FirstGadget; gad; gad = gad->NextGadget) */
783 } /* if (nw.FirstGadget) */
785 if (!(w->Flags & WFLG_SIZEBRIGHT)) if (w->BorderRight > w->WScreen->WBorRight)
787 w->Flags |= WFLG_SIZEBRIGHT;
790 if (!(w->Flags & WFLG_SIZEBBOTTOM)) if (w->BorderBottom > w->WScreen->WBorBottom)
792 w->Flags |= WFLG_SIZEBBOTTOM;
796 // if ((w->Flags & WFLG_SIZEGADGET) &&
797 // (w->Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
799 IPTR sizewidth = 16, sizeheight = 16;
800 struct Image *im;
801 struct DrawInfo *dri;
803 if ((dri = GetScreenDrawInfo(w->WScreen)))
805 struct TagItem imtags[] =
807 {SYSIA_DrawInfo , (STACKIPTR)dri },
808 {SYSIA_Which , SIZEIMAGE },
809 {SYSIA_Size , w->WScreen->Flags & SCREENHIRES ? SYSISIZE_MEDRES : SYSISIZE_LOWRES },
810 {TAG_DONE }
813 if ((im = NewObjectA(NULL, SYSICLASS, imtags)))
815 GetAttr(IA_Width, (Object *)im, &sizewidth);
816 GetAttr(IA_Height, (Object *)im, &sizeheight);
818 DisposeObject(im);
820 FreeScreenDrawInfo(w->WScreen, dri);
823 if (w->Flags & WFLG_SIZEBRIGHT)
825 if (w->BorderRight < sizewidth) w->BorderRight = sizewidth;
828 if (w->Flags & WFLG_SIZEBBOTTOM)
830 if (w->BorderBottom < sizeheight) w->BorderBottom = sizeheight;
833 IW(w)->sizeimage_width = sizewidth;
834 IW(w)->sizeimage_height = sizeheight;
836 /* now increase window size if it's necessary */
839 #ifdef SKINS
841 IW(w)->custombackfill.h_Entry = (HOOKFUNC)HookEntry;
842 IW(w)->custombackfill.h_SubEntry = (HOOKFUNC)GradientizeBackfillFunc;
843 IW(w)->custombackfill.h_Data = &IW(w)->hd;
844 IW(w)->hd.intuitionBase = IntuitionBase;
846 IW(w)->usertranspregion = usertranspregion;
847 IW(w)->usertransphook = usertransphook;
849 #endif
850 IW(w)->DefaultWindowShapeHook.h_Entry = (HOOKFUNC)DefaultWindowShapeFunc;
851 IW(w)->DefaultWindowShapeHook.h_SubEntry = (HOOKFUNC)w;
852 IW(w)->DefaultWindowShapeHook.h_Data = (APTR)IntuitionBase;
854 if (innerWidth != ~0) nw.Width = innerWidth + w->BorderLeft + w->BorderRight;
855 if (innerHeight != ~0) nw.Height = innerHeight + w->BorderTop + w->BorderBottom;
858 LONG parentwidth;
859 LONG parentheight;
861 parentwidth = parentwin ? parentwin->Width : w->WScreen->Width;
862 parentheight = parentwin ? parentwin->Height : w->WScreen->Height;
864 w->Width = (nw.Width != ~0) ? nw.Width : parentwidth - nw.LeftEdge;
865 w->Height = (nw.Height != ~0) ? nw.Height : parentheight - nw.TopEdge;
867 if (autoAdjust)
870 if (w->Width > parentwidth) w->Width = parentwidth;
871 if (w->Height > parentheight) w->Height = parentheight;
873 if (nw.LeftEdge < 0) nw.LeftEdge = 0;
874 if (nw.TopEdge < 0) nw.TopEdge = 0;
876 if ((nw.LeftEdge + w->Width) > parentwidth)
877 nw.LeftEdge = parentwidth - w->Width;
879 if ((nw.TopEdge + w->Height) > parentheight)
880 nw.TopEdge = parentheight - w->Height;
883 w->GZZWidth = w->Width - w->BorderLeft - w->BorderRight;
884 w->GZZHeight = w->Height - w->BorderTop - w->BorderBottom;
887 if (nw.LeftEdge < 0 || nw.TopEdge < 0 ||
888 nw.LeftEdge + w->Width > w->WScreen->Width ||
889 nw.TopEdge + w->Height > w->WScreen->Height)
890 goto failexit;
892 if (NULL == parentwin)
894 w->LeftEdge = nw.LeftEdge;
895 w->TopEdge = nw.TopEdge;
897 else
899 w->LeftEdge = nw.LeftEdge + parentwin->LeftEdge;
900 w->TopEdge = nw.TopEdge + parentwin->TopEdge;
903 #ifndef __MORPHOS__
904 w->RelLeftEdge = nw.LeftEdge;
905 w->RelTopEdge = nw.TopEdge;
906 #endif
908 w->MinWidth = (nw.MinWidth != 0) ? nw.MinWidth : w->Width;
909 w->MinHeight = (nw.MinHeight != 0) ? nw.MinHeight : w->Height;
910 w->MaxWidth = (nw.MaxWidth != 0) ? nw.MaxWidth : w->Width;
911 w->MaxHeight = (nw.MaxHeight != 0) ? nw.MaxHeight : w->Height;
913 //jDc: tested behavior of intuition68k
914 if ((UWORD)w->MaxWidth < w->Width) w->MaxWidth = w->Width;
915 if ((UWORD)w->MaxHeight < w->Height) w->MaxHeight = w->Height;
917 /* check if maxwidth/height is not bigger than screen */
918 if (w->MaxWidth > w->WScreen->Width) w->MaxWidth = w->WScreen->Width;
919 if (w->MaxHeight > w->WScreen->Height) w->MaxHeight = w->WScreen->Height;
921 if (zoombox)
923 ((struct IntWindow *)w)->ZipLeftEdge = zoombox->Left;
924 ((struct IntWindow *)w)->ZipTopEdge = zoombox->Top;
925 ((struct IntWindow *)w)->ZipWidth = zoombox->Width;
926 ((struct IntWindow *)w)->ZipHeight = zoombox->Height;
928 else
930 ((struct IntWindow *)w)->ZipLeftEdge = nw.LeftEdge;
931 ((struct IntWindow *)w)->ZipTopEdge = nw.TopEdge;
932 ((struct IntWindow *)w)->ZipWidth = (w->Width == w->MinWidth) ? w->MaxWidth : w->MinWidth;
933 ((struct IntWindow *)w)->ZipHeight = (w->Height == w->MinHeight) ? w->MaxHeight : w->MinHeight;
936 DEBUG_OPENWINDOW(dprintf("OpenWindow: zip %d %d %d %d\n",
937 ((struct IntWindow *)w)->ZipLeftEdge,
938 ((struct IntWindow *)w)->ZipTopEdge,
939 ((struct IntWindow *)w)->ZipWidth,
940 ((struct IntWindow *)w)->ZipHeight));
943 IW(w)->mousequeue = mousequeue;
944 IW(w)->repeatqueue = repeatqueue;
946 /* Amiga and checkmark images for menus */
948 IW(w)->Checkmark = Checkmark ? Checkmark :
949 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_CheckMark;
951 IW(w)->AmigaKey = AmigaKey ? AmigaKey :
952 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_AmigaKey;
953 IW(w)->SubMenuImage = ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_SubMenuImage;
955 #ifndef __MORPHOS__
956 /* child support */
957 if (NULL != parentwin)
959 if (parentwin->firstchild)
960 parentwin->firstchild->prevchild = w;
962 w->nextchild = parentwin->firstchild;
963 parentwin->firstchild = w;
964 w->parent = parentwin;
966 #endif
968 #ifdef SKINS
969 if (hasskininfo) ((struct IntWindow *)(w))->specialflags = SPFLAG_SKININFO;
970 #endif
972 #ifdef DAMAGECACHE
973 if ((w->Flags & WFLG_SIMPLE_REFRESH) && (IS_DOCAREREFRESH(w)) && (!(w->Flags & WFLG_BORDERLESS))) IW(w)->trashregion = NewRegion();
974 #endif
976 /* Help stuff */
978 if (!have_helpgroup && helpgroupwindow)
980 if (IW(helpgroupwindow)->helpflags & HELPF_ISHELPGROUP)
982 helpgroup = IW(helpgroupwindow)->helpgroup;
983 have_helpgroup = TRUE;
987 if (have_helpgroup)
989 IW(w)->helpflags |= HELPF_ISHELPGROUP;
990 IW(w)->helpgroup = helpgroup;
993 w->Title = nw.Title;
996 #if 1
998 /* Use safe OpenFont.. - Piru
1001 if (GetPrivScreen(w->WScreen)->SpecialFlags & SF_SysFont)
1003 w->IFont = SafeReopenFont(IntuitionBase, &GfxBase->DefaultFont);
1005 else
1007 w->IFont = SafeReopenFont(IntuitionBase, &(GetPrivScreen(w->WScreen)->DInfo.dri.dri_Font));
1010 if (w->IFont == NULL)
1011 goto failexit;
1013 #else
1015 #warning: Really hacky way of re-opening GfxBase->DefaultFont
1017 Forbid();
1018 w->IFont = GfxBase->DefaultFont;
1019 w->IFont->tf_Accessors++;
1020 Permit();
1022 #endif
1024 /* jDc: intui68k waits before opening the window until
1025 ** Move/SizeWindow actions are over (does it mean it's executed on
1026 ** caller's context?).
1029 #ifdef USEWINDOWLOCK
1030 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1032 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1034 #endif
1036 IW(w)->OutlineShape = NULL;
1038 if ((shapeti != NULL) || (shapehookti != NULL)) IW(w)->CustomShape = TRUE;
1039 if (!(IW(w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1041 shapehook = &IW(w)->DefaultWindowShapeHook;
1044 msg.window = w;
1045 msg.bitmap = nw.BitMap;
1046 //msg.backfillhook = backfillhook == LAYERS_BACKFILL ? &IW(w)->custombackfill : backfillhook;
1047 msg.backfillhook = backfillhook;
1048 msg.shape = shape;
1049 msg.shapehook = shapehook;
1050 msg.parentlayer = parentl;
1051 msg.visible = windowvisible;
1053 DoSyncAction((APTR)int_openwindow, &msg.msg, IntuitionBase);
1055 #ifdef USEWINDOWLOCK
1056 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1058 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1060 #endif
1062 if (!msg.success)
1063 goto failexit;
1065 /* nlorentz: The driver has in some way or another allocated a rastport for us,
1066 which now is ready for us to use. */
1068 driver_init_done = TRUE;
1069 rp = w->RPort;
1071 D(bug("called driver, rp=%p\n", rp));
1073 /* The window RastPort always gets the font from GfxBase->DefaultFont, which
1074 is the system's default font. Usually topaz 8, but it can be changed with
1075 the Fonts prefs program to another fixed-sized font. */
1077 SetFont (rp, w->IFont);
1079 D(bug("set fonts\n"));
1081 #warning Remove workaround!
1082 /* lbischoff: The following 4 Setxxx lines are a workaround for the InitRastPort
1083 problem (Bug #75 in docs/BUGS). They ensure that at least a window's rastport
1084 is initialized correctly. Remove them if they are not needed any longer!
1086 SetABPenDrMd (rp, rp->FgPen, rp->BgPen, rp->DrawMode);
1087 SetWriteMask (rp, rp->Mask);
1088 D(bug("set pens\n"));
1091 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
1092 /*DoGMLayout(w->FirstGadget, w, NULL, -1, TRUE, IntuitionBase);
1094 if (NULL != w->FirstGadget)
1095 RefreshGadgets (w->FirstGadget, w, NULL);
1098 if (nw.FirstGadget)
1100 struct IntDrawInfo *dri = &((struct IntScreen *)(w->WScreen))->DInfo;
1101 struct wdpLayoutBorderGadgets msg;
1103 msg.MethodID = WDM_LAYOUT_BORDERGADGETS;
1104 msg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;;
1105 msg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1106 msg.wdp_Window = w;
1107 msg.wdp_Gadgets = nw.FirstGadget;
1108 msg.wdp_Flags = WDF_LBG_INITIAL | WDF_LBG_MULTIPLE;
1109 msg.wdp_ExtraButtons = ((struct IntWindow *)w)->extrabuttons;
1110 msg.wdp_Dri = dri;
1112 DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&msg);
1114 AddGList(w, nw.FirstGadget, -1, -1, NULL);
1117 #if 0
1118 /* !!! This does double refreshing as the system gadgets also are refreshed
1119 in the above RfreshGadgets() call */
1120 if (nw.Flags & WFLG_ACTIVATE)
1122 /* RefreshWindowFrame() will be called from within ActivateWindow().
1123 No point in doing double refreshing. */
1125 ActivateWindow(w);
1127 else
1129 RefreshWindowFrame(w);
1131 #endif
1133 if (screenTitle != NULL)
1134 SetWindowTitles (w, (CONST_STRPTR)~0, screenTitle);
1136 UpdateMouseCoords(w);
1138 if (do_setwindowpointer)
1140 //jDc: main for () loop destroys original taglist pointer, we need to get
1141 //it once again here!
1142 tagList = (struct TagItem *)((struct ExtNewWindow *)newWindow)->Extension;
1143 SetWindowPointerA(w, tagList);
1146 #if 0
1147 ((struct IntWindow *)w)->OutlineShape = NULL;
1149 if ((shape != NULL) || (shapehook != NULL)) ((struct IntWindow *)w)->CustomShape = TRUE;
1150 if ((!((struct IntWindow *)w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1152 struct wdpWindowShape shapemsg;
1154 shapemsg.MethodID = WDM_WINDOWSHAPE;
1155 shapemsg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1156 shapemsg.wdp_Width = w->Width;
1157 shapemsg.wdp_Height = w->Height;
1158 shapemsg.wdp_Window = w;
1159 shapemsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
1161 shape = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&shapemsg);
1162 ((struct IntWindow *)w)->OutlineShape = shape;
1163 ChangeWindowShape(w, shape, NULL);
1164 ((struct IntWindow *)w)->CustomShape = FALSE;
1166 #endif
1168 goto exit;
1170 failexit:
1171 D(bug("fail\n"));
1173 if (w)
1175 ModifyIDCMP (w, 0);
1177 /* nlorentz: Freeing the rasport is now intui_CloseWindow()'s task.
1179 if (rp)
1181 FreeRastPort (rp);
1185 if (driver_init_done)
1186 intui_CloseWindow(w, IntuitionBase);
1188 if (w->IFont) CloseFont(w->IFont);
1190 if (((struct IntWindow *)w)->DecorUserBuffer)
1192 FreeMem((IPTR) ((struct IntWindow *)w)->DecorUserBuffer, ((struct IntWindow *)w)->DecorUserBufferSize);
1195 FreeMem (w, sizeof(struct IntWindow));
1197 w = NULL;
1200 if (nw.Screen && (moreFlags & WMFLG_DO_UNLOCKPUBSCREEN))
1202 UnlockPubScreen(NULL, nw.Screen);
1205 exit:
1207 DEBUG_OPENWINDOW(dprintf("OpenWindow: Return 0x%lx\n", w));
1209 FireScreenNotifyMessage((IPTR) w, SNOTIFY_AFTER_OPENWINDOW, IntuitionBase);
1211 ReturnPtr ("OpenWindow", struct Window *, w);
1212 AROS_LIBFUNC_EXIT
1213 } /* OpenWindow */
1217 /**********************************************************************************/
1219 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
1220 struct IntuitionBase *IntuitionBase)
1222 struct Window * w = msg->window;
1223 struct BitMap * SuperBitMap = msg->bitmap;
1224 struct Hook * backfillhook = msg->backfillhook;
1225 #ifdef CreateLayerTagList
1226 struct Region * shape = msg->shape;
1227 struct Hook * shapehook = msg->shapehook;
1228 struct Layer * parent = msg->parentlayer;
1229 BOOL visible = msg->visible;
1230 #endif
1232 #ifdef SKINS
1233 BOOL installtransphook = FALSE;
1234 BOOL notransphook = TRUE;
1235 #endif
1237 /* Create a layer for the window */
1238 LONG layerflags = 0;
1240 EnterFunc(bug("int_OpenWindow(w=%p)\n", w));
1242 D(bug("screen: %p\n", w->WScreen));
1243 D(bug("bitmap: %p\n", w->WScreen->RastPort.BitMap));
1245 /* Just insert some default values, should be taken from
1246 w->WScreen->WBorxxxx */
1248 /* Set the layer's flags according to the flags of the
1249 ** window
1252 /* refresh type */
1253 if (w->Flags & WFLG_SIMPLE_REFRESH)
1255 layerflags |= LAYERSIMPLE;
1257 else
1259 if (w->Flags & WFLG_SUPER_BITMAP && SuperBitMap)
1261 layerflags |= LAYERSUPER;
1263 else
1265 layerflags |= LAYERSMART;
1269 if (w->Flags & WFLG_BACKDROP)
1271 layerflags |= LAYERBACKDROP;
1274 D(bug("Window dims: (%d, %d, %d, %d)\n",
1275 w->LeftEdge, w->TopEdge, w->Width, w->Height));
1277 #ifdef SKINS
1278 //install transp layer hook!
1280 struct windowclassprefs *wcprefs = NULL;
1282 wcprefs = (struct windowclassprefs*)int_GetCustomPrefs(TYPE_WINDOWCLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1283 if (wcprefs->flags & WINDOWCLASS_PREFS_ROUNDEDEDGES && (w->Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET))))
1285 IW(w)->transpregion = NewRegion();
1286 if (IW(w)->transpregion)
1288 installtransphook = TRUE; notransphook = FALSE;
1289 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1292 else
1294 if (IW(w)->usertransphook)
1296 IW(w)->transpregion = NewRegion();
1297 if (IW(w)->transpregion)
1299 installtransphook = TRUE;
1300 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1303 else if (IW(w)->usertranspregion)
1305 IW(w)->transpregion = NewRegion();
1306 if (IW(w)->transpregion)
1308 installtransphook = TRUE;
1309 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1313 int_FreeCustomPrefs(TYPE_SYSICLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1315 #endif
1317 // LockLayers(&w->WScreen->LayerInfo);
1319 /* A GimmeZeroZero window??? */
1320 if (w->Flags & WFLG_GIMMEZEROZERO)
1323 A GimmeZeroZero window is to be created:
1324 - the outer window will be a simple refresh layer
1325 - the inner window will be a layer according to the flags
1326 What is the size of the inner/outer window supposed to be???
1327 I just make it that the outer window has the size of what is requested
1330 #ifdef __MORPHOS__
1332 struct TagItem layertags[] =
1334 {LA_BackfillHook, (IPTR)LAYERS_NOBACKFILL},
1335 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1336 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1337 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1338 {LA_WindowPtr, (IPTR)w},
1339 {TAG_DONE}
1344 /* First create outer window */
1345 struct Layer * L = CreateUpfrontLayerTagList(
1346 &w->WScreen->LayerInfo
1347 , w->WScreen->RastPort.BitMap
1348 , w->LeftEdge
1349 , w->TopEdge
1350 , w->LeftEdge + w->Width - 1
1351 , w->TopEdge + w->Height - 1
1352 , LAYERSIMPLE | (layerflags & LAYERBACKDROP)
1353 , (struct TagItem *)&layertags);
1355 #else
1356 /* First create outer window */
1358 struct TagItem lay_tags[] =
1360 {LA_Hook , (IPTR)LAYERS_NOBACKFILL },
1361 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1362 {LA_SuperBitMap , (IPTR)NULL },
1363 {LA_ChildOf , (IPTR)parent },
1364 {LA_Visible , (ULONG)visible },
1365 {TAG_DONE }
1368 struct Layer * L = CreateLayerTagList(&w->WScreen->LayerInfo,
1369 w->WScreen->RastPort.BitMap,
1370 w->RelLeftEdge,
1371 w->RelTopEdge,
1372 w->RelLeftEdge + w->Width - 1,
1373 w->RelTopEdge + w->Height - 1,
1374 LAYERSIMPLE | (layerflags & LAYERBACKDROP),
1375 lay_tags);
1377 #endif
1378 /* Could the layer be created. Nothing bad happened so far, so simply leave */
1379 if (NULL == L)
1381 msg->success = FALSE;
1382 // UnlockLayers(&w->WScreen->LayerInfo);
1383 ReturnVoid("intui_OpenWindow(No GimmeZeroZero layer)");
1386 D(bug("created outer GimmeZeroZero layer.\n"));
1388 /* install it as the BorderRPort */
1389 w->BorderRPort = L->rp;
1390 BLAYER(w) = L;
1392 /* This layer belongs to a window */
1393 #ifndef __MORPHOS__
1394 L->Window = (APTR)w;
1395 #endif
1397 #ifdef __MORPHOS__
1398 /* Now comes the inner window */
1399 layertags[0].ti_Data = (IPTR)backfillhook;
1400 w->WLayer = CreateUpfrontLayerTagList(
1401 &w->WScreen->LayerInfo
1402 , w->WScreen->RastPort.BitMap
1403 , w->LeftEdge + w->BorderLeft
1404 , w->TopEdge + w->BorderTop
1405 , w->LeftEdge + w->BorderLeft + w->GZZWidth - 1
1406 , w->TopEdge + w->BorderTop + w->GZZHeight - 1
1407 , layerflags
1408 , (struct TagItem *)&layertags);
1410 #else
1411 /* Now comes the inner window */
1414 struct TagItem lay_tags[] =
1416 {LA_Hook , (IPTR)backfillhook },
1417 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1418 {LA_Shape , (IPTR)shape },
1419 {LA_ShapeHook , (IPTR)shapehook },
1420 {LA_SuperBitMap , (IPTR)SuperBitMap },
1421 {LA_ChildOf , (IPTR)parent },
1422 {LA_Visible , (ULONG)visible },
1423 {TAG_DONE }
1426 w->WLayer = CreateLayerTagList(&w->WScreen->LayerInfo,
1427 w->WScreen->RastPort.BitMap,
1428 w->RelLeftEdge + w->BorderLeft,
1429 w->RelTopEdge + w->BorderTop,
1430 w->RelLeftEdge + w->BorderLeft + w->GZZWidth - 1,
1431 w->RelTopEdge + w->BorderTop + w->GZZHeight - 1,
1432 layerflags,
1433 lay_tags);
1437 #endif
1439 /* could this layer be created? If not then delete the outer window and exit */
1440 if (NULL == w->WLayer)
1442 DeleteLayer(0, L);
1443 msg->success = FALSE;
1444 // UnlockLayers(&w->WScreen->LayerInfo);
1445 ReturnVoid("intui_OpenWindow(No window layer)");
1448 /* That should do it, I guess... */
1450 else
1452 #ifdef __MORPHOS__
1454 struct TagItem layertags[] =
1456 {LA_BackfillHook, (IPTR)backfillhook},
1457 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1458 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1459 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1460 {LA_WindowPtr, (IPTR)w},
1461 {TAG_DONE}
1464 D(dprintf("CreateUpfontLayerTagList(taglist 0x%lx)\n",&layertags));
1466 w->WLayer = CreateUpfrontLayerTagList( &w->WScreen->LayerInfo,
1467 w->WScreen->RastPort.BitMap,
1468 w->LeftEdge,
1469 w->TopEdge,
1470 w->LeftEdge + w->Width - 1,
1471 w->TopEdge + w->Height - 1,
1472 layerflags,
1473 (struct TagItem *)&layertags);
1474 #else
1476 struct TagItem lay_tags[] =
1478 {LA_Hook , (IPTR)backfillhook },
1479 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1480 {LA_Shape , (IPTR)shape },
1481 {LA_ShapeHook , (IPTR)shapehook },
1482 {LA_SuperBitMap , (IPTR)SuperBitMap },
1483 {LA_ChildOf , (IPTR)parent },
1484 {LA_Visible , (ULONG)visible },
1485 {TAG_DONE }
1488 w->WLayer = CreateLayerTagList(&w->WScreen->LayerInfo,
1489 w->WScreen->RastPort.BitMap,
1490 w->RelLeftEdge,
1491 w->RelTopEdge,
1492 w->RelLeftEdge + w->Width - 1,
1493 w->RelTopEdge + w->Height - 1,
1494 layerflags,
1495 lay_tags);
1497 #endif
1499 /* Install the BorderRPort here! see GZZ window above */
1500 if (NULL != w->WLayer)
1503 I am installing a totally new RastPort here so window and frame can
1504 have different fonts etc.
1506 w->BorderRPort = AllocMem(sizeof(struct RastPort), MEMF_ANY);
1508 if (w->BorderRPort)
1510 InitRastPort(w->BorderRPort);
1511 w->BorderRPort->Layer = w->WLayer;
1512 w->BorderRPort->BitMap = w->WLayer->rp->BitMap;
1514 else
1516 /* no memory for RastPort! Simply close the window */
1517 intui_CloseWindow(w, IntuitionBase);
1518 msg->success = FALSE;
1519 // UnlockLayers(&w->WScreen->LayerInfo);
1520 ReturnVoid("intui_OpenWindow(No BorderRPort)");
1525 D(bug("Layer created: %p\n", w->WLayer));
1526 D(bug("Window created: %p\n", w));
1528 /* common code for GZZ and regular windows */
1530 if (w->WLayer)
1533 if ((layerflags & LAYERBACKDROP) && (w->WScreen->Flags & SHOWTITLE))
1535 #ifdef __MORPHOS__
1536 struct Layer *blayer;
1538 /* make sure the screen titlebar is in front of all user created */
1539 /* backdrop windows */
1541 blayer = w->WScreen->BarLayer;
1543 #ifdef SKINS
1544 if (GetPrivScreen(w->WScreen)->SpecialFlags & (SF_InvisibleBar|SF_AppearingBar)) blayer = 0;
1545 #endif
1547 if (blayer) MoveLayerInFrontOf(blayer,w->WLayer);
1549 D(bug("move screen bar layer in front of window backdrop layer\n"));
1550 #else
1551 /* backdrop window was created over screen barlayer, but it must be
1552 under the screen barlayer if screen has flag SHOWTITLE set */
1554 AROS_ATOMIC_AND(w->WScreen->Flags, ~SHOWTITLE);
1556 ShowTitle(w->WScreen, TRUE);
1557 #endif
1560 /* Layer gets pointer to the window */
1561 WLAYER(w) = w->WLayer;
1563 CheckLayers(w->WScreen,IntuitionBase);
1565 // UnlockLayers(&w->WScreen->LayerInfo);
1567 #ifndef __MORPHOS__
1568 w->WLayer->Window = (APTR)w;
1569 #endif
1570 /* Window needs a rastport */
1571 w->RPort = w->WLayer->rp;
1573 /* installation of the correct BorderRPort already happened above !! */
1575 if (CreateWinSysGadgets(w, IntuitionBase))
1577 LONG lock;
1579 lock = LockIBase (0);
1581 /* insert new window into parent/descendant list
1583 ** before: parent win xyz
1584 ** |
1585 ** |
1586 ** |
1587 ** descendant win abc
1589 ** after: parent win xyz
1590 ** \
1591 ** \
1592 ** newwindow w
1593 ** /
1594 ** /
1595 ** /
1596 ** descendant win abc
1599 #if 1
1601 struct Window *parent, *descendant_of_parent;
1603 parent = IntuitionBase->ActiveWindow;
1604 if (!parent) parent = w->WScreen->FirstWindow;
1605 if (parent)
1607 descendant_of_parent = parent->Descendant;
1608 parent->Descendant = w;
1609 if (descendant_of_parent) descendant_of_parent->Parent = w;
1611 else
1613 descendant_of_parent = NULL;
1616 w->Descendant = descendant_of_parent;
1617 w->Parent = parent;
1619 #endif
1621 w->NextWindow = w->WScreen->FirstWindow;
1622 w->WScreen->FirstWindow = w;
1624 w->WindowPort = GetPrivIBase(IntuitionBase)->IntuiReplyPort;
1626 UnlockIBase (lock);
1628 AddResourceToList(w, RESOURCE_WINDOW, IntuitionBase);
1630 if (w->Flags & WFLG_ACTIVATE)
1632 ActivateWindow(w);
1634 else
1636 RefreshWindowFrame(w);
1639 msg->success = TRUE;
1640 ReturnVoid("int_openwindow");
1643 CloseWindow(w);
1644 //int_closewindow(w, IntuitionBase);
1646 } /* if (layer created) */
1648 // UnlockLayers(&w->WScreen->LayerInfo);
1651 D(bug("int_openwindow(General failure)"));
1653 msg->success = FALSE;
1654 ReturnVoid("int_openwindow");