picture.datatype: gi_RastPort should not be directly accessed
[AROS.git] / rom / intuition / openwindow.c
blob6553352b5a211833160f1f67831262b5473e1436
1 /*
2 Copyright 1995-2011, 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 DEBUG_OpenWindow
37 # include <aros/debug.h>
39 struct OpenWindowActionMsg
41 struct IntuiActionMsg msg;
42 struct Window *window;
43 struct BitMap *bitmap;
44 struct Hook *backfillhook;
45 struct Region *shape;
46 struct Hook *shapehook;
47 struct Layer *parentlayer;
48 BOOL invisible;
49 BOOL success;
52 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
53 struct IntuitionBase *IntuitionBase);
55 /*****************************************************************************
57 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
76 opened. Reasons for this might be lack of memory or illegal
77 attributes.
79 NOTES
81 EXAMPLE
83 BUGS
85 SEE ALSO
86 CloseWindow(), ModifyIDCMP()
88 INTERNALS
90 *****************************************************************************/
92 AROS_LIBFUNC_INIT
94 struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
95 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
96 struct OpenWindowActionMsg msg;
97 struct NewWindow nw;
98 struct Window *w = NULL, *helpgroupwindow = NULL, *parentwin = NULL;
99 struct TagItem *tag, *shapeti = NULL, *shapehookti = NULL;
100 struct TagItem *tagList;
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 BOOL pubScreenNameSet = FALSE;
117 UBYTE *screenTitle = NULL;
118 BOOL autoAdjust = FALSE, pubScreenFallBack = FALSE;
119 ULONG innerWidth = ~0;
120 ULONG innerHeight = ~0;
121 WORD mousequeue = DEFAULTMOUSEQUEUE;
122 WORD repeatqueue = 3; /* stegerg: test on my Amiga suggests this */
123 ULONG moreFlags = 0;
124 ULONG helpgroup = 0;
125 ULONG extrabuttons = 0, extrabuttonsid = ETI_Dummy;
126 //ULONG lock;
127 ULONG windowinvisible = FALSE;
128 BOOL driver_init_done = FALSE, have_helpgroup = FALSE;
129 BOOL do_setwindowpointer = FALSE;
131 ASSERT_VALID_PTR_ROMOK(newWindow);
133 D(bug("OpenWindow (%p = { Left=%d Top=%d Width=%d Height=%d })\n"
134 , newWindow
135 , newWindow->LeftEdge
136 , newWindow->TopEdge
137 , newWindow->Width
138 , newWindow->Height
141 FireScreenNotifyMessage((IPTR) newWindow, SNOTIFY_BEFORE_OPENWINDOW, IntuitionBase);
143 nw = *newWindow;
145 #define WFLG_PRIVATEFLAGS (WFLG_WINDOWREFRESH |\
146 WFLG_WINDOWTICKED | WFLG_VISITOR | \
147 WFLG_ZOOMED |\
148 WFLG_WINDOWACTIVE )
149 /* jDc*/
150 /* WFLG_WBENCHWINDOW | \*/
151 /* this is used by WORKBENCH! */
152 /* WFLG_HASZOOM | \*/
153 /* do NOT filter this! how do you think apps could manage to get a zoom image with struct NewWindow? */
155 nw.Flags &= ~WFLG_PRIVATEFLAGS;
157 if (newWindow->Flags & WFLG_NW_EXTENDED)
159 tagList = ((struct ExtNewWindow *)newWindow)->Extension;
160 #ifdef __mc68000
161 /* Sanitycheck the taglist pointer. Some Am*gaOS 1.3/2.x era
162 * apps have WFLG_NW_EXTENDED set with bogus Extension taglist
163 * pointer... (older CygnusED for example) - Piru
165 if (((IPTR) tagList & 1) || !TypeOfMem((APTR)tagList))
167 tagList = NULL;
169 #endif
171 else
173 tagList = NULL;
176 DEBUG_OPENWINDOW(dprintf("OpenWindow: NewWindow 0x%lx TagList 0x%lx\n",
177 newWindow, tagList));
179 if (tagList)
181 ASSERT_VALID_PTR_ROMOK(tagList);
183 /* Look at WA_Flags first, since boolean tags override part of it
184 * even if they appear before it.
186 nw.Flags |= (GetTagData(WA_Flags, nw.Flags, tagList) & ~WFLG_PRIVATEFLAGS);
188 while ((tag = NextTagItem (&tagList)))
190 /* ASSERT_VALID_PTR_ROMOK(tag); */
192 DEBUG_OPENWINDOW(dprintf("OpenWindow: Tag 0x%08lx 0x%08lx\n",
193 tag->ti_Tag, tag->ti_Data));
195 switch (tag->ti_Tag)
197 case WA_Left:
198 nw.LeftEdge = tag->ti_Data;
199 break;
201 case WA_Top:
202 nw.TopEdge = tag->ti_Data;
203 break;
205 case WA_Width:
206 nw.Width = tag->ti_Data;
207 break;
209 case WA_Height:
210 nw.Height = tag->ti_Data;
211 break;
213 case WA_IDCMP:
214 nw.IDCMPFlags = tag->ti_Data;
215 break;
217 case WA_MinWidth:
218 nw.MinWidth = tag->ti_Data;
219 break;
221 case WA_MinHeight:
222 nw.MinHeight = tag->ti_Data;
223 break;
225 case WA_MaxWidth:
226 nw.MaxWidth = tag->ti_Data;
227 break;
229 case WA_MaxHeight:
230 nw.MaxHeight = tag->ti_Data;
231 break;
233 case WA_Gadgets:
234 nw.FirstGadget = (struct Gadget *)(tag->ti_Data);
235 break;
237 case WA_Title:
238 nw.Title = (UBYTE *)(tag->ti_Data);
239 break;
241 case WA_ScreenTitle:
242 screenTitle = (UBYTE *)tag->ti_Data;
243 break;
245 case WA_AutoAdjust:
246 autoAdjust = (tag->ti_Data != 0);
247 break;
249 case WA_InnerWidth:
250 innerWidth = tag->ti_Data;
251 break;
253 case WA_InnerHeight:
254 innerHeight = tag->ti_Data;
255 break;
257 #define MODIFY_FLAG(name) if (tag->ti_Data) \
258 nw.Flags |= (name); else nw.Flags &= ~(name)
259 #define MODIFY_MFLAG(name) if (tag->ti_Data) \
260 moreFlags |= (name); else moreFlags &= ~(name)
262 case WA_SizeGadget:
263 MODIFY_FLAG(WFLG_SIZEGADGET);
264 break;
266 case WA_DragBar:
267 MODIFY_FLAG(WFLG_DRAGBAR);
268 break;
270 case WA_DepthGadget:
271 MODIFY_FLAG(WFLG_DEPTHGADGET);
272 break;
274 case WA_CloseGadget:
275 MODIFY_FLAG(WFLG_CLOSEGADGET);
276 break;
278 case WA_Backdrop:
279 MODIFY_FLAG(WFLG_BACKDROP);
280 break;
282 case WA_ReportMouse:
283 MODIFY_FLAG(WFLG_REPORTMOUSE);
284 break;
286 case WA_NoCareRefresh:
287 MODIFY_FLAG(WFLG_NOCAREREFRESH);
288 break;
290 case WA_Borderless:
291 MODIFY_FLAG(WFLG_BORDERLESS);
292 break;
294 case WA_Activate:
295 MODIFY_FLAG(WFLG_ACTIVATE);
296 break;
298 case WA_RMBTrap:
299 MODIFY_FLAG(WFLG_RMBTRAP);
300 break;
302 case WA_WBenchWindow:
303 MODIFY_FLAG(WFLG_WBENCHWINDOW);
304 break;
306 case WA_SizeBRight:
307 MODIFY_FLAG(WFLG_SIZEBRIGHT);
308 break;
310 case WA_SizeBBottom:
311 MODIFY_FLAG(WFLG_SIZEBBOTTOM);
312 break;
314 case WA_GimmeZeroZero:
315 MODIFY_FLAG(WFLG_GIMMEZEROZERO);
316 break;
318 case WA_NewLookMenus:
319 MODIFY_FLAG(WFLG_NEWLOOKMENUS);
320 break;
322 case WA_ToolBox:
323 MODIFY_FLAG(WFLG_TOOLBOX);
324 break;
326 case WA_Zoom:
327 zoombox = (struct IBox *)tag->ti_Data;
328 DEBUG_OPENWINDOW(dprintf("OpenWindow: zoom %d %d %d %d\n",
329 zoombox->Left, zoombox->Top, zoombox->Width, zoombox->Height));
330 MODIFY_FLAG(WFLG_HASZOOM);
331 break;
333 case WA_DetailPen:
334 if (nw.DetailPen == 0xFF)
335 nw.DetailPen = tag->ti_Data;
336 break;
338 case WA_BlockPen:
339 if (nw.BlockPen == 0xFF)
340 nw.BlockPen = tag->ti_Data;
341 break;
343 case WA_CustomScreen:
344 nw.Screen = (struct Screen *)(tag->ti_Data);
345 nw.Type = CUSTOMSCREEN;
346 break;
348 case WA_SuperBitMap:
349 nw.Flags |= WFLG_SUPER_BITMAP;
350 nw.BitMap = (struct BitMap *)(tag->ti_Data);
351 break;
353 case WA_SimpleRefresh:
354 if (tag->ti_Data)
355 nw.Flags |= WFLG_SIMPLE_REFRESH;
356 break;
358 case WA_SmartRefresh:
359 if (tag->ti_Data)
360 nw.Flags |= WFLG_SMART_REFRESH;
361 break;
363 case WA_PubScreenFallBack:
364 pubScreenFallBack = (tag->ti_Data ? TRUE : FALSE);
365 break;
367 case WA_PubScreenName:
368 pubScreenNameSet = TRUE;
369 pubScreenName = (STRPTR)tag->ti_Data;
370 break;
372 case WA_PubScreen:
373 nw.Type = PUBLICSCREEN;
374 nw.Screen = (struct Screen *)tag->ti_Data;
375 break;
377 case WA_BackFill:
378 backfillhook = (struct Hook *)tag->ti_Data;
379 break;
381 case WA_MouseQueue:
382 mousequeue = tag->ti_Data;
383 break;
385 /* These two are not implemented in AmigaOS */
386 case WA_WindowName:
387 case WA_Colors:
388 break;
390 case WA_NotifyDepth:
391 MODIFY_MFLAG(WMFLG_NOTIFYDEPTH);
392 break;
394 case WA_RptQueue:
395 repeatqueue = tag->ti_Data;
396 break;
398 case WA_Checkmark:
399 Checkmark = (struct Image *)tag->ti_Data;
400 break;
402 case WA_AmigaKey:
403 AmigaKey = (struct Image *)tag->ti_Data;
404 break;
406 case WA_HelpGroup:
407 helpgroup = (ULONG)tag->ti_Data;
408 have_helpgroup = TRUE;
409 break;
411 case WA_HelpGroupWindow:
412 helpgroupwindow = (struct Window *)tag->ti_Data;
413 break;
415 case WA_MenuHelp:
416 MODIFY_MFLAG(WMFLG_MENUHELP);
417 break;
419 case WA_PointerDelay:
420 MODIFY_MFLAG(WMFLG_POINTERDELAY);
421 break;
423 case WA_TabletMessages:
424 MODIFY_MFLAG(WMFLG_TABLETMESSAGES);
425 break;
427 case WA_ExtraTitlebarGadgets:
428 extrabuttons = (ULONG)tag->ti_Data;
429 break;
431 case WA_ExtraGadgetsStartID:
432 extrabuttonsid = (ULONG)tag->ti_Data;
433 break;
435 case WA_ExtraGadget_Iconify:
436 if (tag->ti_Data)
438 extrabuttons |= ETG_ICONIFY;
440 else
442 extrabuttons &= ~ETG_ICONIFY;
444 break;
446 case WA_ExtraGadget_Lock:
447 if (tag->ti_Data)
449 extrabuttons |= ETG_LOCK;
451 else
453 extrabuttons &= ~ETG_LOCK;
455 break;
457 case WA_ExtraGadget_MUI:
458 if (tag->ti_Data)
460 extrabuttons |= ETG_MUI;
462 else
464 extrabuttons &= ~ETG_MUI;
466 break;
468 case WA_ExtraGadget_PopUp:
469 if (tag->ti_Data)
471 extrabuttons |= ETG_POPUP;
473 else
475 extrabuttons &= ~ETG_POPUP;
477 break;
479 case WA_ExtraGadget_Snapshot:
480 if (tag->ti_Data)
482 extrabuttons |= ETG_SNAPSHOT;
484 else
486 extrabuttons &= ~ETG_SNAPSHOT;
488 break;
490 case WA_ExtraGadget_Jump:
491 if (tag->ti_Data)
493 extrabuttons |= ETG_JUMP;
495 else
497 extrabuttons &= ~ETG_JUMP;
499 break;
501 #ifdef SKINS
502 case WA_SkinInfo:
503 skininfo = (struct SkinInfo *)tag->ti_Data;
504 hasskininfo = TRUE;
505 break;
507 case WA_TransparentRegion:
508 usertranspregion = (struct Region *)tag->ti_Data;
509 usertransphook = NULL; //doesn't make sense
510 break;
512 case WA_TransparentRegionHook:
513 usertransphook = (struct Hook *)tag->ti_Data;
514 usertranspregion = NULL;
515 break;
517 case WA_UserPort:
518 userport = (struct MsgPort *)tag->ti_Data;
519 break;
520 /**********************************************************************************/
522 case WA_IAmMUI:
523 MODIFY_MFLAG(WMFLG_IAMMUI);
524 break;
525 #endif
527 #ifndef __MORPHOS__
528 case WA_ShapeRegion:
529 shapeti = tag;
530 shape = (struct Region *)tag->ti_Data;
531 break;
533 case WA_ShapeHook:
534 shapehookti = tag;
535 shapehook = (struct Hook *)tag->ti_Data;
536 break;
539 case WA_Parent:
540 parentwin = ((struct Window *)tag->ti_Data);
541 parentl = parentwin->WLayer;
542 break;
544 case WA_Hidden:
545 windowinvisible = tag->ti_Data;
546 break;
547 #endif
549 case WA_Pointer:
550 case WA_BusyPointer:
551 do_setwindowpointer = TRUE;
552 break;
554 } /* switch Tag */
556 } /* while ((tag = NextTagItem (&tagList))) */
558 } /* if (tagList) */
560 if (nw.Flags & WFLG_SIZEGADGET)
562 if (!(nw.Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
564 nw.Flags |= WFLG_SIZEBRIGHT;
567 //jDc: tested behavior of intuition68k
568 nw.Flags |= WFLG_HASZOOM;
570 else
572 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM);
575 if (nw.Flags & WFLG_BORDERLESS)
577 nw.Flags &= ~(WFLG_SIZEBRIGHT|WFLG_SIZEBBOTTOM|WFLG_SIZEGADGET);
580 /* Find out on which Screen the window must open */
582 /* (cyfm 03/03/03 check for nw.Type == PUBLICSCREEN as well, some programs
583 * like TurboPrint GraphicPublisher specify {WA_PubScreen, NULL} and want
584 * to open on the default public screen that way
586 if (pubScreenNameSet || (nw.Type == PUBLICSCREEN && nw.Screen == NULL))
588 struct Screen *pubs = 0;
590 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
591 pubs = LockPubScreen(pubScreenName);
592 if (!pubs && pubScreenFallBack)
594 nw.Screen = LockPubScreen(NULL);
596 if (pubs)
598 nw.Screen = pubs;
600 nw.Type = PUBLICSCREEN;
601 if (nw.Screen) nw.Flags |= WFLG_VISITOR;
603 else if (nw.Type == PUBLICSCREEN)
605 /* There is no LockPubScreen() with a "struct Screen *" argument, so we have to do
606 * the necessary steps ourself
608 LockPubScreenList();
609 if (GetPrivScreen(nw.Screen)->pubScrNode)
611 GetPrivScreen(nw.Screen)->pubScrNode->psn_VisitorCount++;
612 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
613 nw.Flags |= WFLG_VISITOR;
614 FireScreenNotifyMessage((IPTR) nw.Screen, SNOTIFY_LOCKPUBSCREEN, IntuitionBase);
616 else
618 /* The screen wasn't a PublicScreen */
619 UnlockPubScreenList();
620 D(bug("OpenWindow: Not a PublicScreen\n"));
621 goto failexit;
623 UnlockPubScreenList();
626 if (nw.Type == WBENCHSCREEN)
628 nw.Screen = LockPubScreen("Workbench");
629 if (nw.Screen)
631 moreFlags |= WMFLG_DO_UNLOCKPUBSCREEN;
632 nw.Flags |= WFLG_VISITOR;
636 if (nw.Screen == NULL) {
637 D(bug("OpenWindow: No screen\n"));
638 goto failexit;
641 w = AllocMem (sizeof(struct IntWindow), MEMF_CLEAR);
643 DEBUG_OPENWINDOW(dprintf("OpenWindow: Window 0x%lx\n", w));
645 /* nlorentz: For now, creating a rastport becomes the responsibility of
646 intui_OpenWindow(). This is because intui_OpenWindow() in
647 config/hidd/intuition_driver.c must call CreateUpfrontLayer(),
648 and that will create a rastport for the layer/window, and we don't
649 want two rastports pr. window.
650 Alternatively we may create a layers_driver.c driver for layers,
651 and then call CreateUpfrontLayer() here from openwindow.
652 For the Amiga window<-->X11 window stuff, the layers driver
653 would just allocate a layer struct, a rastport and
654 put the rasport into layer->RastPort, so we
655 could get it inside this routine and put it into
656 window->RPort;.
660 if (NULL == w) {
661 D(bug("OpenWindow: No window\n"));
662 goto failexit;
665 DEBUG_OPENWINDOW(dprintf("OpenWindow: Flags 0x%lx MoreFlags 0x%lx IDCMP 0x%lx\n",
666 nw.Flags, moreFlags, nw.IDCMPFlags));
667 IPTR userbuffersize;
669 GetAttr(WDA_UserBuffer, ((struct IntScreen *)(nw.Screen))->WinDecorObj, &userbuffersize);
671 if (userbuffersize)
673 ((struct IntWindow *)w)->DecorUserBufferSize = userbuffersize;
674 ((struct IntWindow *)w)->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
675 if (0 == ((struct IntWindow *)w)->DecorUserBuffer) {
676 D(bug("OpenWindow: No decor\n"));
677 goto failexit;
681 struct wdpInitWindow initmsg;
682 BOOL ok;
684 initmsg.MethodID = WDM_INITWINDOW;
685 initmsg.wdp_TrueColor = (((struct IntScreen *) nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
686 initmsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
687 initmsg.wdp_ScreenUserBuffer = ((struct IntScreen *) nw.Screen)->DecorUserBuffer;
688 initmsg.wdp_Screen = nw.Screen;
690 ok = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&initmsg);
692 if (!ok) {
693 D(bug("OpenWindow: WDM_INITWINDOW failed\n"));
694 goto failexit;
697 w->WScreen = nw.Screen;
699 #ifdef SKINS
700 if (userport)
702 w->UserPort = userport;
703 ((struct IntWindow *)w)->specialflags |= SPFLAG_USERPORT;
705 #endif
707 if (!ModifyIDCMP (w, nw.IDCMPFlags)) {
708 D(bug("OpenWindow: ModifyIDCMP failed\n"));
709 goto failexit;
712 ((struct IntWindow *)w)->extrabuttons = extrabuttons;
713 ((struct IntWindow *)w)->extrabuttonsid = extrabuttonsid;
715 /* w->RPort = rp; */
717 //w->FirstGadget = nw.FirstGadget;
719 w->DetailPen = (nw.DetailPen != 0xFF) ? nw.DetailPen : w->WScreen->DetailPen;
720 w->BlockPen = (nw.BlockPen != 0xFF) ? nw.BlockPen : w->WScreen->BlockPen;
722 /* Copy flags */
723 w->Flags = nw.Flags;
724 w->MoreFlags = moreFlags;
726 if (!(w->Flags & WFLG_BORDERLESS))
728 w->BorderLeft = w->WScreen->WBorLeft;
729 w->BorderRight = w->WScreen->WBorRight;
730 #ifdef TITLEHACK
731 w->BorderTop = w->WScreen->WBorBottom;
732 #else
733 w->BorderTop = w->WScreen->WBorTop;
734 #endif
735 w->BorderBottom = w->WScreen->WBorBottom;
738 if (nw.Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET)))
740 /* this is a hack. the correct way to "correct" (increase if necessary)
741 the w->Border??? items would be to check all GACT_???BORDER gadgets
742 (inclusive sysgadgets which are GACT_????BORDER gadgets as well) in
743 nw.FirstGadget (or WA_Gadgets tag) and all sysgadgets and then
744 make sure that each window border is big enough so that none of these
745 gadgets extends outside the window border area */
747 #ifdef TITLEHACK
748 w->BorderTop = w->WScreen->WBorTop;
749 #endif
750 /* Georg Steger: ??? font ??? */
751 if (w->WScreen->Font)
752 w->BorderTop += ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_Font->tf_YSize + 1;
753 else
754 w->BorderTop += GfxBase->DefaultFont->tf_YSize + 1;
755 #ifndef TITLEHACK
756 #ifdef SKINS
757 if (hasskininfo)
759 struct windowclassprefs *wcprefs;
760 struct IntDrawInfo *dri;
761 if ((dri = (struct IntDrawInfo *)GetScreenDrawInfo(w->WScreen)))
763 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
764 w->BorderTop += wcprefs->titlebarincrement;
765 int_FreeCustomPrefs(TYPE_WINDOWCLASS,dri,IntuitionBase);
768 #endif
769 #endif
772 /* look for GACT_???BORDER gadgets which increase the BorderSizes */
774 if (nw.FirstGadget)
776 struct Gadget *gad;
778 for(gad = nw.FirstGadget; gad; gad = gad->NextGadget)
780 WORD gadx1, gady1, gadx2, gady2;
782 if (gad->Activation & GACT_LEFTBORDER)
784 /* may never be GFLG_RELRIGHT / GFLG_RELWIDTH */
786 gadx2 = gad->LeftEdge + gad->Width - 1;
787 if (gadx2 >= w->BorderLeft) w->BorderLeft = gadx2/* + 1*/;
790 if (gad->Activation & GACT_TOPBORDER)
792 /* may never be GFLG_RELBOTTOM / GFLG_RELHEIGHT */
794 gady2 = gad->TopEdge + gad->Height - 1;
795 if (gady2 >= w->BorderTop) w->BorderTop = gady2/* + 1*/;
798 if (gad->Activation & GACT_RIGHTBORDER)
800 /* must be GFLG_RELRIGHT but never GFLG_RELWIDTH */
802 gadx1 = -gad->LeftEdge;
803 if (gadx1 >= w->BorderRight) w->BorderRight = gadx1/* + 1*/;
806 if (gad->Activation & GACT_BOTTOMBORDER)
808 /* must be GFLG_RELBOTTOM but never GFLG_RELHEIGHT */
810 gady1 = -gad->TopEdge;
811 if (gady1 >= w->BorderBottom) w->BorderBottom = gady1/* + 1*/;
814 } /* for(gad = nw.FirstGadget; gad; gad = gad->NextGadget) */
816 } /* if (nw.FirstGadget) */
818 if (!(w->Flags & WFLG_SIZEBRIGHT)) if (w->BorderRight > w->WScreen->WBorRight)
820 w->Flags |= WFLG_SIZEBRIGHT;
823 if (!(w->Flags & WFLG_SIZEBBOTTOM)) if (w->BorderBottom > w->WScreen->WBorBottom)
825 w->Flags |= WFLG_SIZEBBOTTOM;
829 // if ((w->Flags & WFLG_SIZEGADGET) &&
830 // (w->Flags & (WFLG_SIZEBRIGHT | WFLG_SIZEBBOTTOM)))
832 IPTR sizewidth = 16, sizeheight = 16;
833 struct Image *im;
834 struct DrawInfo *dri;
836 if ((dri = GetScreenDrawInfo(w->WScreen)))
838 struct TagItem imtags[] =
840 {SYSIA_DrawInfo , (STACKIPTR)dri },
841 {SYSIA_Which , SIZEIMAGE },
842 {SYSIA_Size , w->WScreen->Flags & SCREENHIRES ? SYSISIZE_MEDRES : SYSISIZE_LOWRES },
843 {TAG_DONE }
846 if ((im = NewObjectA(NULL, SYSICLASS, imtags)))
848 GetAttr(IA_Width, (Object *)im, &sizewidth);
849 GetAttr(IA_Height, (Object *)im, &sizeheight);
851 DisposeObject(im);
853 FreeScreenDrawInfo(w->WScreen, dri);
856 if (w->Flags & WFLG_SIZEBRIGHT)
858 if (w->BorderRight < sizewidth) w->BorderRight = sizewidth;
861 if (w->Flags & WFLG_SIZEBBOTTOM)
863 if (w->BorderBottom < sizeheight) w->BorderBottom = sizeheight;
866 IW(w)->sizeimage_width = sizewidth;
867 IW(w)->sizeimage_height = sizeheight;
869 /* now increase window size if it's necessary */
872 #ifdef SKINS
874 IW(w)->custombackfill.h_Entry = (HOOKFUNC)HookEntry;
875 IW(w)->custombackfill.h_SubEntry = (HOOKFUNC)GradientizeBackfillFunc;
876 IW(w)->custombackfill.h_Data = &IW(w)->hd;
877 IW(w)->hd.intuitionBase = IntuitionBase;
879 IW(w)->usertranspregion = usertranspregion;
880 IW(w)->usertransphook = usertransphook;
882 #endif
883 IW(w)->DefaultWindowShapeHook.h_Entry = (HOOKFUNC)DefaultWindowShapeFunc;
884 IW(w)->DefaultWindowShapeHook.h_SubEntry = (HOOKFUNC)w;
885 IW(w)->DefaultWindowShapeHook.h_Data = (APTR)IntuitionBase;
887 if (innerWidth != ~0) nw.Width = innerWidth + w->BorderLeft + w->BorderRight;
888 if (innerHeight != ~0) nw.Height = innerHeight + w->BorderTop + w->BorderBottom;
891 LONG parentwidth;
892 LONG parentheight;
894 parentwidth = parentwin ? parentwin->Width : w->WScreen->Width;
895 parentheight = parentwin ? parentwin->Height : w->WScreen->Height;
897 w->Width = (nw.Width != ~0) ? nw.Width : parentwidth - nw.LeftEdge;
898 w->Height = (nw.Height != ~0) ? nw.Height : parentheight - nw.TopEdge;
900 if (autoAdjust)
903 if (w->Width > parentwidth) w->Width = parentwidth;
904 if (w->Height > parentheight) w->Height = parentheight;
906 if (nw.LeftEdge < 0) nw.LeftEdge = 0;
907 if (nw.TopEdge < 0) nw.TopEdge = 0;
909 if ((nw.LeftEdge + w->Width) > parentwidth)
910 nw.LeftEdge = parentwidth - w->Width;
912 if ((nw.TopEdge + w->Height) > parentheight)
913 nw.TopEdge = parentheight - w->Height;
916 w->GZZWidth = w->Width - w->BorderLeft - w->BorderRight;
917 w->GZZHeight = w->Height - w->BorderTop - w->BorderBottom;
920 if (nw.LeftEdge < 0 || nw.TopEdge < 0 ||
921 nw.LeftEdge + w->Width > w->WScreen->Width ||
922 nw.TopEdge + w->Height > w->WScreen->Height) {
923 D(bug("OpenWindow: Window size (%dx%d) @(%d,%d) is weird for a %dx%d screen\n",
924 nw.LeftEdge + w->Width, nw.TopEdge + w->Height,
925 nw.LeftEdge, nw.TopEdge ,
926 w->WScreen->Width, w->WScreen->Height));
927 goto failexit;
930 if (NULL == parentwin)
932 w->LeftEdge = nw.LeftEdge;
933 w->TopEdge = nw.TopEdge;
935 else
937 w->LeftEdge = nw.LeftEdge + parentwin->LeftEdge;
938 w->TopEdge = nw.TopEdge + parentwin->TopEdge;
941 #ifndef __MORPHOS__
942 w->RelLeftEdge = nw.LeftEdge;
943 w->RelTopEdge = nw.TopEdge;
944 #endif
946 w->MinWidth = (nw.MinWidth != 0) ? nw.MinWidth : w->Width;
947 w->MinHeight = (nw.MinHeight != 0) ? nw.MinHeight : w->Height;
948 w->MaxWidth = (nw.MaxWidth != 0) ? nw.MaxWidth : w->Width;
949 w->MaxHeight = (nw.MaxHeight != 0) ? nw.MaxHeight : w->Height;
951 //jDc: tested behavior of intuition68k
952 if ((UWORD)w->MaxWidth < w->Width) w->MaxWidth = w->Width;
953 if ((UWORD)w->MaxHeight < w->Height) w->MaxHeight = w->Height;
955 /* check if maxwidth/height is not bigger than screen */
956 if (w->MaxWidth > w->WScreen->Width) w->MaxWidth = w->WScreen->Width;
957 if (w->MaxHeight > w->WScreen->Height) w->MaxHeight = w->WScreen->Height;
959 if (zoombox)
961 ((struct IntWindow *)w)->ZipLeftEdge = zoombox->Left;
962 ((struct IntWindow *)w)->ZipTopEdge = zoombox->Top;
963 ((struct IntWindow *)w)->ZipWidth = zoombox->Width;
964 ((struct IntWindow *)w)->ZipHeight = zoombox->Height;
966 else
968 ((struct IntWindow *)w)->ZipLeftEdge = nw.LeftEdge;
969 ((struct IntWindow *)w)->ZipTopEdge = nw.TopEdge;
970 ((struct IntWindow *)w)->ZipWidth = (w->Width == w->MinWidth) ? w->MaxWidth : w->MinWidth;
971 ((struct IntWindow *)w)->ZipHeight = (w->Height == w->MinHeight) ? w->MaxHeight : w->MinHeight;
974 DEBUG_OPENWINDOW(dprintf("OpenWindow: zip %d %d %d %d\n",
975 ((struct IntWindow *)w)->ZipLeftEdge,
976 ((struct IntWindow *)w)->ZipTopEdge,
977 ((struct IntWindow *)w)->ZipWidth,
978 ((struct IntWindow *)w)->ZipHeight));
981 IW(w)->mousequeue = mousequeue;
982 IW(w)->repeatqueue = repeatqueue;
984 /* Amiga and checkmark images for menus */
986 IW(w)->Checkmark = Checkmark ? Checkmark :
987 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_CheckMark;
989 IW(w)->AmigaKey = AmigaKey ? AmigaKey :
990 ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_AmigaKey;
991 IW(w)->SubMenuImage = ((struct IntScreen *)(w->WScreen))->DInfo.dri.dri_SubMenuImage;
993 #ifndef __MORPHOS__
994 /* child support */
995 if (NULL != parentwin)
997 if (parentwin->firstchild)
998 parentwin->firstchild->prevchild = w;
1000 w->nextchild = parentwin->firstchild;
1001 parentwin->firstchild = w;
1002 w->parent = parentwin;
1004 #endif
1006 #ifdef SKINS
1007 if (hasskininfo) ((struct IntWindow *)(w))->specialflags = SPFLAG_SKININFO;
1008 #endif
1010 #ifdef DAMAGECACHE
1011 if ((w->Flags & WFLG_SIMPLE_REFRESH) && (IS_DOCAREREFRESH(w)) && (!(w->Flags & WFLG_BORDERLESS))) IW(w)->trashregion = NewRegion();
1012 #endif
1014 /* Help stuff */
1016 if (!have_helpgroup && helpgroupwindow)
1018 if (IW(helpgroupwindow)->helpflags & HELPF_ISHELPGROUP)
1020 helpgroup = IW(helpgroupwindow)->helpgroup;
1021 have_helpgroup = TRUE;
1025 if (have_helpgroup)
1027 IW(w)->helpflags |= HELPF_ISHELPGROUP;
1028 IW(w)->helpgroup = helpgroup;
1031 w->Title = nw.Title;
1034 #if 1
1036 /* Use safe OpenFont.. - Piru
1039 if (GetPrivScreen(w->WScreen)->SpecialFlags & SF_SysFont)
1041 w->IFont = SafeReopenFont(IntuitionBase, &GfxBase->DefaultFont);
1043 else
1045 w->IFont = SafeReopenFont(IntuitionBase, &(GetPrivScreen(w->WScreen)->DInfo.dri.dri_Font));
1048 if (w->IFont == NULL) {
1049 D(bug("OpenWindow: No font\n"));
1050 goto failexit;
1053 #else
1055 #warning: Really hacky way of re-opening GfxBase->DefaultFont
1057 Forbid();
1058 w->IFont = GfxBase->DefaultFont;
1059 w->IFont->tf_Accessors++;
1060 Permit();
1062 #endif
1064 /* jDc: intui68k waits before opening the window until
1065 ** Move/SizeWindow actions are over (does it mean it's executed on
1066 ** caller's context?).
1069 #ifdef USEWINDOWLOCK
1070 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1072 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1074 #endif
1076 IW(w)->OutlineShape = NULL;
1078 if ((shapeti != NULL) || (shapehookti != NULL)) IW(w)->CustomShape = TRUE;
1079 if (!(IW(w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1081 shapehook = &IW(w)->DefaultWindowShapeHook;
1084 msg.window = w;
1085 msg.bitmap = nw.BitMap;
1086 //msg.backfillhook = backfillhook == LAYERS_BACKFILL ? &IW(w)->custombackfill : backfillhook;
1087 msg.backfillhook = backfillhook;
1088 msg.shape = shape;
1089 msg.shapehook = shapehook;
1090 msg.parentlayer = parentl;
1091 msg.invisible = windowinvisible;
1093 DoSyncAction((APTR)int_openwindow, &msg.msg, IntuitionBase);
1095 #ifdef USEWINDOWLOCK
1096 if (!(FindTask(0) == ((struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data)->InputDeviceTask))
1098 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1100 #endif
1102 if (!msg.success) {
1103 D(bug("OpenWindow: DoSyncAction failed\n"));
1104 goto failexit;
1107 /* nlorentz: The driver has in some way or another allocated a rastport for us,
1108 which now is ready for us to use. */
1110 driver_init_done = TRUE;
1111 rp = w->RPort;
1113 D(bug("called driver, rp=%p\n", rp));
1115 /* The window RastPort always gets the font from GfxBase->DefaultFont, which
1116 is the system's default font. Usually topaz 8, but it can be changed with
1117 the Fonts prefs program to another fixed-sized font. */
1119 SetFont (rp, w->IFont);
1121 D(bug("set fonts\n"));
1123 /* FIXME: Remove workaround! */
1124 /* lbischoff: The following 4 Setxxx lines are a workaround for the InitRastPort
1125 problem (Bug #75 in docs/BUGS). They ensure that at least a window's rastport
1126 is initialized correctly. Remove them if they are not needed any longer!
1128 SetABPenDrMd (rp, rp->FgPen, rp->BgPen, rp->DrawMode);
1129 SetWriteMask (rp, rp->Mask);
1130 D(bug("set pens\n"));
1133 /* Send all GA_RelSpecial BOOPSI gadgets in the list the GM_LAYOUT msg */
1134 /*DoGMLayout(w->FirstGadget, w, NULL, -1, TRUE, IntuitionBase);
1136 if (NULL != w->FirstGadget)
1137 RefreshGadgets (w->FirstGadget, w, NULL);
1140 if (nw.FirstGadget)
1142 struct IntDrawInfo *dri = &((struct IntScreen *)(w->WScreen))->DInfo;
1143 struct wdpLayoutBorderGadgets msg;
1145 msg.MethodID = WDM_LAYOUT_BORDERGADGETS;
1146 msg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;;
1147 msg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1148 msg.wdp_Window = w;
1149 msg.wdp_Gadgets = nw.FirstGadget;
1150 msg.wdp_Flags = WDF_LBG_INITIAL | WDF_LBG_MULTIPLE;
1151 msg.wdp_ExtraButtons = ((struct IntWindow *)w)->extrabuttons;
1152 msg.wdp_Dri = (struct DrawInfo *)dri;
1154 DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&msg);
1156 AddGList(w, nw.FirstGadget, -1, -1, NULL);
1159 #if 0
1160 /* !!! This does double refreshing as the system gadgets also are refreshed
1161 in the above RfreshGadgets() call */
1162 if (nw.Flags & WFLG_ACTIVATE)
1164 /* RefreshWindowFrame() will be called from within ActivateWindow().
1165 No point in doing double refreshing. */
1167 ActivateWindow(w);
1169 else
1171 RefreshWindowFrame(w);
1173 #endif
1175 if (screenTitle != NULL)
1176 SetWindowTitles (w, (CONST_STRPTR)~0, screenTitle);
1178 UpdateMouseCoords(w);
1180 if (do_setwindowpointer)
1182 //jDc: main for () loop destroys original taglist pointer, we need to get
1183 //it once again here!
1184 tagList = (struct TagItem *)((struct ExtNewWindow *)newWindow)->Extension;
1185 SetWindowPointerA(w, (struct TagItem *)tagList);
1188 #if 0
1189 ((struct IntWindow *)w)->OutlineShape = NULL;
1191 if ((shape != NULL) || (shapehook != NULL)) ((struct IntWindow *)w)->CustomShape = TRUE;
1192 if ((!((struct IntWindow *)w)->CustomShape) && (!(w->Flags & WFLG_BORDERLESS)) && !IS_GZZWINDOW(w))
1194 struct wdpWindowShape shapemsg;
1196 shapemsg.MethodID = WDM_WINDOWSHAPE;
1197 shapemsg.wdp_TrueColor = (((struct IntScreen *)nw.Screen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR);
1198 shapemsg.wdp_Width = w->Width;
1199 shapemsg.wdp_Height = w->Height;
1200 shapemsg.wdp_Window = w;
1201 shapemsg.wdp_UserBuffer = ((struct IntWindow *)w)->DecorUserBuffer;
1203 shape = DoMethodA(((struct IntScreen *)(nw.Screen))->WinDecorObj, (Msg)&shapemsg);
1204 ((struct IntWindow *)w)->OutlineShape = shape;
1205 ChangeWindowShape(w, shape, NULL);
1206 ((struct IntWindow *)w)->CustomShape = FALSE;
1208 #endif
1210 goto exit;
1212 failexit:
1213 D(bug("fail\n"));
1215 if (w)
1217 ModifyIDCMP (w, 0);
1219 /* nlorentz: Freeing the rasport is now intui_CloseWindow()'s task.
1221 if (rp)
1223 FreeRastPort (rp);
1227 if (driver_init_done)
1228 intui_CloseWindow(w, IntuitionBase);
1230 if (w->IFont) CloseFont(w->IFont);
1232 if (((struct IntWindow *)w)->DecorUserBuffer)
1234 FreeMem((APTR)((struct IntWindow *)w)->DecorUserBuffer, ((struct IntWindow *)w)->DecorUserBufferSize);
1237 FreeMem (w, sizeof(struct IntWindow));
1239 w = NULL;
1242 if (nw.Screen && (moreFlags & WMFLG_DO_UNLOCKPUBSCREEN))
1244 UnlockPubScreen(NULL, nw.Screen);
1247 exit:
1249 DEBUG_OPENWINDOW(dprintf("OpenWindow: Return 0x%lx\n", w));
1251 FireScreenNotifyMessage((IPTR) w, SNOTIFY_AFTER_OPENWINDOW, IntuitionBase);
1253 ReturnPtr ("OpenWindow", struct Window *, w);
1254 AROS_LIBFUNC_EXIT
1255 } /* OpenWindow */
1259 /**********************************************************************************/
1261 static VOID int_openwindow(struct OpenWindowActionMsg *msg,
1262 struct IntuitionBase *IntuitionBase)
1264 struct GfxBase * GfxBase = GetPrivIBase(IntuitionBase)->GfxBase;
1265 struct LayersBase * LayersBase = GetPrivIBase(IntuitionBase)->LayersBase;
1266 struct Window * w = msg->window;
1267 struct BitMap * SuperBitMap = msg->bitmap;
1268 struct Hook * backfillhook = msg->backfillhook;
1269 struct Region * shape = msg->shape;
1270 struct Hook * shapehook = msg->shapehook;
1271 struct Layer * parent = msg->parentlayer;
1272 BOOL invisible = msg->invisible;
1274 #ifdef SKINS
1275 BOOL installtransphook = FALSE;
1276 BOOL notransphook = TRUE;
1277 #endif
1279 /* Create a layer for the window */
1280 LONG layerflags = 0;
1282 EnterFunc(bug("int_OpenWindow(w=%p)\n", w));
1284 D(bug("screen: %p\n", w->WScreen));
1285 D(bug("bitmap: %p\n", w->WScreen->RastPort.BitMap));
1287 /* Just insert some default values, should be taken from
1288 w->WScreen->WBorxxxx */
1290 /* Set the layer's flags according to the flags of the
1291 ** window
1294 /* refresh type */
1295 if (w->Flags & WFLG_SIMPLE_REFRESH)
1297 layerflags |= LAYERSIMPLE;
1299 else
1301 if (w->Flags & WFLG_SUPER_BITMAP && SuperBitMap)
1303 layerflags |= LAYERSUPER;
1305 else
1307 layerflags |= LAYERSMART;
1311 if (w->Flags & WFLG_BACKDROP)
1313 layerflags |= LAYERBACKDROP;
1316 D(bug("Window dims: (%d, %d, %d, %d)\n",
1317 w->LeftEdge, w->TopEdge, w->Width, w->Height));
1319 #ifdef SKINS
1320 //install transp layer hook!
1322 struct windowclassprefs *wcprefs = NULL;
1324 wcprefs = (struct windowclassprefs*)int_GetCustomPrefs(TYPE_WINDOWCLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1325 if (wcprefs->flags & WINDOWCLASS_PREFS_ROUNDEDEDGES && (w->Title || (w->Flags & (WFLG_DRAGBAR | WFLG_CLOSEGADGET | WFLG_DEPTHGADGET))))
1327 IW(w)->transpregion = NewRegion();
1328 if (IW(w)->transpregion)
1330 installtransphook = TRUE; notransphook = FALSE;
1331 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1334 else
1336 if (IW(w)->usertransphook)
1338 IW(w)->transpregion = NewRegion();
1339 if (IW(w)->transpregion)
1341 installtransphook = TRUE;
1342 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1345 else if (IW(w)->usertranspregion)
1347 IW(w)->transpregion = NewRegion();
1348 if (IW(w)->transpregion)
1350 installtransphook = TRUE;
1351 IW(w)->specialflags |= SPFLAG_TRANSPHOOK;
1355 int_FreeCustomPrefs(TYPE_SYSICLASS,&((struct IntScreen*)(w->WScreen))->DInfo,IntuitionBase);
1357 #endif
1359 // LockLayers(&w->WScreen->LayerInfo);
1361 /* A GimmeZeroZero window??? */
1362 if (w->Flags & WFLG_GIMMEZEROZERO)
1365 A GimmeZeroZero window is to be created:
1366 - the outer window will be a simple refresh layer
1367 - the inner window will be a layer according to the flags
1368 What is the size of the inner/outer window supposed to be???
1369 I just make it that the outer window has the size of what is requested
1372 struct TagItem layertags[] =
1374 {LA_BackfillHook, (IPTR)LAYERS_NOBACKFILL},
1375 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1376 #ifdef SKINS
1377 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1378 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1379 #else
1380 {TAG_IGNORE , 0 },
1381 {TAG_IGNORE , 0 },
1382 #endif
1383 {LA_WindowPtr, (IPTR)w },
1384 {LA_ChildOf , (IPTR)parent}, /* These two are AROS-specific */
1385 {LA_Hidden , invisible },
1386 {TAG_DONE}
1389 /* First create outer window */
1390 struct Layer * L = CreateUpfrontLayerTagList(
1391 &w->WScreen->LayerInfo
1392 , w->WScreen->RastPort.BitMap
1393 , w->LeftEdge
1394 , w->TopEdge
1395 , w->LeftEdge + w->Width - 1
1396 , w->TopEdge + w->Height - 1
1397 , LAYERSIMPLE | (layerflags & LAYERBACKDROP)
1398 , (struct TagItem *)&layertags);
1400 /* Could the layer be created. Nothing bad happened so far, so simply leave */
1401 if (NULL == L)
1403 msg->success = FALSE;
1404 // UnlockLayers(&w->WScreen->LayerInfo);
1405 ReturnVoid("intui_OpenWindow(No GimmeZeroZero layer)");
1408 D(bug("created outer GimmeZeroZero layer.\n"));
1410 /* install it as the BorderRPort */
1411 w->BorderRPort = L->rp;
1412 BLAYER(w) = L;
1414 /* Now comes the inner window */
1415 layertags[0].ti_Data = (IPTR)backfillhook;
1416 if (shapehook)
1418 layertags[2].ti_Tag = LA_ShapeHook;
1419 layertags[2].ti_Data = (IPTR)shapehook;
1421 if (shape)
1423 layertags[3].ti_Tag = LA_ShapeRegion;
1424 layertags[3].ti_Data = (IPTR)shape;
1427 w->WLayer = CreateUpfrontLayerTagList(
1428 &w->WScreen->LayerInfo
1429 , w->WScreen->RastPort.BitMap
1430 , w->LeftEdge + w->BorderLeft
1431 , w->TopEdge + w->BorderTop
1432 , w->LeftEdge + w->BorderLeft + w->GZZWidth - 1
1433 , w->TopEdge + w->BorderTop + w->GZZHeight - 1
1434 , layerflags
1435 , (struct TagItem *)&layertags);
1437 /* could this layer be created? If not then delete the outer window and exit */
1438 if (NULL == w->WLayer)
1440 DeleteLayer(0, L);
1441 msg->success = FALSE;
1442 // UnlockLayers(&w->WScreen->LayerInfo);
1443 ReturnVoid("intui_OpenWindow(No window layer)");
1446 /* That should do it, I guess... */
1448 else
1450 struct TagItem layertags[] =
1452 {LA_BackfillHook, (IPTR)backfillhook},
1453 {SuperBitMap ? LA_SuperBitMap : TAG_IGNORE, (IPTR)SuperBitMap},
1454 #ifdef SKINS
1455 {installtransphook ? LA_TransHook : TAG_IGNORE, notransphook ? (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->notransphook : (IPTR)&((struct IntIntuitionBase *)(IntuitionBase))->transphook},
1456 {installtransphook ? LA_TransRegion : TAG_IGNORE, (IPTR)IW(w)->transpregion},
1457 #else
1458 {TAG_IGNORE , 0 },
1459 {TAG_IGNORE , 0 },
1460 #endif
1461 {LA_WindowPtr, (IPTR)w },
1462 {LA_ChildOf , (IPTR)parent}, /* These two are AROS-specific */
1463 {LA_Hidden, invisible },
1464 {TAG_DONE}
1467 if (shapehook)
1469 layertags[2].ti_Tag = LA_ShapeHook;
1470 layertags[2].ti_Data = (IPTR)shapehook;
1472 if (shape)
1474 layertags[3].ti_Tag = LA_ShapeRegion;
1475 layertags[3].ti_Data = (IPTR)shape;
1478 D(dprintf("CreateUpfontLayerTagList(taglist 0x%lx)\n",&layertags));
1480 w->WLayer = CreateUpfrontLayerTagList( &w->WScreen->LayerInfo,
1481 w->WScreen->RastPort.BitMap,
1482 w->LeftEdge,
1483 w->TopEdge,
1484 w->LeftEdge + w->Width - 1,
1485 w->TopEdge + w->Height - 1,
1486 layerflags,
1487 (struct TagItem *)&layertags);
1489 /* Install the BorderRPort here! see GZZ window above */
1490 if (NULL != w->WLayer)
1493 I am installing a totally new RastPort here so window and frame can
1494 have different fonts etc.
1496 w->BorderRPort = AllocMem(sizeof(struct RastPort), MEMF_ANY);
1498 if (w->BorderRPort)
1500 InitRastPort(w->BorderRPort);
1501 w->BorderRPort->Layer = w->WLayer;
1502 w->BorderRPort->BitMap = w->WLayer->rp->BitMap;
1504 else
1506 /* no memory for RastPort! Simply close the window */
1507 intui_CloseWindow(w, IntuitionBase);
1508 msg->success = FALSE;
1509 // UnlockLayers(&w->WScreen->LayerInfo);
1510 ReturnVoid("intui_OpenWindow(No BorderRPort)");
1515 D(bug("Layer created: %p\n", w->WLayer));
1516 D(bug("Window created: %p\n", w));
1518 /* common code for GZZ and regular windows */
1520 if (w->WLayer)
1523 if ((layerflags & LAYERBACKDROP) && (w->WScreen->Flags & SHOWTITLE))
1525 #ifdef __MORPHOS__
1526 struct Layer *blayer;
1528 /* make sure the screen titlebar is in front of all user created */
1529 /* backdrop windows */
1531 blayer = w->WScreen->BarLayer;
1533 #ifdef SKINS
1534 if (GetPrivScreen(w->WScreen)->SpecialFlags & (SF_InvisibleBar|SF_AppearingBar)) blayer = 0;
1535 #endif
1537 if (blayer) MoveLayerInFrontOf(blayer,w->WLayer);
1539 D(bug("move screen bar layer in front of window backdrop layer\n"));
1540 #else
1541 /* backdrop window was created over screen barlayer, but it must be
1542 under the screen barlayer if screen has flag SHOWTITLE set */
1544 AROS_ATOMIC_AND(w->WScreen->Flags, ~SHOWTITLE);
1546 ShowTitle(w->WScreen, TRUE);
1547 #endif
1550 /* Layer gets pointer to the window */
1551 WLAYER(w) = w->WLayer;
1553 CheckLayers(w->WScreen,IntuitionBase);
1555 // UnlockLayers(&w->WScreen->LayerInfo);
1557 #ifndef __MORPHOS__
1558 w->WLayer->Window = (APTR)w;
1559 #endif
1560 /* Window needs a rastport */
1561 w->RPort = w->WLayer->rp;
1563 /* installation of the correct BorderRPort already happened above !! */
1565 if (CreateWinSysGadgets(w, IntuitionBase))
1567 LONG lock;
1569 lock = LockIBase (0);
1571 /* insert new window into parent/descendant list
1573 ** before: parent win xyz
1574 ** |
1575 ** |
1576 ** |
1577 ** descendant win abc
1579 ** after: parent win xyz
1580 ** \
1581 ** \
1582 ** newwindow w
1583 ** /
1584 ** /
1585 ** /
1586 ** descendant win abc
1589 #if 1
1591 struct Window *parent, *descendant_of_parent;
1593 parent = IntuitionBase->ActiveWindow;
1594 if (!parent) parent = w->WScreen->FirstWindow;
1595 if (parent)
1597 descendant_of_parent = parent->Descendant;
1598 parent->Descendant = w;
1599 if (descendant_of_parent) descendant_of_parent->Parent = w;
1601 else
1603 descendant_of_parent = NULL;
1606 w->Descendant = descendant_of_parent;
1607 w->Parent = parent;
1609 #endif
1611 w->NextWindow = w->WScreen->FirstWindow;
1612 w->WScreen->FirstWindow = w;
1614 w->WindowPort = GetPrivIBase(IntuitionBase)->IntuiReplyPort;
1616 UnlockIBase (lock);
1618 AddResourceToList(w, RESOURCE_WINDOW, IntuitionBase);
1620 if (w->Flags & WFLG_ACTIVATE)
1622 ActivateWindow(w);
1624 else
1626 RefreshWindowFrame(w);
1629 msg->success = TRUE;
1630 ReturnVoid("int_openwindow");
1633 CloseWindow(w);
1634 //int_closewindow(w, IntuitionBase);
1636 } /* if (layer created) */
1638 // UnlockLayers(&w->WScreen->LayerInfo);
1641 D(bug("int_openwindow(General failure)"));
1643 msg->success = FALSE;
1644 ReturnVoid("int_openwindow");