define __KERNEL_STRICT_NAMES to avoid inclusion of kernel types on systems that carry...
[cake.git] / rom / intuition / openscreen.c
blob7498db4624c7b8c166b01e3f08973df0f1bd6e21
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$
6 Open a new screen.
7 */
9 #include <exec/memory.h>
10 #include <utility/tagitem.h>
11 #include <intuition/screens.h>
12 #include <intuition/intuition.h>
13 #include <intuition/imageclass.h>
14 #include <intuition/windecorclass.h>
15 #include <intuition/scrdecorclass.h>
16 #include <intuition/gadgetclass.h>
17 #include <intuition/extensions.h>
18 #include <graphics/modeid.h>
19 #include <graphics/videocontrol.h>
20 #include <graphics/displayinfo.h>
21 #include <prefs/screenmode.h>
22 #include <proto/exec.h>
23 #include <proto/graphics.h>
24 #include <proto/layers.h>
25 #include <proto/utility.h>
26 #include <proto/intuition.h>
27 #include <proto/dos.h>
28 #include <string.h>
29 #ifdef __MORPHOS__
30 #include <proto/cybergraphics.h>
31 #include <cybergraphx/cybergraphics.h>
32 #endif
33 #include "intuition_intern.h"
34 #include "intuition_customize.h"
35 #include "intuition_extend.h"
36 #include "inputhandler.h"
37 #include "inputhandler_support.h"
38 #include "inputhandler_actions.h"
39 #include "menus.h"
41 #ifndef DEBUG_OpenScreen
42 #define DEBUG_OpenScreen 0
43 #endif
44 #undef DEBUG
45 #if DEBUG_OpenScreen
46 #define DEBUG 1
47 #endif
48 #include <aros/debug.h>
50 struct OpenScreenActionMsg
52 struct IntuiActionMsg msg;
53 struct IntScreen *Screen;
54 struct NewScreen *NewScreen;
55 struct List *List;
58 static VOID int_openscreen(struct OpenScreenActionMsg *msg,
59 struct IntuitionBase *IntuitionBase);
61 #ifdef __MORPHOS__
62 extern const ULONG defaultdricolors[DRIPEN_NUMDRIPENS];
63 #else
64 //FIXME: NUMDRIPENS == DRIPEN_NUMDRIPENS ???
65 extern const ULONG defaultdricolors[NUMDRIPENS];
66 #endif
68 #if DEBUG
69 #undef THIS_FILE
70 static const char THIS_FILE[] = __FILE__;
71 #endif
73 /*****************************************************************************
75 NAME */
77 AROS_LH1(struct Screen *, OpenScreen,
79 /* SYNOPSIS */
80 AROS_LHA(struct NewScreen *, newScreen, A0),
82 /* LOCATION */
83 struct IntuitionBase *, IntuitionBase, 33, Intuition)
85 /* FUNCTION
87 INPUTS
89 RESULT
91 NOTES
93 EXAMPLE
95 BUGS
97 SEE ALSO
99 INTERNALS
101 HISTORY
102 29-10-95 digulla automatically created from
103 intuition_lib.fd and clib/intuition_protos.h
105 *****************************************************************************/
107 AROS_LIBFUNC_INIT
109 struct NewScreen ns;
110 struct TagItem *tag, *tagList;
111 struct IntScreen *screen;
112 int success;
113 struct Hook *layer_info_hook = NULL;
114 struct ColorSpec *colors = NULL;
115 ULONG *errorPtr; /* Store error at user specified location */
116 UWORD *customdripens = NULL;
117 ULONG *colors32 = NULL;
118 WORD sysfont = -1;
119 BOOL ok = TRUE, rp_inited = FALSE, li_inited = FALSE, sharepens = FALSE;
120 #ifdef USEWINDOWLOCK
121 BOOL windowlock = FALSE;
122 #endif
123 struct Rectangle *dclip = NULL;
124 LONG overscan = OSCAN_TEXT;
125 DisplayInfoHandle displayinfo;
126 struct DimensionInfo dimensions;
127 struct MonitorInfo monitor;
128 #ifdef __MORPHOS__
129 ULONG allocbitmapflags = BMF_DISPLAYABLE;
130 #else
131 BOOL frontbm_set = FALSE;
132 struct BitMap *old_front_bm = NULL;
133 #endif
134 //ULONG lock;
135 WORD numcolors;
136 BOOL workbench = FALSE;
137 struct TagItem modetags[] =
139 { BIDTAG_Depth , 0UL },
140 { BIDTAG_DesiredWidth , 0UL },
141 { BIDTAG_DesiredHeight , 0UL },
142 { TAG_DONE }
144 ULONG modeid = INVALID_ID;
146 /* Intuition not up yet? */
147 if (!GetPrivIBase(IntuitionBase)->DefaultPointer)
148 return FALSE;
150 ASSERT_VALID_PTR_ROMOK(newScreen);
152 #define COPY(x) screen->Screen.x = ns.x
153 #define SetError(x) if (errorPtr != NULL) *errorPtr = x;
155 D(bug("OpenScreen (%p = { Left=%d Top=%d Width=%d Height=%d Depth=%d })\n"
156 , newScreen
157 , newScreen->LeftEdge
158 , newScreen->TopEdge
159 , newScreen->Width
160 , newScreen->Height
161 , newScreen->Depth
164 #ifndef __MORPHOS__
165 if (IntuitionBase->FirstScreen)
166 old_front_bm = IntuitionBase->FirstScreen->RastPort.BitMap;
167 #endif
169 FireScreenNotifyMessage((IPTR) newScreen, SNOTIFY_BEFORE_OPENSCREEN, IntuitionBase);
171 ns = *newScreen;
173 if (newScreen->Type & NS_EXTENDED)
175 tagList = ((struct ExtNewScreen *)newScreen)->Extension;
177 else
179 tagList = NULL;
182 DEBUG_OPENSCREEN(dprintf("OpenScreen: Left %d Top %d Width %d Height %d Depth %d Tags 0x%lx\n",
183 ns.LeftEdge, ns.TopEdge, ns.Width, ns.Height, ns.Depth, tagList));
185 #ifdef __MORPHOS__
186 if (!CyberGfxBase) CyberGfxBase = OpenLibrary("cybergraphics.library",0);
187 if (!CyberGfxBase) return NULL;
189 if (!LocaleBase) LocaleBase = OpenLibrary("locale.library",0);
190 if (!LocaleBase) return NULL;
191 #endif
193 #ifdef USEGETIPREFS //needs INTUITION_THEME_ENCHANCEMENT!
194 if (!GetPrivIBase(IntuitionBase)->IPrefsLoaded && FindPort(SKINMANAGERPORTNAME))
196 /* let's init prefs before 1st OpenScreen that needs them*/
197 int_SkinAction(SKA_GetIPrefs,0,0,IntuitionBase);
199 #endif
201 screen = AllocMem(sizeof (struct IntScreen), MEMF_ANY | MEMF_CLEAR);
203 DEBUG_OPENSCREEN(dprintf("OpenScreen: screen 0x%lx\n", screen));
205 /* Do this really early to be able to report errors */
206 errorPtr = (ULONG *)GetTagData((Tag)SA_ErrorCode, (ULONG)NULL, (struct TagItem *)tagList);
208 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ErrorCode 0x%lx\n",errorPtr));
210 if (screen == NULL)
212 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
213 SetError(OSERR_NOMEM);
214 return NULL;
217 if (tagList)
219 if (GetTagData(SA_LikeWorkbench, FALSE, tagList))
222 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_LikeWorkbench\n"));
224 ns.Width = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width;
225 ns.Height = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height;
226 ns.Depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth;
227 modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID;
229 if (GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Control & SMF_AUTOSCROLL)
231 /* need to mark autoscroll */
232 ns.Type |= AUTOSCROLL;
234 sysfont = 1;
235 sharepens = TRUE; /* not sure */
238 while((tag = NextTagItem ((const struct TagItem **)&tagList)))
240 #if 1
241 DEBUG_OPENSCREEN(dprintf("OpenScreen: Tag 0x%08lx Data 0x%08lx\n",
242 tag->ti_Tag, tag->ti_Data));
243 #endif
244 switch(tag->ti_Tag)
246 case SA_Left:
247 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Left %ld\n",tag->ti_Data));
248 ns.LeftEdge = tag->ti_Data;
249 break;
251 case SA_Top:
252 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Top %ld\n",tag->ti_Data));
253 ns.TopEdge = tag->ti_Data;
254 break;
256 case SA_Width:
257 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Width %ld\n",tag->ti_Data));
258 ns.Width = tag->ti_Data;
259 break;
261 case SA_Height:
262 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Height %ld\n",tag->ti_Data));
263 ns.Height = tag->ti_Data;
264 break;
266 case SA_Depth:
267 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Depth %ld\n",tag->ti_Data));
268 ns.Depth = tag->ti_Data;
269 break;
271 case SA_DetailPen:
272 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DetailPen %ld\n",tag->ti_Data));
273 ns.DetailPen = tag->ti_Data;
274 break;
276 case SA_BlockPen:
277 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BlockPen %ld\n",tag->ti_Data));
278 ns.BlockPen = tag->ti_Data;
279 break;
281 case SA_Type:
282 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Type 0x%lx\n",tag->ti_Data));
283 ns.Type &= ~SCREENTYPE;
284 ns.Type |= tag->ti_Data;
285 break;
287 case SA_Title:
288 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Title <%s>\n",tag->ti_Data));
289 ns.DefaultTitle = (UBYTE *)tag->ti_Data;
290 break;
292 case SA_ID:
293 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ID <%s>\n",tag->ti_Data));
294 screen->ID = StrDup((STRPTR)tag->ti_Data);
295 break;
297 case SA_Font:
298 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Font 0x%lx\n",tag->ti_Data));
299 ns.Font = (struct TextAttr *)tag->ti_Data;
300 break;
302 case SA_Colors32:
303 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors32 0x%lx\n",tag->ti_Data));
304 colors32 = (ULONG *)tag->ti_Data;
305 break;
307 case SA_Colors:
308 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors 0x%lx\n",tag->ti_Data));
309 colors = (struct ColorSpec *)tag->ti_Data;
310 break;
312 case SA_SysFont:
313 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SysFont 0x%lx\n",tag->ti_Data));
314 sysfont = (WORD)tag->ti_Data;
315 break;
317 case SA_BitMap:
318 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap 0x%lx\n",tag->ti_Data));
319 if(tag->ti_Data)
321 ns.Type |= CUSTOMBITMAP;
322 ns.CustomBitMap = (struct BitMap *)tag->ti_Data;
324 else
326 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap==NULL specified, custom bitmap use disabled\n"));
328 break;
330 /* Name of this public screen. */
331 case SA_PubName:
332 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubName <%s>\n",tag->ti_Data));
333 if (!tag->ti_Data)
335 screen->pubScrNode = AllocMem(sizeof(struct PubScreenNode), MEMF_CLEAR);
336 break;
338 else
340 struct Screen *old;
342 LockPubScreenList();
344 if (strcmp((char *)tag->ti_Data, "Workbench") == 0)
346 #warning This would still not be safe, if a normal app tried to open its own screen with SA_PubName=Workbench
347 if (GetPrivIBase(IntuitionBase)->WorkBench)
349 UnlockPubScreenList();
351 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
353 return NULL;
355 workbench = TRUE;
357 else
359 old = LockPubScreen((STRPTR)tag->ti_Data);
361 if (old != NULL)
363 UnlockPubScreen(NULL, old);
364 SetError(OSERR_PUBNOTUNIQUE);
365 UnlockPubScreenList();
366 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
368 return NULL;
372 UnlockPubScreenList();
375 screen->pubScrNode = AllocMem(sizeof(struct PubScreenNode), MEMF_CLEAR);
377 DEBUG_OPENSCREEN(dprintf("OpenScreen: pubScrNode 0x%lx\n",screen->pubScrNode));
379 if (screen->pubScrNode == NULL)
381 SetError(OSERR_NOMEM);
382 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
384 return NULL;
387 if ((ns.Type & SCREENTYPE) == CUSTOMSCREEN)
389 ns.Type &= ~SCREENTYPE;
390 ns.Type |= PUBLICSCREEN;
393 screen->pubScrNode->psn_Node.ln_Name = AllocVec(MAXPUBSCREENNAME + 1,
394 MEMF_ANY);
396 if (screen->pubScrNode->psn_Node.ln_Name == NULL)
398 SetError(OSERR_NOMEM);
399 FreeMem(screen->pubScrNode, sizeof(struct PubScreenNode));
400 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
402 return NULL;
405 /* Always open public screens in private mode. */
406 screen->pubScrNode->psn_Flags |= PSNF_PRIVATE;
407 strcpy(screen->pubScrNode->psn_Node.ln_Name, (STRPTR)tag->ti_Data);
408 break;
410 /* Signal bit number to use when signalling public screen
411 signal task. */
412 case SA_PubSig:
413 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubSig 0x%lx\n",tag->ti_Data));
414 if (screen->pubScrNode == NULL)
416 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
418 return NULL;
420 /* If no PubTask is set, we set the calling task as default */
421 if (screen->pubScrNode->psn_SigTask == NULL)
422 screen->pubScrNode->psn_SigTask = FindTask(NULL);
424 screen->pubScrNode->psn_SigBit = (UBYTE)tag->ti_Data;
425 break;
427 /* Task that should be signalled when the public screen loses
428 its last visitor window. */
429 case SA_PubTask:
430 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubTask 0x%lx\n",tag->ti_Data));
431 if (screen->pubScrNode == NULL)
433 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
434 return NULL;
436 screen->pubScrNode->psn_SigTask = (struct Task *)tag->ti_Data;
437 break;
439 case SA_BackFill:
440 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackFill Hook 0x%lx\n",tag->ti_Data));
441 layer_info_hook = (struct Hook *)tag->ti_Data;
442 break;
444 case SA_Quiet:
445 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Quiet 0x%lx\n",tag->ti_Data));
446 if (tag->ti_Data)
448 ns.Type |= SCREENQUIET;
450 else
452 ns.Type &= ~SCREENQUIET;
454 break;
456 case SA_ShowTitle:
457 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ShowTitle 0x%lx\n",tag->ti_Data));
458 if (tag->ti_Data)
460 ns.Type |= SHOWTITLE;
462 else
464 ns.Type &= ~SHOWTITLE;
466 break;
468 case SA_Pens:
469 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Pens 0x%lx\n",tag->ti_Data));
470 customdripens = (UWORD *)tag->ti_Data;
471 break;
473 case SA_DisplayID:
474 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DisplayID 0x%lx\n",tag->ti_Data));
475 //if (modeid == INVALID_ID)
476 modeid = tag->ti_Data;
477 break;
479 case SA_SharePens:
480 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SharePens 0x%lx\n",tag->ti_Data));
481 sharepens = tag->ti_Data ? TRUE : FALSE;
482 if (tag->ti_Data)
484 ns.Type |= PENSHARED;
486 else
488 ns.Type &= ~PENSHARED;
490 break;
492 case SA_Interleaved:
493 #ifdef __MORPHOS__
494 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Interleaved 0x%lx\n",tag->ti_Data));
495 if (tag->ti_Data)
497 allocbitmapflags |= BMF_INTERLEAVED;
499 else
501 allocbitmapflags &= ~BMF_INTERLEAVED;
503 #endif
504 break;
506 case SA_Behind:
507 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Behind 0x%lx\n",tag->ti_Data));
508 if (tag->ti_Data)
510 ns.Type |= SCREENBEHIND;
512 else
514 ns.Type &= ~SCREENBEHIND;
516 break;
518 case SA_DClip:
519 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DClip 0x%lx\n",tag->ti_Data));
520 dclip = (struct Rectangle *)tag->ti_Data;
521 break;
523 case SA_Overscan:
524 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_OverScan 0x%lx\n",tag->ti_Data));
525 overscan = tag->ti_Data;
526 break;
528 case SA_LikeWorkbench:
529 case SA_ErrorCode:
531 * handled elsewhere
533 break;
535 case SA_AutoScroll:
536 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_AutoScroll 0x%lx\n",tag->ti_Data));
537 ns.Type |= AUTOSCROLL;
538 break;
540 case SA_FullPalette:
541 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FullPalette 0x%lx\n",tag->ti_Data));
542 break;
544 case SA_ColorMapEntries:
545 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ColorMapEntries 0x%lx\n",tag->ti_Data));
546 break;
548 case SA_Parent:
549 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Parent 0x%lx\n",tag->ti_Data));
550 break;
552 case SA_Draggable:
553 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Draggable 0x%lx\n",tag->ti_Data));
554 break;
556 case SA_Exclusive:
557 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Exclusive 0x%lx\n",tag->ti_Data));
558 break;
560 case SA_VideoControl:
561 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_VideoControl 0x%lx\n",tag->ti_Data));
562 break;
564 case SA_FrontChild:
565 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FrontChild 0x%lx\n",tag->ti_Data));
566 break;
568 case SA_BackChild:
569 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackChild 0x%lx\n",tag->ti_Data));
570 break;
572 case SA_MinimizeISG:
573 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_MinimizeISG 0x%lx\n",tag->ti_Data));
574 break;
576 #warning TODO: Missing SA_ Tags
577 default:
578 DEBUG_OPENSCREEN(dprintf("OpenScreen: unknown tag 0x%lx data 0x%lx\n",
579 tag->ti_Tag,
580 tag->ti_Data));
581 break;
583 } /* switch (tag->ti_Tag) */
585 } /* while ((tag = NextTagItem (&tagList))) */
587 } /* if (tagList) */
589 DEBUG_OPENSCREEN(dprintf("OpenScreen: Left %d Top %d Width %d Height %d Depth %d Tags 0x%lx\n",
590 ns.LeftEdge, ns.TopEdge, ns.Width, ns.Height, ns.Depth, tagList));
592 /* First Init the RastPort then get the BitPlanes!! */
594 modetags[0].ti_Data = ns.Depth;
595 if (ns.Width != STDSCREENWIDTH)
597 modetags[1].ti_Data = ns.Width;
599 else
601 modetags[1].ti_Tag = TAG_IGNORE;
604 if (ns.Height != STDSCREENHEIGHT)
606 modetags[2].ti_Data = ns.Height;
608 else
610 modetags[2].ti_Tag = TAG_IGNORE;
613 #ifdef __MORPHOS__
614 // if default HIRES_KEY or HIRESLACE_KEY is passed, make sure we find a replacement
615 // cybergraphx mode
617 if (INVALID_ID != modeid)
619 if (FindDisplayInfo(modeid) == NULL)
621 switch(modeid)
623 case HIRES_KEY:
624 case HIRESLACE_KEY:
626 struct TagItem bestmodetags[] =
628 { CYBRBIDTG_Depth , 0UL },
629 { CYBRBIDTG_NominalWidth , 0UL },
630 { CYBRBIDTG_NominalHeight , 0UL },
631 { TAG_DONE }
634 bestmodetags[0].ti_Data = 8;
635 bestmodetags[1].ti_Data = ns.Width;
636 bestmodetags[2].ti_Data = ns.Height;
638 DEBUG_OPENSCREEN(dprintf("resetting native mode id !!\n");)
639 DEBUG_OPENSCREEN(dprintf("ns.Width %ld ns.Height %ld ns.Depth %ld !!\n",
640 (LONG) ns.Width, (LONG) ns.Height, (LONG) ns.Depth);)
643 modeid = BestCModeIDTagList(bestmodetags);
645 DEBUG_OPENSCREEN(dprintf("BestCModeIDTagList returned %ld\n",modeid);)
647 break;
649 default:
650 break;
655 #endif
657 if (INVALID_ID == modeid)
659 modeid = BestModeIDA(modetags);
660 if (INVALID_ID == modeid)
662 DEBUG_OPENSCREEN(dprintf("!!! OpenScreen(): Could not find valid modeid !!!\n");)
663 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
665 return NULL;
669 DEBUG_OPENSCREEN(dprintf("OpenScreen: ModeID 0x%08lx\n", modeid));
671 #ifdef __MORPHOS__
673 InitRastPort(&screen->Screen.RastPort);
674 rp_inited = TRUE;
675 success = FALSE;
676 numcolors = 0;
678 if ((displayinfo = FindDisplayInfo(modeid)) != NULL &&
679 GetDisplayInfoData(displayinfo, &dimensions, sizeof(dimensions), DTAG_DIMS, modeid) &&
680 GetDisplayInfoData(displayinfo, &monitor, sizeof(monitor), DTAG_MNTR, modeid))
682 success = TRUE;
684 screen->Monitor = monitor.Mspc;
686 if (dclip == NULL)
688 switch (overscan)
690 case OSCAN_STANDARD:
691 dclip = &dimensions.StdOScan;
692 break;
694 case OSCAN_MAX:
695 dclip = &dimensions.MaxOScan;
696 break;
698 case OSCAN_VIDEO:
699 dclip = &dimensions.VideoOScan;
700 break;
702 default:
703 dclip = &dimensions.TxtOScan;
704 break;
708 if (ns.Width == STDSCREENWIDTH)
709 ns.Width = dclip->MaxX - dclip->MinX + 1;
711 if (ns.Height == STDSCREENHEIGHT)
712 ns.Height = dclip->MaxY - dclip->MinY + 1;
714 DEBUG_OPENSCREEN(dprintf("OpenScreen: Monitor 0x%lx Width %ld Height %ld\n",
715 screen->Monitor, ns.Width, ns.Height));
717 if (ns.Type & CUSTOMBITMAP)
719 struct BitMap *custombm;
721 custombm = ns.CustomBitMap;
723 if (IsCyberModeID(modeid) && custombm)
725 int pixfmt = GetCyberIDAttr(CYBRIDATTR_PIXFMT,modeid);
727 if(GetCyberMapAttr(custombm,CYBRMATTR_PIXFMT) != pixfmt)
729 // incompatible formats !
730 custombm = NULL;
734 if(custombm != NULL)
736 screen->Screen.RastPort.BitMap = custombm;
737 ns.Depth = GetBitMapAttr(ns.CustomBitMap,BMA_DEPTH);
738 DEBUG_OPENSCREEN(dprintf("OpenScreen: CustomBitmap Depth %ld\n",
739 ns.Depth));
741 else
743 ns.CustomBitMap = NULL;
744 ns.Type &= ~CUSTOMBITMAP;
747 else
749 screen->Screen.RastPort.BitMap = NULL;
753 if(screen->Screen.RastPort.BitMap == NULL)
755 ULONG pixfmt;
756 ULONG Depth;
758 Depth = (dimensions.MaxDepth > 8) ? dimensions.MaxDepth : ns.Depth;
760 switch(Depth)
762 case 15:
763 pixfmt = PIXFMT_RGB15;
764 break;
765 case 16:
766 pixfmt = PIXFMT_RGB16;
767 break;
768 case 24:
769 pixfmt = PIXFMT_BGR24;
770 break;
771 case 32:
772 pixfmt = PIXFMT_ARGB32;
773 break;
774 default:
775 pixfmt = PIXFMT_LUT8;
776 break;
779 if (IsCyberModeID(modeid))
781 pixfmt = GetCyberIDAttr(CYBRIDATTR_PIXFMT,modeid);
785 allocbitmapflags |= (BMF_SPECIALFMT|BMF_CLEAR);
787 screen->Screen.RastPort.BitMap = AllocBitMap(ns.Width,
788 ns.Height,
789 Depth,
790 allocbitmapflags | (pixfmt << 24),
791 NULL);
793 screen->AllocatedBitmap = screen->Screen.RastPort.BitMap;
795 memcpy(&screen->Screen.BitMap,screen->Screen.RastPort.BitMap,sizeof(struct BitMap));
798 DEBUG_OPENSCREEN(dprintf("OpenScreen: BitMap 0x%lx\n",
799 screen->Screen.RastPort.BitMap));
801 else
803 DEBUG_OPENSCREEN(dprintf("OpenScreen: no displayinfo\n"));
805 #else
806 if ((displayinfo = FindDisplayInfo(modeid)) != NULL &&
807 GetDisplayInfoData(displayinfo, (UBYTE *)&dimensions, sizeof(dimensions), DTAG_DIMS, modeid) &&
808 GetDisplayInfoData(displayinfo, (UBYTE *)&monitor, sizeof(monitor), DTAG_MNTR, modeid))
810 screen->Monitor = monitor.Mspc;
812 if (dclip == NULL)
814 switch (overscan)
816 case OSCAN_STANDARD:
817 dclip = &dimensions.StdOScan;
818 break;
820 case OSCAN_MAX:
821 dclip = &dimensions.MaxOScan;
822 break;
824 case OSCAN_VIDEO:
825 dclip = &dimensions.VideoOScan;
826 break;
828 default:
829 dclip = &dimensions.TxtOScan;
830 break;
834 if (ns.Width == STDSCREENWIDTH)
835 ns.Width = dclip->MaxX - dclip->MinX + 1;
837 if (ns.Height == STDSCREENHEIGHT)
838 ns.Height = dclip->MaxY - dclip->MinY + 1;
842 if ((success = InitRastPort (&screen->Screen.RastPort)))
844 rp_inited = TRUE;
847 screen->Screen.RastPort.BitMap = screen->AllocatedBitmap = AllocScreenBitMap(modeid);
849 #endif
850 D(bug("got bitmap\n"));
852 /* Init screen's viewport */
853 InitVPort(&screen->Screen.ViewPort);
855 /* Allocate a RasInfo struct in which we have a pointer
856 to the struct BitMap, into which the driver can
857 store its stuff. (Eg. pointer to a BitMap HIDD object)
859 screen->Screen.ViewPort.RasInfo = AllocMem(sizeof(struct RasInfo), MEMF_ANY | MEMF_CLEAR);
861 DEBUG_OPENSCREEN(dprintf("OpenScreen: RasInfo 0x%lx\n",
862 screen->Screen.ViewPort.RasInfo));
864 if (!success ||
865 (screen->Screen.RastPort.BitMap == NULL) ||
866 (screen->Screen.ViewPort.RasInfo == NULL))
868 ok = FALSE;
870 else
872 /* Store pointer to bitmap, so we can get hold of it
873 from withing LoadRGBxx() functions
875 D(bug("got allocated stuff\n"));
876 screen->Screen.ViewPort.RasInfo->BitMap = screen->Screen.RastPort.BitMap;
880 if (ok)
882 /* Read depth from the bitmap to avoid AttachPalExtra/ObtainPen getting
883 * confused if cgx decided to allocate a higher depth bitmap than what
884 * was asked.
886 ns.Depth = GetBitMapAttr(screen->Screen.RastPort.BitMap,BMA_DEPTH);
888 numcolors = (ns.Depth <= 8) ? (1L << ns.Depth) : 256;
890 /* Get a color map structure. Sufficient colors?? */
892 DEBUG_OPENSCREEN(dprintf("OpenScreen: Colormap Entries %ld\n",
893 numcolors));
895 if ((screen->Screen.ViewPort.ColorMap = GetColorMap(numcolors < 32 ? 32 : numcolors)) != NULL)
898 #ifndef __MORPHOS__ /* Use VideoControl for MorphOS */
899 screen->Screen.ViewPort.ColorMap->VPModeID = modeid;
900 #endif
902 if (0 == AttachPalExtra(screen->Screen.ViewPort.ColorMap,
903 &screen->Screen.ViewPort))
905 #if 0
906 int i = 0;
907 char *alloclist;
908 UWORD *refcnt;
910 refcnt =(UWORD*) screen->Screen.ViewPort.ColorMap->PalExtra->pe_RefCnt;
911 alloclist = (UBYTE *)(refcnt + screen->Screen.ViewPort.ColorMap->Count);
913 DEBUG_OPENSCREEN(dprintf("OpenScreen: PalExtra alloclist 0x%lx Count %ld\n",alloclist,screen->Screen.ViewPort.ColorMap->Count));
915 while(i < screen->Screen.ViewPort.ColorMap->Count)
917 // initialize alloc list to -1,0,1,2,3,4
919 DEBUG_OPENSCREEN(dprintf("OpenScreen: alloclist[%ld]=%ld\n",
920 i,alloclist[i]));
921 i++;
923 #endif
925 else
927 ok = FALSE;
930 else
932 ok = FALSE;
935 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx\n",
936 screen->Screen.ViewPort.ColorMap));
939 #ifdef __MORPHOS__
941 screen->ModeID = modeid;
943 if (ok)
945 struct ViewPortExtra *vpe = GfxNew(VIEWPORT_EXTRA_TYPE);
947 DEBUG_OPENSCREEN(dprintf("OpenScreen: ViewPortExtra 0x%lx\n", vpe));
949 ok = FALSE;
951 if (vpe)
953 struct TagItem tags[6];
955 memcpy(&vpe->DisplayClip, dclip,sizeof(struct Rectangle));
957 screen->Screen.ViewPort.DWidth = dclip->MaxX - dclip->MinX + 1;//ns.Width; /* or from dclip ? */
958 screen->Screen.ViewPort.DHeight = dclip->MaxY - dclip->MinY + 1;//ns.Height;
960 tags[0].ti_Tag = VTAG_ATTACH_CM_SET;
961 tags[0].ti_Data = (IPTR)&screen->Screen.ViewPort;
962 tags[1].ti_Tag = VTAG_VIEWPORTEXTRA_SET;
963 tags[1].ti_Data = (IPTR)vpe;
964 tags[2].ti_Tag = VTAG_NORMAL_DISP_SET;
965 tags[2].ti_Data = (IPTR)displayinfo;
966 tags[3].ti_Tag = VTAG_VPMODEID_SET;
967 tags[3].ti_Data = modeid;
968 tags[4].ti_Tag = VTAG_END_CM;
969 tags[5].ti_Tag = TAG_END;
971 if (VideoControl(screen->Screen.ViewPort.ColorMap, tags) == 0)
973 DEBUG_OPENSCREEN(dprintf("OpenScreen: VideoControl ok\n"));
974 ok = TRUE;
976 else
978 DEBUG_OPENSCREEN(dprintf("OpenScreen: VideoControl failed\n"));
982 // added 2002-03-10, pre iprefs openscreen has all first 4 colours black (cyfm)
983 // removed 2002-26-12, I now set the pens on start (zapek)
984 #if 0
985 if ((p = GetPrivIBase(IntuitionBase)->Colors))
987 int Sum;
989 DEBUG_OPENSCREEN(dprintf("OpenScreen: Intuition Color32 Table 0x%lx\n",p);)
991 Sum = p[0].red + p[0].green + p[0].blue;
992 Sum += p[1].red + p[1].green + p[1].blue;
993 Sum += p[2].red + p[2].green + p[2].blue;
994 Sum += p[3].red + p[3].green + p[3].blue;
995 if (Sum==0)
997 int i;
999 DEBUG_OPENSCREEN(dprintf("OpenScreen: All 4 first colours black, reset !!\n");)
1001 for (i = 0; i < COLORTABLEENTRIES; i++)
1003 DEBUG_OPENSCREEN(dprintf("OpenScreen: Current Color32[%ld] R 0x%lx G 0x%lx B 0x%lx\n",
1005 p[i].red, p[i].green, p[i].blue));
1007 p[0].red = 0xAAAAAAAA;
1008 p[0].green = 0xAAAAAAAA;
1009 p[0].blue = 0xAAAAAAAA;
1011 p[1].red = 0x00000000;
1012 p[1].green = 0x00000000;
1013 p[1].blue = 0x00000000;
1015 p[2].red = 0xFFFFFFFF;
1016 p[2].green = 0xFFFFFFFF;
1017 p[2].blue = 0xFFFFFFFF;
1019 p[3].red = 0x55555555;
1020 p[3].green = 0x77777777;
1021 p[3].blue = 0xAAAAAAAA;
1025 #endif
1028 #endif
1030 if (ok)
1032 struct Color32 *p;
1033 int k, c;
1034 UWORD *q;
1036 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set first 4 colors\n"));
1038 p = GetPrivIBase(IntuitionBase)->Colors;
1039 for (k = 0; k < 4 && k < numcolors; ++k)
1041 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB32 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1042 screen->Screen.ViewPort,
1043 k, p[k].red, p[k].green, p[k].blue));
1044 SetRGB32(&screen->Screen.ViewPort, k, p[k].red, p[k].green, p[k].blue);
1047 if (ns.Depth >= 3)
1049 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set last 4 colors\n"));
1051 #warning Isn`t that only set for FullPalette ?
1052 for (k = 0; k < 4; ++k)
1054 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB32 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1055 screen->Screen.ViewPort,
1056 numcolors - k - 1, p[k+4].red, p[k+4].green, p[k+4].blue));
1058 ObtainPen(screen->Screen.ViewPort.ColorMap,
1059 numcolors - 4 + k,
1060 p[k+4].red,
1061 p[k+4].green,
1062 p[k+4].blue,
1067 DEBUG_OPENSCREEN(dprintf("OpenScreen: Obtain Mousepointer colors\n"));
1069 /* Allocate pens for the mouse pointer */
1070 q = &GetPrivIBase(IntuitionBase)->ActivePreferences->color17;
1071 if (numcolors < 20)
1072 /* FIXME: this assumes that we have at least 16 colors */
1073 c = numcolors - 7;
1074 else
1075 c = 17;
1076 for (k = 0; k < 3; ++k, ++q)
1078 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx Pen %ld R 0x%lx G 0x%lx B 0x%lx\n",
1079 screen->Screen.ViewPort.ColorMap,
1080 k + c,
1081 (*q >> 8) * 0x11111111,
1082 ((*q >> 4) & 0xf) * 0x11111111,
1083 (*q & 0xf) * 0x11111111));
1084 ObtainPen(screen->Screen.ViewPort.ColorMap,
1085 k + c,
1086 (*q >> 8) * 0x11111111,
1087 ((*q >> 4) & 0xf) * 0x11111111,
1088 (*q & 0xf) * 0x11111111,
1090 /* The following piece is left for reference only. It came from
1091 classic Amiga where mouse pointer was implemented as a hardware
1092 sprite. It always uses DAC registers 17 - 19, even for screens
1093 with small depth.
1094 In future we probably need some other mechanism for setting
1095 pointer palette, probably separate HIDD methods.
1096 if (k + 17 < numcolors)
1098 ObtainPen(screen->Screen.ViewPort.ColorMap,
1099 k + 17,
1100 (*q >> 8) * 0x11111111,
1101 ((*q >> 4) & 0xf) * 0x11111111,
1102 (*q & 0xf) * 0x11111111,
1103 PEN_EXCLUSIVE);
1105 else
1107 ** Can't be allocated, but can still be set. **
1108 SetRGB32(&screen->Screen.ViewPort,
1109 k + 17,
1110 (*q >> 8) * 0x11111111,
1111 ((*q >> 4) & 0xf) * 0x11111111,
1112 (*q & 0xf) * 0x11111111);
1116 if (colors) /* if SA_Colors tag exists */
1118 DEBUG_OPENSCREEN(dprintf("OpenScreen: set SA_Colors 0x%lx\n",colors));
1119 for(; colors->ColorIndex != (WORD)~0; colors++)
1121 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB4 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1122 screen->Screen.ViewPort,
1123 colors,
1124 colors->Red,
1125 colors->Green,
1126 colors->Blue));
1127 SetRGB4(&screen->Screen.ViewPort,
1128 colors->ColorIndex,
1129 colors->Red,
1130 colors->Green,
1131 colors->Blue);
1135 if (colors32) /* if SA_Colors32 tag exists */
1137 DEBUG_OPENSCREEN(dprintf("OpenScreen: LoadRGB32 colors32 0x%lx\n",colors32));
1138 LoadRGB32(&screen->Screen.ViewPort, (const ULONG *)colors32);
1141 D(bug("Loaded colors\n"));
1143 COPY(LeftEdge);
1144 COPY(TopEdge);
1145 COPY(Width);
1146 COPY(Height);
1147 COPY(DetailPen);
1148 COPY(BlockPen);
1149 COPY(Font);
1150 COPY(DefaultTitle);
1152 //intui68k filters this
1153 screen->Screen.Flags = (ns.Type & ~NS_EXTENDED);
1155 /* Temporary hack */
1156 if (ns.Width >= 500 || ns.Height >= 300)
1157 screen->Screen.Flags |= SCREENHIRES;
1159 #ifndef __MORPHOS__
1160 /* Mark the bitmap of the screen as an AROS-displayed BitMap */
1161 screen->Screen.RastPort.BitMap->Flags |= BMF_AROS_HIDD;
1162 #endif
1165 Copy the data from the rastport's bitmap
1166 to the screen's bitmap structure
1168 screen->Screen.BitMap = *screen->Screen.RastPort.BitMap;
1170 #ifdef __MORPHOS__
1171 screen->Screen.WBorTop = 2;
1172 screen->Screen.WBorLeft = 4;
1173 screen->Screen.WBorRight = 4;
1174 screen->Screen.WBorBottom = 2;
1175 #else
1176 screen->Screen.WBorTop = 3; /* Amiga default is 2 */
1177 screen->Screen.WBorLeft = 4;
1178 screen->Screen.WBorRight = 4;
1179 screen->Screen.WBorBottom = 2; /* Amiga default is 2 */
1180 #endif
1182 screen->Screen.Title = ns.DefaultTitle;
1184 if (screen->ID == NULL) if (screen->Screen.Title) screen->ID = StrDup(screen->Screen.Title);
1186 DEBUG_OPENSCREEN(dprintf("OpenScreen: init layers\n"));
1187 InitLayers(&screen->Screen.LayerInfo);
1188 li_inited = TRUE;
1190 #if 0
1191 /* Root layer now installed automatically by first call
1192 to CreateLayerTagList */
1194 #ifdef CreateLayerTagList
1196 struct TagItem tags[4] =
1198 {LA_Visible , FALSE },
1199 {LA_Priority, ROOTPRIORITY },
1200 {TAG_DONE }
1203 screen->rootLayer =
1204 CreateLayerTagList(&screen->Screen.LayerInfo,
1205 screen->Screen.RastPort.BitMap,
1206 screen->Screen.LeftEdge,
1207 screen->Screen.TopEdge,
1208 screen->Screen.LeftEdge + screen->Screen.Width - 1,
1209 screen->Screen.TopEdge + screen->Screen.Height - 1,
1211 tags);
1213 DEBUG_OPENSCREEN(dprintf("OpenScreen: rootLayer 0x%lx\n",screen->rootLayer));
1215 #endif
1216 #endif
1218 if (NULL != layer_info_hook)
1220 DEBUG_OPENSCREEN(dprintf("OpenScreen: instal layerinfohook\n"));
1221 InstallLayerInfoHook(&screen->Screen.LayerInfo, layer_info_hook);
1223 D(bug("layers intited screen\n"));
1225 screen->DInfo.dri.dri_Version = DRI_VERSION;
1226 screen->DInfo.dri.dri_NumPens = NUMDRIPENS;
1227 screen->DInfo.dri.dri_Pens = screen->Pens;
1228 /* dri_Depth is 8 on hi/true color screens like in AmigaOS with picasso96/cybergraphx */
1229 screen->DInfo.dri.dri_Depth = (ns.Depth <= 8) ? ns.Depth : 8;
1230 #warning These are probably monitor dependent
1231 screen->DInfo.dri.dri_Resolution.X = 44;
1232 screen->DInfo.dri.dri_Resolution.Y = 44;
1234 if (ns.Depth > 8) screen->DInfo.dri.dri_Flags = DRIF_DIRECTCOLOR;
1236 screen->DInfo.dri_Screen = &screen->Screen;
1238 /* SA_SysFont overrides SA_Font! */
1240 DEBUG_OPENSCREEN(dprintf("OpenScreen: SysFont = %d, ns.Font = %p\n", sysfont, ns.Font));
1242 if (sysfont == 0)
1244 /* Is handled below */
1245 DEBUG_OPENSCREEN(dprintf("OpenScreen: skip SysFont for now\n"));
1247 else if (sysfont == 1)
1249 #if 1
1250 /* Use safe OpenFont here - Piru
1252 screen->DInfo.dri.dri_Font = SafeReopenFont(IntuitionBase, &GetPrivIBase(IntuitionBase)->ScreenFont);
1253 #else
1255 #warning: Really hacky way of re-opening ScreenFont
1257 Forbid();
1258 screen->DInfo.dri.dri_Font = GetPrivIBase(IntuitionBase)->ScreenFont;
1259 screen->DInfo.dri.dri_Font->tf_Accessors++;
1260 Permit();
1261 #endif
1263 screen->SpecialFlags |= SF_SysFont;
1265 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set ScreenFont\n"));
1268 else if (ns.Font)
1270 screen->DInfo.dri.dri_Font = OpenFont(ns.Font);
1271 DEBUG_OPENSCREEN(dprintf("OpenScreen: custom font 0x%lx\n",screen->DInfo.dri.dri_Font));
1274 if (!screen->DInfo.dri.dri_Font)
1276 /* GfxBase->DefaultFont is *not* always topaz 8. It
1277 can be set with the Font prefs program!! */
1279 #if 1
1280 /* Use safe OpenFont.. - Piru
1282 screen->DInfo.dri.dri_Font = SafeReopenFont(IntuitionBase, &GfxBase->DefaultFont);
1283 #else
1285 #warning: Really hacky way of re-opening system default font
1287 Forbid();
1288 screen->DInfo.dri.dri_Font = GfxBase->DefaultFont;
1289 screen->DInfo.dri.dri_Font->tf_Accessors++;
1290 Permit();
1291 #endif
1294 if (!screen->DInfo.dri.dri_Font) ok = FALSE;
1296 } /* if (ok) */
1298 if (ok)
1300 /* set default values for pens */
1301 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set Default Pens\n"));
1303 CopyMem(ns.Depth == 1 ? GetPrivIBase(IntuitionBase)->DriPens2
1304 : ns.Depth == 4 ? GetPrivIBase(IntuitionBase)->DriPens4
1305 : GetPrivIBase(IntuitionBase)->DriPens8,
1306 screen->Pens,
1307 sizeof(screen->Pens));
1309 if (ns.Depth > 1)
1311 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set NewLook\n"));
1312 screen->DInfo.dri.dri_Flags |= DRIF_NEWLOOK;
1316 if (customdripens)
1318 WORD i;
1320 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set Custom Pens\n"));
1322 screen->Pens[DETAILPEN] = screen->Screen.DetailPen;
1323 screen->Pens[BLOCKPEN] = screen->Screen.BlockPen;
1325 for(i = 0; (i < NUMDRIPENS) && (customdripens[i] != (UWORD)~0); i++)
1327 DEBUG_OPENSCREEN(dprintf("OpenScreen: Pen[%ld] %ld\n",i,screen->Pens[i]));
1328 screen->Pens[i] = customdripens[i];
1331 else
1334 * Let`s do some broken software validation of the pens
1335 * so we may not run into a black desktop.
1338 DEBUG_OPENSCREEN(dprintf("OpenScreen: Check Default Pens if the make sense\n"));
1339 if (screen->Screen.DetailPen == screen->Screen.BlockPen)
1341 DEBUG_OPENSCREEN(dprintf("OpenScreen: DetailPen==BlockPen..correct\n"));
1342 screen->Screen.DetailPen = 0;
1343 screen->Screen.BlockPen = 1;
1345 else
1346 if (screen->Screen.BlockPen == 0)
1348 DEBUG_OPENSCREEN(dprintf("OpenScreen: BlockPen==0..correct\n"));
1349 screen->Screen.BlockPen = screen->Screen.DetailPen;
1350 screen->Screen.DetailPen = 0;
1353 screen->Pens[DETAILPEN] = screen->Screen.DetailPen;
1354 screen->Pens[BLOCKPEN] = screen->Screen.BlockPen;
1357 /* Allocate shared/exclusive colors */
1360 BYTE color_alloced[256];
1362 WORD i;
1364 for(i = 0; i < 256; i++)
1366 color_alloced[i] = FALSE;
1369 /* Mouse pointer colors */
1371 color_alloced[17] = TRUE;
1372 color_alloced[18] = TRUE;
1373 color_alloced[19] = TRUE;
1375 /* The Pens in the DrawInfo must be allocated as shared */
1377 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen DrawInfo Pens as shared\n"));
1379 for(i = 0; i < NUMDRIPENS; i++)
1381 int pen = screen->Pens[i];
1383 if (!color_alloced[pen])
1385 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen ColorMap 0x%lx Pen %ld\n",
1386 screen->Screen.ViewPort.ColorMap,
1387 pen));
1389 ObtainPen(screen->Screen.ViewPort.ColorMap,
1390 pen,
1394 PENF_NO_SETCOLOR);
1395 color_alloced[pen] = TRUE;
1398 DEBUG_OPENSCREEN(dprintf("OpenScreen: done\n"));
1400 /* If SA_SharePens is FALSE then allocate the rest of the colors
1401 in the colormap as exclusive */
1403 if (!sharepens)
1405 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen the remaining Pens as exclusive\n"));
1407 for(i = 0; i < numcolors; i++)
1409 if (!color_alloced[i])
1411 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen ColorMap 0x%lx Pen %ld\n",
1412 screen->Screen.ViewPort.ColorMap,
1413 i));
1414 ObtainPen(screen->Screen.ViewPort.ColorMap,
1419 PENF_EXCLUSIVE | PENF_NO_SETCOLOR);
1423 } /* if (!sharepens) */
1428 #ifndef __MORPHOS__
1429 if (ok)
1431 if (!SetFrontBitMap(screen->Screen.RastPort.BitMap, TRUE))
1432 ok = FALSE;
1433 else
1434 frontbm_set = TRUE;
1436 #endif
1438 #ifdef SKINS
1439 if (ok)
1441 ULONG realdepth;
1443 screen->DInfo.dri_Screen = &screen->Screen; //useful sometimes ;)
1445 realdepth = GetBitMapAttr( screen->Screen.RastPort.BitMap, BMA_DEPTH );
1446 if (realdepth > 8)
1448 screen->DInfo.dri_Flags |= DRIF_DIRECTCOLOR;
1450 else
1452 screen->DInfo.dri_Flags &= ~DRIF_DIRECTCOLOR;
1455 if (!(screen->DInfo.dri_Colors = AllocMem(4 * DRIPEN_NUMDRIPENS,MEMF_PUBLIC)))
1456 ok = FALSE;
1458 if (ok)
1460 CopyMem(&defaultdricolors,screen->DInfo.dri_Colors,sizeof (defaultdricolors));
1461 memset(((UBYTE *) screen->DInfo.dri_Colors) + sizeof(defaultdricolors), 0, 4 * DRIPEN_NUMDRIPENS - sizeof(defaultdricolors));
1464 if (ok)
1466 if ((screen->DInfo.dri_Customize = AllocMem(sizeof (struct IntuitionCustomize),MEMF_PUBLIC|MEMF_CLEAR)))
1468 struct IntuitionCustomize *ic;
1469 ic = screen->DInfo.dri_Customize;
1470 screen->DInfo.dri_Flags |= DRIF_SKINSSUPPORT;
1471 /* This initializes CustomizePrefs structure */
1473 int_SkinAction(SKA_LoadSkin,(ULONG*)&screen->DInfo,(struct Screen *)screen,IntuitionBase);
1475 else
1477 ok = FALSE;
1482 if (ok)
1484 struct windowclassprefs *wcprefs;
1486 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,&screen->DInfo,IntuitionBase);
1487 if (wcprefs->flags & WINDOWCLASS_PREFS_1TO1FRAMES)
1489 screen->Screen.WBorLeft = screen->Screen.WBorTop;
1490 screen->Screen.WBorRight = screen->Screen.WBorTop;
1491 screen->Screen.WBorBottom = screen->Screen.WBorTop;
1493 #ifdef TITLEHACK
1494 screen->Screen.WBorTop += wcprefs->titlebarincrement;
1495 #endif
1496 int_FreeCustomPrefs(TYPE_WINDOWCLASS,&screen->DInfo,IntuitionBase);
1499 #endif
1501 if (ok)
1503 IPTR userbuffersize;
1505 struct NewDecorator *nd;
1507 nd = ((struct IntIntuitionBase *)(IntuitionBase))->Decorator;
1509 ObtainSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
1511 struct DosLibrary *DOSBase;
1513 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 40);
1514 if (DOSBase)
1516 struct Node *node;
1517 if (!IsListEmpty(&GetPrivIBase(IntuitionBase)->Decorations))
1519 node = GetPrivIBase(IntuitionBase)->Decorations.lh_Head;
1520 for (; node->ln_Succ; node = node->ln_Succ)
1522 struct NewDecorator *d = (struct NewDecorator *) node;
1523 if ((d->nd_IntPattern != NULL) && (screen->ID != NULL)) if (MatchPattern(d->nd_IntPattern, screen->ID)) nd = d;
1527 CloseLibrary((struct Library *) DOSBase);
1530 // if (MatchPattern(tl->parsename, task->tc_Node.ln_Name)) b = tl;
1532 if (nd != NULL)
1534 screen->ScrDecorObj = nd->nd_Screen;
1535 screen->WinDecorObj = nd->nd_Window;
1536 screen->MenuDecorObj = nd->nd_Menu;
1538 else
1540 screen->ScrDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorObj;
1541 screen->WinDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorObj;
1542 screen->MenuDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorObj;
1544 screen->Decorator = nd;
1546 if (screen->Decorator) screen->Decorator->nd_cnt++;
1548 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
1550 GetAttr(SDA_UserBuffer, screen->ScrDecorObj, &userbuffersize);
1552 if (userbuffersize)
1554 screen->DecorUserBufferSize = userbuffersize;
1555 screen->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
1556 if (!screen->DecorUserBuffer) ok = FALSE;
1560 if (ok)
1562 struct TagItem sysi_tags[] =
1564 {SYSIA_Which , MENUCHECK },
1565 {SYSIA_DrawInfo , (IPTR)&screen->DInfo },
1566 {SYSIA_UserBuffer, screen->DecorUserBuffer },
1568 {TAG_DONE }
1571 screen->DInfo.dri.dri_CheckMark = NewObjectA(NULL, "sysiclass", sysi_tags);
1572 DEBUG_OPENSCREEN(dprintf("OpenScreen: CheckMark 0x%lx\n",
1573 screen->DInfo.dri.dri_CheckMark));
1575 sysi_tags[0].ti_Data = AMIGAKEY;
1577 screen->DInfo.dri.dri_AmigaKey = NewObjectA(NULL, "sysiclass", sysi_tags);
1578 DEBUG_OPENSCREEN(dprintf("OpenScreen: AmigaKey 0x%lx\n",
1579 screen->DInfo.dri.dri_AmigaKey));
1581 sysi_tags[0].ti_Data = SUBMENUIMAGE;
1583 screen->DInfo.dri.dri_SubMenuImage = NewObjectA(NULL, "sysiclass", sysi_tags);
1584 DEBUG_OPENSCREEN(dprintf("OpenScreen: SubMenuImage 0x%lx\n",
1585 screen->DInfo.dri.dri_SubMenuImage));
1587 #ifdef SKINS
1588 sysi_tags[0].ti_Data = SUBMENUIMAGE;
1589 screen->DInfo.dri_Customize->submenu = NewObjectA(NULL, "sysiclass", sysi_tags);
1590 sysi_tags[0].ti_Data = MENUTOGGLEIMAGE;
1591 screen->DInfo.dri_Customize->menutoggle = NewObjectA(NULL, "sysiclass", sysi_tags);
1592 if (!screen->DInfo.dri_Customize->submenu ||
1593 !screen->DInfo.dri_Customize->menutoggle) ok = FALSE;
1594 #endif
1596 if (!screen->DInfo.dri.dri_CheckMark || !screen->DInfo.dri.dri_AmigaKey || !screen->DInfo.dri.dri_SubMenuImage) ok = FALSE;
1601 if (ok)
1603 SetFont(&screen->Screen.RastPort, screen->DInfo.dri.dri_Font);
1605 AskFont(&screen->Screen.RastPort, (struct TextAttr *) &screen->textattr);
1607 screen->Screen.Font = (struct TextAttr *) &screen->textattr;
1609 DEBUG_OPENSCREEN(dprintf("OpenScreen: Font %s/%d\n",
1610 screen->textattr.tta_Name, screen->textattr.tta_YSize));
1612 #ifdef __MORPHOS__
1613 screen->Screen.BarVBorder = 1;
1614 screen->Screen.BarHBorder = 5;
1615 screen->Screen.MenuVBorder = 2;
1616 screen->Screen.MenuHBorder = 4;
1617 #else
1618 screen->Screen.BarVBorder = 1; /* on the Amiga it is (usually?) 1 */
1619 screen->Screen.BarHBorder = 5;
1620 screen->Screen.MenuVBorder = 2; /* on the Amiga it is (usually?) 2 */
1621 screen->Screen.MenuHBorder = 4;
1622 #endif
1624 struct IntDrawInfo *dri = &screen->DInfo;
1625 struct sdpInitScreen msg;
1627 msg.MethodID = SDM_INITSCREEN;
1628 msg.sdp_Screen = &screen->Screen;
1629 msg.sdp_TrueColor = screen->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR;
1630 msg.sdp_FontHeight = screen->DInfo.dri.dri_Font->tf_YSize;
1631 msg.sdp_BarVBorder = screen->Screen.BarVBorder;
1632 msg.sdp_BarHBorder = screen->Screen.BarHBorder;
1633 msg.sdp_MenuVBorder = screen->Screen.MenuVBorder;
1634 msg.spd_MenuHBorder = screen->Screen.MenuHBorder;
1635 msg.sdp_WBorTop = screen->Screen.WBorTop;
1636 msg.sdp_WBorLeft = screen->Screen.WBorLeft;
1637 msg.sdp_WBorRight = screen->Screen.WBorRight;
1638 msg.sdp_WBorBottom = screen->Screen.WBorBottom;
1640 #ifdef TITLEHACK
1641 msg.sdp_TitleHack = screen->Screen.WBorTop-2;
1642 #else
1643 msg.sdp_TitleHack = 0;
1644 #endif
1646 msg.sdp_BarHeight = msg.sdp_FontHeight + msg.sdp_BarVBorder * 2 + msg.sdp_TitleHack;
1647 msg.sdp_UserBuffer = ((struct IntScreen *)screen)->DecorUserBuffer;
1649 if (!DoMethodA(((struct IntScreen *)(screen))->ScrDecorObj, (Msg)&msg)) ok = FALSE;
1650 if (ok)
1652 screen->Screen.BarHeight = msg.sdp_BarHeight;
1653 screen->Screen.BarVBorder = msg.sdp_BarVBorder;
1654 screen->Screen.BarHBorder = msg.sdp_BarHBorder;
1655 screen->Screen.MenuVBorder = msg.sdp_MenuVBorder;
1656 screen->Screen.MenuHBorder = msg.spd_MenuHBorder;
1657 screen->Screen.WBorTop = msg.sdp_WBorTop;
1658 screen->Screen.WBorLeft = msg.sdp_WBorLeft;
1659 screen->Screen.WBorRight = msg.sdp_WBorRight;
1660 screen->Screen.WBorBottom = msg.sdp_WBorBottom;
1665 if (ok)
1669 #define SDEPTH_HEIGHT (screen->Screen.BarHeight + 1)
1670 #ifdef IA_Screen
1671 #undef IA_Screen
1672 #endif
1673 #define IA_Screen (IA_Dummy + 0x1f) /* OS v44 includes!*/
1675 struct TagItem sdepth_tags[] =
1677 {GA_Image , 0 },
1678 {GA_Top , 0 },
1679 #if SQUARE_WIN_GADGETS
1680 {GA_Width , SDEPTH_HEIGHT },
1681 #endif
1682 {GA_Height , SDEPTH_HEIGHT },
1683 {GA_SysGadget , TRUE },
1684 {GA_SysGType , GTYP_SDEPTH },
1685 {GA_RelVerify , TRUE },
1686 {TAG_DONE }
1689 Object *im = 0;
1691 if (!(screen->Screen.Flags & SCREENQUIET))
1693 im = CreateStdSysImage(SDEPTHIMAGE, SDEPTH_HEIGHT, &screen->Screen, (APTR) ((struct IntScreen *)screen)->DecorUserBuffer,
1694 (struct DrawInfo *)&screen->DInfo, IntuitionBase);
1697 sdepth_tags[0].ti_Data = (IPTR)im;
1699 screen->depthgadget = NewObjectA(NULL, BUTTONGCLASS, sdepth_tags );
1701 DEBUG_OPENSCREEN(dprintf("OpenScreen: DepthGadget 0x%lx\n",
1702 screen->depthgadget));
1704 screen->Screen.FirstGadget = (struct Gadget *)screen->depthgadget;
1705 if (screen->Screen.FirstGadget)
1707 struct IntDrawInfo *dri = &screen->DInfo;
1708 struct sdpLayoutScreenGadgets msg;
1710 screen->Screen.FirstGadget->GadgetType |= GTYP_SCRGADGET;
1712 msg.MethodID = SDM_LAYOUT_SCREENGADGETS;
1713 msg.sdp_TrueColor = screen->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR;
1714 msg.sdp_Layer = screen->Screen.BarLayer;
1715 msg.sdp_Gadgets = screen->Screen.FirstGadget;
1716 msg.sdp_Flags = SDF_LSG_INITIAL | SDF_LSG_MULTIPLE;
1717 msg.sdp_UserBuffer = ((struct IntScreen *)screen)->DecorUserBuffer;
1719 DoMethodA(((struct IntScreen *)(screen))->ScrDecorObj, (Msg)&msg);
1721 #if 0
1722 struct TagItem gadtags[] =
1724 {GA_RelRight, 0 },
1725 {TAG_DONE }
1727 IPTR width;
1729 GetAttr(GA_Width, screen->depthgadget, &width);
1731 gadtags[0].ti_Data = -width + 1;
1732 SetAttrsA(screen->depthgadget, gadtags);
1733 #endif
1736 else
1738 if (im) DisposeObject(im);
1743 #if 1
1745 int i;
1747 for (i = 0;i <= screen->DInfo.dri.dri_NumPens; i++)
1749 DEBUG_OPENSCREEN(dprintf("OpenScreen: dri_Pen[%ld] = %ld\n",i,screen->DInfo.dri.dri_Pens[i]));
1752 #endif
1754 #ifdef USEWINDOWLOCK
1755 /* let's wait for user to finish window drag/size actions to avoid
1756 deadlocks and not break user's input */
1757 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1758 windowlock = TRUE;
1759 #endif
1761 #ifdef SKINS
1762 int_CalcSkinInfo(&screen->Screen,IntuitionBase);
1763 int_InitTitlebarBuffer(screen,IntuitionBase);
1764 #endif
1766 D(bug("callling SetRast()\n"));
1768 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set background color Pen %ld\n",screen->Pens[BACKGROUNDPEN]));
1769 /* Set screen to background color */
1770 SetRast(&screen->Screen.RastPort, screen->Pens[BACKGROUNDPEN]);
1772 D(bug("SetRast() called\n"));
1774 DEBUG_OPENSCREEN(dprintf("OpenScreen: Creating screen bar\n"));
1776 #ifdef SKINS
1777 if (workbench)
1779 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_NOWBTITLEBAR) screen->SpecialFlags |= SF_InvisibleBar;
1780 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_DISAPPEARINGTITLEBAR) screen->SpecialFlags |= SF_AppearingBar;
1782 #endif
1784 //jDc: ALL screens MUST have BarLayer!
1785 CreateScreenBar(&screen->Screen, IntuitionBase);
1787 D(bug("[intuition] OpenScreen: ScreenBar = %p\n", screen->Screen.BarLayer));
1789 if (!screen->Screen.BarLayer) ok = FALSE;
1792 ** jDc: better modify the screen list in sync with inputhandler, this for example allows us to scan the list
1793 ** without any locks when we are on input.device context
1795 if (ok)
1797 struct OpenScreenActionMsg msg;
1798 struct List *list = LockPubScreenList();
1800 msg.Screen = screen;
1801 msg.NewScreen = &ns;
1802 msg.List = list;
1804 DEBUG_OPENSCREEN(dprintf("OpenScreen: Calling DoSyncAction()\n"));
1806 DoSyncAction((APTR)int_openscreen,&msg.msg,IntuitionBase);
1808 DEBUG_OPENSCREEN(dprintf("OpenScreen: DoSyncAction returned\n"));
1810 UnlockPubScreenList();
1813 } /* if (ok) */
1815 if (ok)
1817 GetAttr(POINTERA_SharedPointer, GetPrivIBase(IntuitionBase)->DefaultPointer, (IPTR *)&screen->Pointer);
1818 ObtainSharedPointer(screen->Pointer, IntuitionBase);
1819 DEBUG_OPENSCREEN(dprintf("OpenScreen: Sprite DefaultPtr 0x%lx\n",&screen->Pointer));
1822 #ifdef __MORPHOS__
1823 if (ok)
1825 ok = MakeScreen(&screen->Screen) == 0;
1826 DEBUG_OPENSCREEN(dprintf("OpenScreen: MakeScreen %s\n", ok ? "ok" : "failed"));
1829 if (ok)
1831 ok = RethinkDisplay() == 0;
1832 DEBUG_OPENSCREEN(dprintf("OpenScreen: RethinkDisplay %s\n", ok ? "ok" : "failed"));
1834 #endif
1836 #ifdef SKINS
1837 if (ok)
1839 FireMenuMessage(MMCODE_STARTCLOCK,NULL,NULL,IntuitionBase);
1841 #endif
1843 #ifdef USEWINDOWLOCK
1844 if (windowlock) ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1845 #endif
1847 if (!ok)
1849 #ifndef __MORPHOS__
1850 if (frontbm_set)
1852 if (NULL != old_front_bm)
1853 SetFrontBitMap(old_front_bm, FALSE);
1855 #endif
1857 if (li_inited)
1859 DEBUG_OPENSCREEN(dprintf("OpenScreen: Get ThinLayerInfo\n"));
1860 ThinLayerInfo(&screen->Screen.LayerInfo);
1863 if (screen->Screen.ViewPort.ColorMap)
1865 #ifdef __MORPHOS__
1866 struct TagItem tags[2];
1868 tags[0].ti_Tag = VTAG_ATTACH_CM_GET;
1869 tags[0].ti_Data = 0;
1870 tags[1].ti_Tag = VTAG_END_CM;
1872 if (VideoControl(screen->Screen.ViewPort.ColorMap, tags) == 0 &&
1873 tags[0].ti_Data)
1875 GfxFree((APTR)tags[0].ti_Data);
1877 #endif
1879 FreeColorMap(screen->Screen.ViewPort.ColorMap);
1882 if (screen->Screen.BarLayer)
1884 DEBUG_OPENSCREEN(dprintf("OpenScreen: KillScreenBar\n"));
1885 KillScreenBar(&screen->Screen, IntuitionBase);
1888 #ifdef SKINS
1889 DisposeObject(screen->DInfo.dri_Customize->submenu);
1890 DisposeObject(screen->DInfo.dri_Customize->menutoggle);
1891 if (screen->DInfo.dri_Customize) FreeMem(screen->DInfo.dri_Customize,sizeof (struct IntuitionCustomize));
1892 if (screen->DInfo.dri_Colors) FreeMem(screen->DInfo.dri_Colors,4 * DRIPEN_NUMDRIPENS);
1893 #endif
1894 if (screen->DInfo.dri.dri_AmigaKey)
1896 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose AmigaKey Object\n"));
1897 DisposeObject(screen->DInfo.dri.dri_AmigaKey);
1899 if (screen->DInfo.dri.dri_CheckMark)
1901 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose CheckMark Object\n"));
1902 DisposeObject(screen->DInfo.dri.dri_CheckMark);
1905 if (screen->DInfo.dri.dri_SubMenuImage)
1907 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose SubMenuImage Object\n"));
1908 DisposeObject(screen->DInfo.dri.dri_SubMenuImage);
1911 if (screen->DInfo.dri.dri_Font)
1913 DEBUG_OPENSCREEN(dprintf("OpenScreen: Close Font\n"));
1914 CloseFont(screen->DInfo.dri.dri_Font);
1917 if (screen->AllocatedBitmap && !(ns.Type & CUSTOMBITMAP))
1919 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free BitMap\n"));
1920 FreeBitMap(screen->AllocatedBitmap);
1923 if (screen->Screen.ViewPort.RasInfo)
1925 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free RasInfo\n"));
1926 FreeMem(screen->Screen.ViewPort.RasInfo, sizeof (struct RasInfo));
1929 if (rp_inited)
1931 DEBUG_OPENSCREEN(dprintf("OpenScreen: Trash Rastport\n"));
1932 DeinitRastPort(&screen->Screen.RastPort);
1935 if (screen->DecorUserBuffer)
1937 FreeMem((void *)screen->DecorUserBuffer, screen->DecorUserBufferSize);
1940 if (screen->Decorator) screen->Decorator->nd_cnt--;
1942 if (screen->ID) FreeVec(screen->ID);
1944 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free Screen\n"));
1945 FreeMem (screen, sizeof (struct IntScreen));
1947 screen = 0;
1949 } /* if (!ok) */
1951 DEBUG_OPENSCREEN(dprintf("OpenScreen: return 0x%lx\n", screen));
1953 FireScreenNotifyMessage((IPTR) screen, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
1955 ReturnPtr ("OpenScreen", struct Screen *, (struct Screen *)screen);
1957 AROS_LIBFUNC_EXIT
1959 } /* OpenScreen */
1961 static VOID int_openscreen(struct OpenScreenActionMsg *msg,
1962 struct IntuitionBase *IntuitionBase)
1964 ULONG lock;
1965 struct IntScreen *screen = msg->Screen;
1966 struct NewScreen *ns = msg->NewScreen;
1967 struct List *list = msg->List;
1969 DEBUG_OPENSCREEN(dprintf("OpenScreen: Checking for pubScrNode (0x%lx)\n",screen->pubScrNode));
1971 /* If this is a public screen, we link it into the intuition global
1972 public screen list */
1973 if (screen->pubScrNode != NULL)
1975 /* Set the pointer to ourselves */
1976 GetPrivScreen(screen)->pubScrNode->psn_Screen = &screen->Screen;
1978 DEBUG_OPENSCREEN(dprintf("OpenScreen: Add Screen to PubList\n"));
1979 AddTail(list, (struct Node *)GetPrivScreen(screen)->pubScrNode);
1982 lock = LockIBase((ULONG)NULL);
1983 if (ns->Type & SCREENBEHIND)
1985 struct Screen **ptr = &IntuitionBase->FirstScreen;
1987 DEBUG_OPENSCREEN(dprintf("OpenScreen: Sort Behind\n"));
1988 if (!*ptr)
1989 IntuitionBase->ActiveScreen = &screen->Screen;
1990 while (*ptr)
1991 ptr = &(*ptr)->NextScreen;
1992 *ptr = &screen->Screen;
1994 else
1996 screen->Screen.NextScreen = IntuitionBase->FirstScreen;
1997 IntuitionBase->FirstScreen =
1998 IntuitionBase->ActiveScreen = &screen->Screen;
1999 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set as ActiveScreen\n"));
2002 /* set the default pub screen */
2003 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_DEFPUBSCREEN)
2005 if ((IntuitionBase->FirstScreen == &screen->Screen) && screen->pubScrNode && (screen->Screen.Flags & (PUBLICSCREEN | WBENCHSCREEN)))
2007 GetPrivIBase(IntuitionBase)->DefaultPubScreen = &screen->Screen;
2011 UnlockIBase(lock);
2013 D(bug("set active screen\n"));
2015 AddResourceToList(screen, RESOURCE_SCREEN, IntuitionBase);