define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / intuition / openwindow.c
blob27ba5f61ec155d03a88f070764ee33950f13926b
1 /*
2 Copyright 1995-2009, 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 0
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 * Disabled at 12.03.2009 - many AROS targets don't have ROM in their memory lists, this
165 * results in ignoring taglist from bootmenu.
166 * Anyway this doesn't matter until AROS runs on m68k
167 * Pavel Fedin <sonic.amiga@gmail.com>
169 if (((ULONG) tagList & 1) || !TypeOfMem(tagList))
171 tagList = NULL;
173 #endif
175 else
177 tagList = NULL;
180 DEBUG_OPENWINDOW(dprintf("OpenWindow: NewWindow 0x%lx TagList 0x%lx\n",
181 newWindow, tagList));
183 if (tagList)
185 ASSERT_VALID_PTR_ROMOK(tagList);
187 /* Look at WA_Flags first, since boolean tags override part of it
188 * even if they appear before it.
190 nw.Flags |= (GetTagData(WA_Flags, nw.Flags, tagList) & ~WFLG_PRIVATEFLAGS);
192 while ((tag = NextTagItem (&tagList)))
194 /* ASSERT_VALID_PTR_ROMOK(tag); */
196 DEBUG_OPENWINDOW(dprintf("OpenWindow: Tag 0x%08lx 0x%08lx\n",
197 tag->ti_Tag, tag->ti_Data));
199 switch (tag->ti_Tag)
201 case WA_Left:
202 nw.LeftEdge = tag->ti_Data;
203 break;
205 case WA_Top:
206 nw.TopEdge = tag->ti_Data;
207 break;
209 case WA_Width:
210 nw.Width = tag->ti_Data;
211 break;
213 case WA_Height:
214 nw.Height = tag->ti_Data;
215 break;
217 case WA_IDCMP:
218 nw.IDCMPFlags = tag->ti_Data;
219 break;
221 case WA_MinWidth:
222 nw.MinWidth = tag->ti_Data;
223 break;
225 case WA_MinHeight:
226 nw.MinHeight = tag->ti_Data;
227 break;
229 case WA_MaxWidth:
230 nw.MaxWidth = tag->ti_Data;
231 break;
233 case WA_MaxHeight:
234 nw.MaxHeight = tag->ti_Data;
235 break;
237 case WA_Gadgets:
238 nw.FirstGadget = (struct Gadget *)(tag->ti_Data);
239 break;
241 case WA_Title:
242 nw.Title = (UBYTE *)(tag->ti_Data);
243 break;
245 case WA_ScreenTitle:
246 screenTitle = (UBYTE *)tag->ti_Data;
247 break;
249 case WA_AutoAdjust:
250 autoAdjust = (tag->ti_Data != 0);
251 break;
253 case WA_InnerWidth:
254 innerWidth = tag->ti_Data;
255 break;
257 case WA_InnerHeight:
258 innerHeight = tag->ti_Data;
259 break;
261 #define MODIFY_FLAG(name) if (tag->ti_Data) \
262 nw.Flags |= (name); else nw.Flags &= ~(name)
263 #define MODIFY_MFLAG(name) if (tag->ti_Data) \
264 moreFlags |= (name); else moreFlags &= ~(name)
266 case WA_SizeGadget:
267 MODIFY_FLAG(WFLG_SIZEGADGET);
268 break;
270 case WA_DragBar:
271 MODIFY_FLAG(WFLG_DRAGBAR);
272 break;
274 case WA_DepthGadget:
275 MODIFY_FLAG(WFLG_DEPTHGADGET);
276 break;
278 case WA_CloseGadget:
279 MODIFY_FLAG(WFLG_CLOSEGADGET);
280 break;
282 case WA_Backdrop:
283 MODIFY_FLAG(WFLG_BACKDROP);
284 break;
286 case WA_ReportMouse:
287 MODIFY_FLAG(WFLG_REPORTMOUSE);
288 break;
290 case WA_NoCareRefresh:
291 MODIFY_FLAG(WFLG_NOCAREREFRESH);
292 break;
294 case WA_Borderless:
295 MODIFY_FLAG(WFLG_BORDERLESS);
296 break;
298 case WA_Activate:
299 MODIFY_FLAG(WFLG_ACTIVATE);
300 break;
302 case WA_RMBTrap:
303 MODIFY_FLAG(WFLG_RMBTRAP);
304 break;
306 case WA_WBenchWindow:
307 MODIFY_FLAG(WFLG_WBENCHWINDOW);
308 break;
310 case WA_SizeBRight:
311 MODIFY_FLAG(WFLG_SIZEBRIGHT);
312 break;
314 case WA_SizeBBottom:
315 MODIFY_FLAG(WFLG_SIZEBBOTTOM);
316 break;
318 case WA_GimmeZeroZero:
319 MODIFY_FLAG(WFLG_GIMMEZEROZERO);
320 break;
322 case WA_NewLookMenus:
323 MODIFY_FLAG(WFLG_NEWLOOKMENUS);
324 break;
326 case WA_ToolBox:
327 MODIFY_FLAG(WFLG_TOOLBOX);
328 break;
330 case WA_Zoom:
331 zoombox = (struct IBox *)tag->ti_Data;
332 DEBUG_OPENWINDOW(dprintf("OpenWindow: zoom %d %d %d %d\n",
333 zoombox->Left, zoombox->Top, zoombox->Width, zoombox->Height));
334 MODIFY_FLAG(WFLG_HASZOOM);
335 break;
337 case WA_DetailPen:
338 if (nw.DetailPen == 0xFF)
339 nw.DetailPen = tag->ti_Data;
340 break;
342 case WA_BlockPen:
343 if (nw.BlockPen == 0xFF)
344 nw.BlockPen = tag->ti_Data;
345 break;
347 case WA_CustomScreen:
348 nw.Screen = (struct Screen *)(tag->ti_Data);
349 nw.Type = CUSTOMSCREEN;
350 break;
352 case WA_SuperBitMap:
353 nw.Flags |= WFLG_SUPER_BITMAP;
354 nw.BitMap = (struct BitMap *)(tag->ti_Data);
355 break;
357 case WA_SimpleRefresh:
358 if (tag->ti_Data)
359 nw.Flags |= WFLG_SIMPLE_REFRESH;
360 break;
362 case WA_SmartRefresh:
363 if (tag->ti_Data)
364 nw.Flags |= WFLG_SMART_REFRESH;
365 break;
367 case WA_PubScreenFallBack:
368 pubScreenFallBack = (tag->ti_Data ? TRUE : FALSE);
369 break;
371 case WA_PubScreenName:
372 //nw.Type = PUBLICSCREEN; //handled below!!
373 pubScreenName = (STRPTR)tag->ti_Data;
374 break;
376 case WA_PubScreen:
377 nw.Type = PUBLICSCREEN;
378 nw.Screen = (struct Screen *)tag->ti_Data;
379 break;
381 case WA_BackFill:
382 backfillhook = (struct Hook *)tag->ti_Data;
383 break;
385 case WA_MouseQueue:
386 mousequeue = tag->ti_Data;
387 break;
389 /* These two are not implemented in AmigaOS */
390 case WA_WindowName:
391 case WA_Colors:
392 break;
394 case WA_NotifyDepth:
395 MODIFY_MFLAG(WMFLG_NOTIFYDEPTH);
396 break;
398 case WA_RptQueue:
399 repeatqueue = tag->ti_Data;
400 break;
402 case WA_Checkmark:
403 Checkmark = (struct Image *)tag->ti_Data;
404 break;
406 case WA_AmigaKey:
407 AmigaKey = (struct Image *)tag->ti_Data;
408 break;
410 case WA_HelpGroup:
411 helpgroup = (ULONG)tag->ti_Data;
412 have_helpgroup = TRUE;
413 break;
415 case WA_HelpGroupWindow:
416 helpgroupwindow = (struct Window *)tag->ti_Data;
417 break;
419 case WA_MenuHelp:
420 MODIFY_MFLAG(WMFLG_MENUHELP);
421 break;
423 case WA_PointerDelay:
424 MODIFY_MFLAG(WMFLG_POINTERDELAY);
425 break;
427 case WA_TabletMessages:
428 MODIFY_MFLAG(WMFLG_TABLETMESSAGES);
429 break;
431 case WA_ExtraTitlebarGadgets:
432 extrabuttons = (ULONG)tag->ti_Data;
433 break;
435 case WA_ExtraGadgetsStartID:
436 extrabuttonsid = (ULONG)tag->ti_Data;
437 break;
439 case WA_ExtraGadget_Iconify:
440 if (tag->ti_Data)
442 extrabuttons |= ETG_ICONIFY;
444 else
446 extrabuttons &= ~ETG_ICONIFY;
448 break;
450 case WA_ExtraGadget_Lock:
451 if (tag->ti_Data)
453 extrabuttons |= ETG_LOCK;
455 else
457 extrabuttons &= ~ETG_LOCK;
459 break;
461 case WA_ExtraGadget_MUI:
462 if (tag->ti_Data)
464 extrabuttons |= ETG_MUI;
466 else
468 extrabuttons &= ~ETG_MUI;
470 break;
472 case WA_ExtraGadget_PopUp:
473 if (tag->ti_Data)
475 extrabuttons |= ETG_POPUP;
477 else
479 extrabuttons &= ~ETG_POPUP;
481 break;
483 case WA_ExtraGadget_Snapshot:
484 if (tag->ti_Data)
486 extrabuttons |= ETG_SNAPSHOT;
488 else
490 extrabuttons &= ~ETG_SNAPSHOT;
492 break;
494 case WA_ExtraGadget_Jump:
495 if (tag->ti_Data)
497 extrabuttons |= ETG_JUMP;
499 else
501 extrabuttons &= ~ETG_JUMP;
503 break;
505 #ifdef SKINS
506 case WA_SkinInfo:
507 skininfo = (struct SkinInfo *)tag->ti_Data;
508 hasskininfo = TRUE;
509 break;
511 case WA_TransparentRegion:
512 usertranspregion = (struct Region *)tag->ti_Data;
513 usertransphook = NULL; //doesn't make sense
514 break;
516 case WA_TransparentRegionHook:
517 usertransphook = (struct Hook *)tag->ti_Data;
518 usertranspregion = NULL;
519 break;
521 case WA_UserPort:
522 userport = (struct MsgPort *)tag->ti_Data;
523 break;
524 /**********************************************************************************/
526 case WA_IAmMUI:
527 MODIFY_MFLAG(WMFLG_IAMMUI);
528 break;
529 #endif
531 #ifndef __MORPHOS__
532 case WA_Shape:
533 shapeti = tag;
534 shape = (struct Region *)tag->ti_Data;
535 break;
537 case WA_ShapeHook:
538 shapehookti = tag;
539 shapehook = (struct Hook *)tag->ti_Data;
540 break;
543 case WA_Parent:
544 parentwin = ((struct Window *)tag->ti_Data);
545 parentl = parentwin->WLayer;
546 break;
548 case WA_Visible:
549 windowvisible = (ULONG)tag->ti_Data;
550 break;
551 #endif
553 case WA_Pointer:
554 case WA_BusyPointer:
555 do_setwindowpointer = TRUE;
556 break;
558 } /* switch Tag */
560 } /* while ((tag = NextTagItem (&tagList))) */
562 } /* if (tagList) */
564 if (nw.Flags & WFLG_SIZEGADGET)
566 if (!(nw.Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
568 nw.Flags |= WFLG_SIZEBRIGHT;
571 //jDc: tested behavior of intuition68k
572 nw.Flags |= WFLG_HASZOOM;
574 else
576 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM);
579 if (nw.Flags & WFLG_BORDERLESS)
581 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM|WFLG_SIZEGADGET);
584 /* Find out on which Screen the window must open */
586 /* (cyfm 03/03/03 check for nw.Type == PUBLICSCREEN as well, some programs
587 * like TurboPrint GraphicPublisher specify {WA_PubScreen, NULL} and want
588 * to open on the default public screen that way
591 if (!nw.Screen && (pubScreenName || (nw.Type == PUBLICSCREEN)))
593 struct Screen *pubs = 0;
595 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
596 pubs = LockPubScreen(pubScreenName);
597 if (!pubs && pubScreenFallBack)
599 nw.Screen = LockPubScreen(NULL);
601 if (pubs)
603 nw.Screen = pubs;
605 nw.Type = PUBLICSCREEN;
606 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
609 if (!nw.Screen && nw.Type == WBENCHSCREEN)
611 nw.Screen = LockPubScreen("Workbench");
612 if (nw.Screen)
614 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
615 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
619 if (nw.Screen == NULL)
620 goto failexit;
622 w = AllocMem (sizeof(struct IntWindow), MEMF_CLEAR);
624 DEBUG_OPENWINDOW(dprintf("OpenWindow: Window 0x%lx\n", w));
626 /* nlorentz: For now, creating a rastport becomes the responsibility of
627 intui_OpenWindow(). This is because intui_OpenWindow() in
628 config/hidd/intuition_driver.c must call CreateUpfrontLayer(),
629 and that will create a rastport for the layer/window, and we don't
630 want two rastports pr. window.
631 Alternatively we may create a layers_driver.c driver for layers,
632 and then call CreateUpfrontLayer() here from openwindow.
633 For the Amiga window<-->X11 window stuff, the layers driver
634 would just allocate a layer struct, a rastport and
635 put the rasport into layer->RastPort, so we
636 could get it inside this routine and put it into
637 window->RPort;.
641 if (NULL == w)
642 goto failexit;
644 DEBUG_OPENWINDOW(dprintf("OpenWindow: Flags 0x%lx MoreFlags 0x%lx IDCMP 0x%lx\n",
645 nw.Flags, moreFlags, nw.IDCMPFlags));
646 IPTR userbuffersize;
648 GetAttr(WDA_UserBuffer, ((struct IntScreen *)(nw.Screen))->WinDecorObj, &userbuffersize);
650 if (userbuffersize)
652 ((struct IntWindow *)w)->DecorUserBufferSize = userbuffersize;
653 ((struct IntWindow *)w)->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
654 if (0 == ((struct IntWindow *)w)->DecorUserBuffer)
655 goto failexit;
658 struct wdpInitWindow initmsg;
659 BOOL ok;
661 initmsg.MethodID = WDM_INITWINDOW;
662 initmsg.wdp_TrueColor = (((struct IntScreen *) nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
663 initmsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
664 initmsg.wdp_ScreenUserBuffer = ((struct IntScreen *) nw.Screen)->DecorUserBuffer;
665 initmsg.wdp_Screen = nw.Screen;
667 ok = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&initmsg);
669 if (!ok) goto failexit;
671 w->WScreen = nw.Screen;
673 #ifdef SKINS
674 if (userport)
676 w->UserPort = userport;
677 ((struct IntWindow *)w)->specialflags |= SPFLAG_USERPORT;
679 #endif
681 if (!ModifyIDCMP (w, nw.IDCMPFlags))
682 goto failexit;
684 ((struct IntWindow *)w)->extrabuttons = extrabuttons;
685 ((struct IntWindow *)w)->extrabuttonsid = extrabuttonsid;
687 /* w->RPort = rp; */
689 //w->FirstGadget = nw.FirstGadget;
691 w->DetailPen = (nw.DetailPen != 0xFF) ? nw.DetailPen : w->WScreen->DetailPen;
692 w->BlockPen = (nw.BlockPen != 0xFF) ? nw.BlockPen : w->WScreen->BlockPen;
694 /* Copy flags */
695 w->Flags = nw.Flags;
696 w->MoreFlags = moreFlags;
698 if (!(w->Flags & WFLG_BORDERLESS))
700 w->BorderLeft = w->WScreen->WBorLeft;
701 w->BorderRight = w->WScreen->WBorRight;
702 #ifdef TITLEHACK
703 w->BorderTop = w->WScreen->WBorBottom;
704 #else
705 w->BorderTop = w->WScreen->WBorTop;
706 #endif
707 w->BorderBottom = w->WScreen->WBorBottom;
710 if (nw.Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET)))
712 /* this is a hack. the correct way to "correct" (increase if necessary)
713 the w->Border??? items would be to check all GACT_???BORDER gadgets
714 (inclusive sysgadgets which are GACT_????BORDER gadgets as well) in
715 nw.FirstGadget (or WA_Gadgets tag) and all sysgadgets and then
716 make sure that each window border is big enough so that none of these
717 gadgets extends outside the window border area */
719 #ifdef TITLEHACK
720 w->BorderTop = w->WScreen->WBorTop;
721 #endif
722 /* Georg Steger: ??? font ??? */
723 if (w->WScreen->Font)
724 w->BorderTop += ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_Font->tf_YSize + 1;
725 else
726 w->BorderTop += GfxBase->DefaultFont->tf_YSize + 1;
727 #ifndef TITLEHACK
728 #ifdef SKINS
729 if (hasskininfo)
731 struct windowclassprefs *wcprefs;
732 struct IntDrawInfo *dri;
733 if ((dri = (struct IntDrawInfo *)GetScreenDrawInfo(w->WScreen)))
735 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
736 w->BorderTop += wcprefs->titlebarincrement;
737 int_FreeCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
740 #endif
741 #endif
744 /* look for GACT_???BORDER gadgets which increase the BorderSizes */
746 if (nw.FirstGadget)
748 struct Gadget *gad;
750 for(gad = nw.FirstGadget; gad; gad = gad->NextGadget)
752 WORD gadx1, gady1, gadx2, gady2;
754 if (gad->Activation & GACT_LEFTBORDER)
756 /* may never be GFLG_RELRIGHT / GFLG_RELWIDTH */
758 gadx2 = gad->LeftEdge + gad->Width - 1;
759 if (gadx2 >= w->BorderLeft) w->BorderLeft = gadx2/* + 1*/;
762 if (gad->Activation & GACT_TOPBORDER)
764 /* may never be GFLG_RELBOTTOM / GFLG_RELHEIGHT */
766 gady2 = gad->TopEdge + gad->Height - 1;
767 if (gady2 >= w->BorderTop) w->BorderTop = gady2/* + 1*/;
770 if (gad->Activation & GACT_RIGHTBORDER)
772 /* must be GFLG_RELRIGHT but never GFLG_RELWIDTH */
774 gadx1 = -gad->LeftEdge;
775 if (gadx1 >= w->BorderRight) w->BorderRight = gadx1/* + 1*/;
778 if (gad->Activation & GACT_BOTTOMBORDER)
780 /* must be GFLG_RELBOTTOM but never GFLG_RELHEIGHT */
782 gady1 = -gad->TopEdge;
783 if (gady1 >= w->BorderBottom) w->BorderBottom = gady1/* + 1*/;
786 } /* for(gad = nw.FirstGadget; gad; gad = gad->NextGadget) */
788 } /* if (nw.FirstGadget) */
790 if (!(w->Flags & WFLG_SIZEBRIGHT)) if (w->BorderRight > w->WScreen->WBorRight)
792 w->Flags |= WFLG_SIZEBRIGHT;
795 if (!(w->Flags & WFLG_SIZEBBOTTOM)) if (w->BorderBottom > w->WScreen->WBorBottom)
797 w->Flags |= WFLG_SIZEBBOTTOM;
801 // if ((w->Flags & WFLG_SIZEGADGET) &&
802 // (w->Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
804 IPTR sizewidth = 16, sizeheight = 16;
805 struct Image *im;
806 struct DrawInfo *dri;
808 if ((dri = GetScreenDrawInfo(w->WScreen)))
810 struct TagItem imtags[] =
812 {SYSIA_DrawInfo , (STACKIPTR)dri },
813 {SYSIA_Which , SIZEIMAGE },
814 {SYSIA_Size , w->WScreen->Flags & SCREENHIRES ? SYSISIZE_MEDRES : SYSISIZE_LOWRES },
815 {TAG_DONE }
818 if ((im = NewObjectA(NULL, SYSICLASS, imtags)))
820 GetAttr(IA_Width, (Object *)im, &sizewidth);
821 GetAttr(IA_Height, (Object *)im, &sizeheight);
823 DisposeObject(im);
825 FreeScreenDrawInfo(w->WScreen, dri);
828 if (w->Flags & WFLG_SIZEBRIGHT)
830 if (w->BorderRight < sizewidth) w->BorderRight = sizewidth;
833 if (w->Flags & WFLG_SIZEBBOTTOM)
835 if (w->BorderBottom < sizeheight) w->BorderBottom = sizeheight;
838 IW(w)->sizeimage_width = sizewidth;
839 IW(w)->sizeimage_height = sizeheight;
841 /* now increase window size if it's necessary */
844 #ifdef SKINS
846 IW(w)->custombackfill.h_Entry = (HOOKFUNC)HookEntry;
847 IW(w)->custombackfill.h_SubEntry = (HOOKFUNC)GradientizeBackfillFunc;
848 IW(w)->custombackfill.h_Data = &IW(w)->hd;
849 IW(w)->hd.intuitionBase = IntuitionBase;
851 IW(w)->usertranspregion = usertranspregion;
852 IW(w)->usertransphook = usertransphook;
854 #endif
855 IW(w)->DefaultWindowShapeHook.h_Entry = (HOOKFUNC)DefaultWindowShapeFunc;
856 IW(w)->DefaultWindowShapeHook.h_SubEntry = (HOOKFUNC)w;
857 IW(w)->DefaultWindowShapeHook.h_Data = (APTR)IntuitionBase;
859 if (innerWidth != ~0) nw.Width = innerWidth + w->BorderLeft + w->BorderRight;
860 if (innerHeight != ~0) nw.Height = innerHeight + w->BorderTop + w->BorderBottom;
863 LONG parentwidth;
864 LONG parentheight;
866 parentwidth = parentwin ? parentwin->Width : w->WScreen->Width;
867 parentheight = parentwin ? parentwin->Height : w->WScreen->Height;
869 w->Width = (nw.Width != ~0) ? nw.Width : parentwidth - nw.LeftEdge;
870 w->Height = (nw.Height != ~0) ? nw.Height : parentheight - nw.TopEdge;
872 if (autoAdjust)
875 if (w->Width > parentwidth) w->Width = parentwidth;
876 if (w->Height > parentheight) w->Height = parentheight;
878 if (nw.LeftEdge < 0) nw.LeftEdge = 0;
879 if (nw.TopEdge < 0) nw.TopEdge = 0;
881 if ((nw.LeftEdge + w->Width) > parentwidth)
882 nw.LeftEdge = parentwidth - w->Width;
884 if ((nw.TopEdge + w->Height) > parentheight)
885 nw.TopEdge = parentheight - w->Height;
888 w->GZZWidth = w->Width - w->BorderLeft - w->BorderRight;
889 w->GZZHeight = w->Height - w->BorderTop - w->BorderBottom;
892 if (nw.LeftEdge < 0 || nw.TopEdge < 0 ||
893 nw.LeftEdge + w->Width > w->WScreen->Width ||
894 nw.TopEdge + w->Height > w->WScreen->Height)
895 goto failexit;
897 if (NULL == parentwin)
899 w->LeftEdge = nw.LeftEdge;
900 w->TopEdge = nw.TopEdge;
902 else
904 w->LeftEdge = nw.LeftEdge + parentwin->LeftEdge;
905 w->TopEdge = nw.TopEdge + parentwin->TopEdge;
908 #ifndef __MORPHOS__
909 w->RelLeftEdge = nw.LeftEdge;
910 w->RelTopEdge = nw.TopEdge;
911 #endif
913 w->MinWidth = (nw.MinWidth != 0) ? nw.MinWidth : w->Width;
914 w->MinHeight = (nw.MinHeight != 0) ? nw.MinHeight : w->Height;
915 w->MaxWidth = (nw.MaxWidth != 0) ? nw.MaxWidth : w->Width;
916 w->MaxHeight = (nw.MaxHeight != 0) ? nw.MaxHeight : w->Height;
918 //jDc: tested behavior of intuition68k
919 if ((UWORD)w->MaxWidth < w->Width) w->MaxWidth = w->Width;
920 if ((UWORD)w->MaxHeight < w->Height) w->MaxHeight = w->Height;
922 /* check if maxwidth/height is not bigger than screen */
923 if (w->MaxWidth > w->WScreen->Width) w->MaxWidth = w->WScreen->Width;
924 if (w->MaxHeight > w->WScreen->Height) w->MaxHeight = w->WScreen->Height;
926 if (zoombox)
928 ((struct IntWindow *)w)->ZipLeftEdge = zoombox->Left;
929 ((struct IntWindow *)w)->ZipTopEdge = zoombox->Top;
930 ((struct IntWindow *)w)->ZipWidth = zoombox->Width;
931 ((struct IntWindow *)w)->ZipHeight = zoombox->Height;
933 else
935 ((struct IntWindow *)w)->ZipLeftEdge = nw.LeftEdge;
936 ((struct IntWindow *)w)->ZipTopEdge = nw.TopEdge;
937 ((struct IntWindow *)w)->ZipWidth = (w->Width == w->MinWidth) ? w->MaxWidth : w->MinWidth;
938 ((struct IntWindow *)w)->ZipHeight = (w->Height == w->MinHeight) ? w->MaxHeight : w->MinHeight;
941 DEBUG_OPENWINDOW(dprintf("OpenWindow: zip %d %d %d %d\n",
942 ((struct IntWindow *)w)->ZipLeftEdge,
943 ((struct IntWindow *)w)->ZipTopEdge,
944 ((struct IntWindow *)w)->ZipWidth,
945 ((struct IntWindow *)w)->ZipHeight));
948 IW(w)->mousequeue = mousequeue;
949 IW(w)->repeatqueue = repeatqueue;
951 /* Amiga and checkmark images for menus */
953 IW(w)->Checkmark = Checkmark ? Checkmark :
954 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_CheckMark;
956 IW(w)->AmigaKey = AmigaKey ? AmigaKey :
957 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_AmigaKey;
958 IW(w)->SubMenuImage = ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_SubMenuImage;
960 #ifndef __MORPHOS__
961 /* child support */
962 if (NULL != parentwin)
964 if (parentwin->firstchild)
965 parentwin->firstchild->prevchild = w;
967 w->nextchild = parentwin->firstchild;
968 parentwin->firstchild = w;
969 w->parent = parentwin;
971 #endif
973 #ifdef SKINS
974 if (hasskininfo) ((struct IntWindow *)(w))->specialflags = SPFLAG_SKININFO;
975 #endif
977 #ifdef DAMAGECACHE
978 if ((w->Flags & WFLG_SIMPLE_REFRESH) && (IS_DOCAREREFRESH(w)) && (!(w->Flags & WFLG_BORDERLESS))) IW(w)->trashregion = NewRegion();
979 #endif
981 /* Help stuff */
983 if (!have_helpgroup && helpgroupwindow)
985 if (IW(helpgroupwindow)->helpflags & HELPF_ISHELPGROUP)
987 helpgroup = IW(helpgroupwindow)->helpgroup;
988 have_helpgroup = TRUE;
992 if (have_helpgroup)
994 IW(w)->helpflags |= HELPF_ISHELPGROUP;
995 IW(w)->helpgroup = helpgroup;
998 w->Title = nw.Title;
1001 #if 1
1003 /* Use safe OpenFont.. - Piru
1006 if (GetPrivScreen(w->WScreen)->SpecialFlags & SF_SysFont)
1008 w->IFont = SafeReopenFont(IntuitionBase, &GfxBase->DefaultFont);
1010 else
1012 w->IFont = SafeReopenFont(IntuitionBase, &(GetPrivScreen(w->WScreen)->DInfo.dri.dri_Font));
1015 if (w->IFont == NULL)
1016 goto failexit;
1018 #else
1020 #warning: Really hacky way of re-opening GfxBase->DefaultFont
1022 Forbid();
1023 w->IFont = GfxBase->DefaultFont;
1024 w->IFont->tf_Accessors++;
1025 Permit();
1027 #endif
1029 /* jDc: intui68k waits before opening the window until
1030 ** Move/SizeWindow actions are over (does it mean it's executed on
1031 ** caller's context?).
1034 #ifdef USEWINDOWLOCK
1035 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1037 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1039 #endif
1041 IW(w)->OutlineShape = NULL;
1043 if ((shapeti != NULL) || (shapehookti != NULL)) IW(w)->CustomShape = TRUE;
1044 if (!(IW(w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1046 shapehook = &IW(w)->DefaultWindowShapeHook;
1049 msg.window = w;
1050 msg.bitmap = nw.BitMap;
1051 //msg.backfillhook = backfillhook == LAYERS_BACKFILL ? &IW(w)->custombackfill : backfillhook;
1052 msg.backfillhook = backfillhook;
1053 msg.shape = shape;
1054 msg.shapehook = shapehook;
1055 msg.parentlayer = parentl;
1056 msg.visible = windowvisible;
1058 DoSyncAction((APTR)int_openwindow, &msg.msg, IntuitionBase);
1060 #ifdef USEWINDOWLOCK
1061 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1063 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1065 #endif
1067 if (!msg.success)
1068 goto failexit;
1070 /* nlorentz: The driver has in some way or another allocated a rastport for us,
1071 which now is ready for us to use. */
1073 driver_init_done = TRUE;
1074 rp = w->RPort;
1076 D(bug("called driver, rp=%p\n", rp));
1078 /* The window RastPort always gets the font from GfxBase->DefaultFont, which
1079 is the system's default font. Usually topaz 8, but it can be changed with
1080 the Fonts prefs program to another fixed-sized font. */
1082 SetFont (rp, w->IFont);
1084 D(bug("set fonts\n"));
1086 #warning Remove workaround!
1087 /* lbischoff: The following 4 Setxxx lines are a workaround for the InitRastPort
1088 problem (Bug #75 in docs/BUGS). They ensure that at least a window's rastport
1089 is initialized correctly. Remove them if they are not needed any longer!
1091 SetABPenDrMd (rp, rp->FgPen, rp->BgPen, rp->DrawMode);
1092 SetWriteMask (rp, rp->Mask);
1093 D(bug("set pens\n"));
1096 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
1097 /*DoGMLayout(w->FirstGadget, w, NULL, -1, TRUE, IntuitionBase);
1099 if (NULL != w->FirstGadget)
1100 RefreshGadgets (w->FirstGadget, w, NULL);
1103 if (nw.FirstGadget)
1105 struct IntDrawInfo *dri = &((struct IntScreen *)(w->WScreen))->DInfo;
1106 struct wdpLayoutBorderGadgets msg;
1108 msg.MethodID = WDM_LAYOUT_BORDERGADGETS;
1109 msg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;;
1110 msg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1111 msg.wdp_Window = w;
1112 msg.wdp_Gadgets = nw.FirstGadget;
1113 msg.wdp_Flags = WDF_LBG_INITIAL | WDF_LBG_MULTIPLE;
1114 msg.wdp_ExtraButtons = ((struct IntWindow *)w)->extrabuttons;
1115 msg.wdp_Dri = dri;
1117 DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&msg);
1119 AddGList(w, nw.FirstGadget, -1, -1, NULL);
1122 #if 0
1123 /* !!! This does double refreshing as the system gadgets also are refreshed
1124 in the above RfreshGadgets() call */
1125 if (nw.Flags & WFLG_ACTIVATE)
1127 /* RefreshWindowFrame() will be called from within ActivateWindow().
1128 No point in doing double refreshing. */
1130 ActivateWindow(w);
1132 else
1134 RefreshWindowFrame(w);
1136 #endif
1138 if (screenTitle != NULL)
1139 SetWindowTitles (w, (CONST_STRPTR)~0, screenTitle);
1141 UpdateMouseCoords(w);
1143 if (do_setwindowpointer)
1145 //jDc: main for () loop destroys original taglist pointer, we need to get
1146 //it once again here!
1147 tagList = (struct TagItem *)((struct ExtNewWindow *)newWindow)->Extension;
1148 SetWindowPointerA(w, tagList);
1151 #if 0
1152 ((struct IntWindow *)w)->OutlineShape = NULL;
1154 if ((shape != NULL) || (shapehook != NULL)) ((struct IntWindow *)w)->CustomShape = TRUE;
1155 if ((!((struct IntWindow *)w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1157 struct wdpWindowShape shapemsg;
1159 shapemsg.MethodID = WDM_WINDOWSHAPE;
1160 shapemsg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1161 shapemsg.wdp_Width = w->Width;
1162 shapemsg.wdp_Height = w->Height;
1163 shapemsg.wdp_Window = w;
1164 shapemsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
1166 shape = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&shapemsg);
1167 ((struct IntWindow *)w)->OutlineShape = shape;
1168 ChangeWindowShape(w, shape, NULL);
1169 ((struct IntWindow *)w)->CustomShape = FALSE;
1171 #endif
1173 goto exit;
1175 failexit:
1176 D(bug("fail\n"));
1178 if (w)
1180 ModifyIDCMP (w, 0);
1182 /* nlorentz: Freeing the rasport is now intui_CloseWindow()'s task.
1184 if (rp)
1186 FreeRastPort (rp);
1190 if (driver_init_done)
1191 intui_CloseWindow(w, IntuitionBase);
1193 if (w->IFont) CloseFont(w->IFont);
1195 if (((struct IntWindow *)w)->DecorUserBuffer)
1197 FreeMem((APTR)((struct IntWindow *)w)->DecorUserBuffer, ((struct IntWindow *)w)->DecorUserBufferSize);
1200 FreeMem (w, sizeof(struct IntWindow));
1202 w = NULL;
1205 if (nw.Screen && (moreFlags & WMFLG_DO_UNLOCKPUBSCREEN))
1207 UnlockPubScreen(NULL, nw.Screen);
1210 exit:
1212 DEBUG_OPENWINDOW(dprintf("OpenWindow: Return 0x%lx\n", w));
1214 FireScreenNotifyMessage((IPTR) w, SNOTIFY_AFTER_OPENWINDOW, IntuitionBase);
1216 ReturnPtr ("OpenWindow", struct Window *, w);
1217 AROS_LIBFUNC_EXIT
1218 } /* OpenWindow */
1222 /**********************************************************************************/
1224 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
1225 struct IntuitionBase *IntuitionBase)
1227 struct Window * w = msg->window;
1228 struct BitMap * SuperBitMap = msg->bitmap;
1229 struct Hook * backfillhook = msg->backfillhook;
1230 #ifdef CreateLayerTagList
1231 struct Region * shape = msg->shape;
1232 struct Hook * shapehook = msg->shapehook;
1233 struct Layer * parent = msg->parentlayer;
1234 BOOL visible = msg->visible;
1235 #endif
1237 #ifdef SKINS
1238 BOOL installtransphook = FALSE;
1239 BOOL notransphook = TRUE;
1240 #endif
1242 /* Create a layer for the window */
1243 LONG layerflags = 0;
1245 EnterFunc(bug("int_OpenWindow(w=%p)\n", w));
1247 D(bug("screen: %p\n", w->WScreen));
1248 D(bug("bitmap: %p\n", w->WScreen->RastPort.BitMap));
1250 /* Just insert some default values, should be taken from
1251 w->WScreen->WBorxxxx */
1253 /* Set the layer's flags according to the flags of the
1254 ** window
1257 /* refresh type */
1258 if (w->Flags & WFLG_SIMPLE_REFRESH)
1260 layerflags |= LAYERSIMPLE;
1262 else
1264 if (w->Flags & WFLG_SUPER_BITMAP && SuperBitMap)
1266 layerflags |= LAYERSUPER;
1268 else
1270 layerflags |= LAYERSMART;
1274 if (w->Flags & WFLG_BACKDROP)
1276 layerflags |= LAYERBACKDROP;
1279 D(bug("Window dims: (%d, %d, %d, %d)\n",
1280 w->LeftEdge, w->TopEdge, w->Width, w->Height));
1282 #ifdef SKINS
1283 //install transp layer hook!
1285 struct windowclassprefs *wcprefs = NULL;
1287 wcprefs = (struct windowclassprefs*)int_GetCustomPrefs(TYPE_WINDOWCLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1288 if (wcprefs->flags & WINDOWCLASS_PREFS_ROUNDEDEDGES && (w->Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET))))
1290 IW(w)->transpregion = NewRegion();
1291 if (IW(w)->transpregion)
1293 installtransphook = TRUE; notransphook = FALSE;
1294 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1297 else
1299 if (IW(w)->usertransphook)
1301 IW(w)->transpregion = NewRegion();
1302 if (IW(w)->transpregion)
1304 installtransphook = TRUE;
1305 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1308 else if (IW(w)->usertranspregion)
1310 IW(w)->transpregion = NewRegion();
1311 if (IW(w)->transpregion)
1313 installtransphook = TRUE;
1314 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1318 int_FreeCustomPrefs(TYPE_SYSICLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1320 #endif
1322 // LockLayers(&w->WScreen->LayerInfo);
1324 /* A GimmeZeroZero window??? */
1325 if (w->Flags & WFLG_GIMMEZEROZERO)
1328 A GimmeZeroZero window is to be created:
1329 - the outer window will be a simple refresh layer
1330 - the inner window will be a layer according to the flags
1331 What is the size of the inner/outer window supposed to be???
1332 I just make it that the outer window has the size of what is requested
1335 #ifdef __MORPHOS__
1337 struct TagItem layertags[] =
1339 {LA_BackfillHook, (IPTR)LAYERS_NOBACKFILL},
1340 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1341 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1342 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1343 {LA_WindowPtr, (IPTR)w},
1344 {TAG_DONE}
1349 /* First create outer window */
1350 struct Layer * L = CreateUpfrontLayerTagList(
1351 &w->WScreen->LayerInfo
1352 , w->WScreen->RastPort.BitMap
1353 , w->LeftEdge
1354 , w->TopEdge
1355 , w->LeftEdge + w->Width - 1
1356 , w->TopEdge + w->Height - 1
1357 , LAYERSIMPLE | (layerflags & LAYERBACKDROP)
1358 , (struct TagItem *)&layertags);
1360 #else
1361 /* First create outer window */
1363 struct TagItem lay_tags[] =
1365 {LA_Hook , (IPTR)LAYERS_NOBACKFILL },
1366 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1367 {LA_SuperBitMap , (IPTR)NULL },
1368 {LA_ChildOf , (IPTR)parent },
1369 {LA_Visible , (ULONG)visible },
1370 {TAG_DONE }
1373 struct Layer * L = CreateLayerTagList(&w->WScreen->LayerInfo,
1374 w->WScreen->RastPort.BitMap,
1375 w->RelLeftEdge,
1376 w->RelTopEdge,
1377 w->RelLeftEdge + w->Width - 1,
1378 w->RelTopEdge + w->Height - 1,
1379 LAYERSIMPLE | (layerflags & LAYERBACKDROP),
1380 lay_tags);
1382 #endif
1383 /* Could the layer be created. Nothing bad happened so far, so simply leave */
1384 if (NULL == L)
1386 msg->success = FALSE;
1387 // UnlockLayers(&w->WScreen->LayerInfo);
1388 ReturnVoid("intui_OpenWindow(No GimmeZeroZero layer)");
1391 D(bug("created outer GimmeZeroZero layer.\n"));
1393 /* install it as the BorderRPort */
1394 w->BorderRPort = L->rp;
1395 BLAYER(w) = L;
1397 /* This layer belongs to a window */
1398 #ifndef __MORPHOS__
1399 L->Window = (APTR)w;
1400 #endif
1402 #ifdef __MORPHOS__
1403 /* Now comes the inner window */
1404 layertags[0].ti_Data = (IPTR)backfillhook;
1405 w->WLayer = CreateUpfrontLayerTagList(
1406 &w->WScreen->LayerInfo
1407 , w->WScreen->RastPort.BitMap
1408 , w->LeftEdge + w->BorderLeft
1409 , w->TopEdge + w->BorderTop
1410 , w->LeftEdge + w->BorderLeft + w->GZZWidth - 1
1411 , w->TopEdge + w->BorderTop + w->GZZHeight - 1
1412 , layerflags
1413 , (struct TagItem *)&layertags);
1415 #else
1416 /* Now comes the inner window */
1419 struct TagItem lay_tags[] =
1421 {LA_Hook , (IPTR)backfillhook },
1422 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1423 {LA_Shape , (IPTR)shape },
1424 {LA_ShapeHook , (IPTR)shapehook },
1425 {LA_SuperBitMap , (IPTR)SuperBitMap },
1426 {LA_ChildOf , (IPTR)parent },
1427 {LA_Visible , (ULONG)visible },
1428 {TAG_DONE }
1431 w->WLayer = CreateLayerTagList(&w->WScreen->LayerInfo,
1432 w->WScreen->RastPort.BitMap,
1433 w->RelLeftEdge + w->BorderLeft,
1434 w->RelTopEdge + w->BorderTop,
1435 w->RelLeftEdge + w->BorderLeft + w->GZZWidth - 1,
1436 w->RelTopEdge + w->BorderTop + w->GZZHeight - 1,
1437 layerflags,
1438 lay_tags);
1442 #endif
1444 /* could this layer be created? If not then delete the outer window and exit */
1445 if (NULL == w->WLayer)
1447 DeleteLayer(0, L);
1448 msg->success = FALSE;
1449 // UnlockLayers(&w->WScreen->LayerInfo);
1450 ReturnVoid("intui_OpenWindow(No window layer)");
1453 /* That should do it, I guess... */
1455 else
1457 #ifdef __MORPHOS__
1459 struct TagItem layertags[] =
1461 {LA_BackfillHook, (IPTR)backfillhook},
1462 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1463 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1464 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1465 {LA_WindowPtr, (IPTR)w},
1466 {TAG_DONE}
1469 D(dprintf("CreateUpfontLayerTagList(taglist 0x%lx)\n",&layertags));
1471 w->WLayer = CreateUpfrontLayerTagList( &w->WScreen->LayerInfo,
1472 w->WScreen->RastPort.BitMap,
1473 w->LeftEdge,
1474 w->TopEdge,
1475 w->LeftEdge + w->Width - 1,
1476 w->TopEdge + w->Height - 1,
1477 layerflags,
1478 (struct TagItem *)&layertags);
1479 #else
1481 struct TagItem lay_tags[] =
1483 {LA_Hook , (IPTR)backfillhook },
1484 {LA_Priority , (layerflags & LAYERBACKDROP) ? BACKDROPPRIORITY : UPFRONTPRIORITY },
1485 {LA_Shape , (IPTR)shape },
1486 {LA_ShapeHook , (IPTR)shapehook },
1487 {LA_SuperBitMap , (IPTR)SuperBitMap },
1488 {LA_ChildOf , (IPTR)parent },
1489 {LA_Visible , (ULONG)visible },
1490 {TAG_DONE }
1493 w->WLayer = CreateLayerTagList(&w->WScreen->LayerInfo,
1494 w->WScreen->RastPort.BitMap,
1495 w->RelLeftEdge,
1496 w->RelTopEdge,
1497 w->RelLeftEdge + w->Width - 1,
1498 w->RelTopEdge + w->Height - 1,
1499 layerflags,
1500 lay_tags);
1502 #endif
1504 /* Install the BorderRPort here! see GZZ window above */
1505 if (NULL != w->WLayer)
1508 I am installing a totally new RastPort here so window and frame can
1509 have different fonts etc.
1511 w->BorderRPort = AllocMem(sizeof(struct RastPort), MEMF_ANY);
1513 if (w->BorderRPort)
1515 InitRastPort(w->BorderRPort);
1516 w->BorderRPort->Layer = w->WLayer;
1517 w->BorderRPort->BitMap = w->WLayer->rp->BitMap;
1519 else
1521 /* no memory for RastPort! Simply close the window */
1522 intui_CloseWindow(w, IntuitionBase);
1523 msg->success = FALSE;
1524 // UnlockLayers(&w->WScreen->LayerInfo);
1525 ReturnVoid("intui_OpenWindow(No BorderRPort)");
1530 D(bug("Layer created: %p\n", w->WLayer));
1531 D(bug("Window created: %p\n", w));
1533 /* common code for GZZ and regular windows */
1535 if (w->WLayer)
1538 if ((layerflags & LAYERBACKDROP) && (w->WScreen->Flags & SHOWTITLE))
1540 #ifdef __MORPHOS__
1541 struct Layer *blayer;
1543 /* make sure the screen titlebar is in front of all user created */
1544 /* backdrop windows */
1546 blayer = w->WScreen->BarLayer;
1548 #ifdef SKINS
1549 if (GetPrivScreen(w->WScreen)->SpecialFlags & (SF_InvisibleBar|SF_AppearingBar)) blayer = 0;
1550 #endif
1552 if (blayer) MoveLayerInFrontOf(blayer,w->WLayer);
1554 D(bug("move screen bar layer in front of window backdrop layer\n"));
1555 #else
1556 /* backdrop window was created over screen barlayer, but it must be
1557 under the screen barlayer if screen has flag SHOWTITLE set */
1559 AROS_ATOMIC_AND(w->WScreen->Flags, ~SHOWTITLE);
1561 ShowTitle(w->WScreen, TRUE);
1562 #endif
1565 /* Layer gets pointer to the window */
1566 WLAYER(w) = w->WLayer;
1568 CheckLayers(w->WScreen,IntuitionBase);
1570 // UnlockLayers(&w->WScreen->LayerInfo);
1572 #ifndef __MORPHOS__
1573 w->WLayer->Window = (APTR)w;
1574 #endif
1575 /* Window needs a rastport */
1576 w->RPort = w->WLayer->rp;
1578 /* installation of the correct BorderRPort already happened above !! */
1580 if (CreateWinSysGadgets(w, IntuitionBase))
1582 LONG lock;
1584 lock = LockIBase (0);
1586 /* insert new window into parent/descendant list
1588 ** before: parent win xyz
1589 ** |
1590 ** |
1591 ** |
1592 ** descendant win abc
1594 ** after: parent win xyz
1595 ** \
1596 ** \
1597 ** newwindow w
1598 ** /
1599 ** /
1600 ** /
1601 ** descendant win abc
1604 #if 1
1606 struct Window *parent, *descendant_of_parent;
1608 parent = IntuitionBase->ActiveWindow;
1609 if (!parent) parent = w->WScreen->FirstWindow;
1610 if (parent)
1612 descendant_of_parent = parent->Descendant;
1613 parent->Descendant = w;
1614 if (descendant_of_parent) descendant_of_parent->Parent = w;
1616 else
1618 descendant_of_parent = NULL;
1621 w->Descendant = descendant_of_parent;
1622 w->Parent = parent;
1624 #endif
1626 w->NextWindow = w->WScreen->FirstWindow;
1627 w->WScreen->FirstWindow = w;
1629 w->WindowPort = GetPrivIBase(IntuitionBase)->IntuiReplyPort;
1631 UnlockIBase (lock);
1633 AddResourceToList(w, RESOURCE_WINDOW, IntuitionBase);
1635 if (w->Flags & WFLG_ACTIVATE)
1637 ActivateWindow(w);
1639 else
1641 RefreshWindowFrame(w);
1644 msg->success = TRUE;
1645 ReturnVoid("int_openwindow");
1648 CloseWindow(w);
1649 //int_closewindow(w, IntuitionBase);
1651 } /* if (layer created) */
1653 // UnlockLayers(&w->WScreen->LayerInfo);
1656 D(bug("int_openwindow(General failure)"));
1658 msg->success = FALSE;
1659 ReturnVoid("int_openwindow");