some fixes to accented characters
[tangerine.git] / rom / intuition / openscreen.c
blob9939934af23af95919dde5e87e8e636c8c436d1f
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 ASSERT_VALID_PTR_ROMOK(newScreen);
148 #define COPY(x) screen->Screen.x = ns.x
149 #define SetError(x) if (errorPtr != NULL) *errorPtr = x;
151 D(bug("OpenScreen (%p = { Left=%d Top=%d Width=%d Height=%d Depth=%d })\n"
152 , newScreen
153 , newScreen->LeftEdge
154 , newScreen->TopEdge
155 , newScreen->Width
156 , newScreen->Height
157 , newScreen->Depth
160 #ifndef __MORPHOS__
161 if (IntuitionBase->FirstScreen)
162 old_front_bm = IntuitionBase->FirstScreen->RastPort.BitMap;
163 #endif
165 FireScreenNotifyMessage((IPTR) newScreen, SNOTIFY_BEFORE_OPENSCREEN, IntuitionBase);
167 ns = *newScreen;
169 if (newScreen->Type & NS_EXTENDED)
171 tagList = ((struct ExtNewScreen *)newScreen)->Extension;
173 else
175 tagList = NULL;
178 DEBUG_OPENSCREEN(dprintf("OpenScreen: Left %d Top %d Width %d Height %d Depth %d Tags 0x%lx\n",
179 ns.LeftEdge, ns.TopEdge, ns.Width, ns.Height, ns.Depth, tagList));
181 #ifdef __MORPHOS__
182 if (!CyberGfxBase) CyberGfxBase = OpenLibrary("cybergraphics.library",0);
183 if (!CyberGfxBase) return NULL;
185 if (!LocaleBase) LocaleBase = OpenLibrary("locale.library",0);
186 if (!LocaleBase) return NULL;
187 #endif
189 #ifdef USEGETIPREFS //needs INTUITION_THEME_ENCHANCEMENT!
190 if (!GetPrivIBase(IntuitionBase)->IPrefsLoaded && FindPort(SKINMANAGERPORTNAME))
192 /* let's init prefs before 1st OpenScreen that needs them*/
193 int_SkinAction(SKA_GetIPrefs,0,0,IntuitionBase);
195 #endif
197 screen = AllocMem(sizeof (struct IntScreen), MEMF_ANY | MEMF_CLEAR);
199 DEBUG_OPENSCREEN(dprintf("OpenScreen: screen 0x%lx\n", screen));
201 /* Do this really early to be able to report errors */
202 errorPtr = (ULONG *)GetTagData((Tag)SA_ErrorCode, (ULONG)NULL, (struct TagItem *)tagList);
204 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ErrorCode 0x%lx\n",errorPtr));
206 if (screen == NULL)
208 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
209 SetError(OSERR_NOMEM);
210 return NULL;
213 if (tagList)
215 if (GetTagData(SA_LikeWorkbench, FALSE, tagList))
218 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_LikeWorkbench\n"));
220 ns.Width = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Width;
221 ns.Height = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Height;
222 ns.Depth = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Depth;
223 modeid = GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_DisplayID;
225 if (GetPrivIBase(IntuitionBase)->ScreenModePrefs.smp_Control & SMF_AUTOSCROLL)
227 /* need to mark autoscroll */
228 ns.Type |= AUTOSCROLL;
230 sysfont = 1;
231 sharepens = TRUE; /* not sure */
234 while((tag = NextTagItem ((const struct TagItem **)&tagList)))
236 #if 1
237 DEBUG_OPENSCREEN(dprintf("OpenScreen: Tag 0x%08lx Data 0x%08lx\n",
238 tag->ti_Tag, tag->ti_Data));
239 #endif
240 switch(tag->ti_Tag)
242 case SA_Left:
243 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Left %ld\n",tag->ti_Data));
244 ns.LeftEdge = tag->ti_Data;
245 break;
247 case SA_Top:
248 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Top %ld\n",tag->ti_Data));
249 ns.TopEdge = tag->ti_Data;
250 break;
252 case SA_Width:
253 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Width %ld\n",tag->ti_Data));
254 ns.Width = tag->ti_Data;
255 break;
257 case SA_Height:
258 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Height %ld\n",tag->ti_Data));
259 ns.Height = tag->ti_Data;
260 break;
262 case SA_Depth:
263 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Depth %ld\n",tag->ti_Data));
264 ns.Depth = tag->ti_Data;
265 break;
267 case SA_DetailPen:
268 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DetailPen %ld\n",tag->ti_Data));
269 ns.DetailPen = tag->ti_Data;
270 break;
272 case SA_BlockPen:
273 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BlockPen %ld\n",tag->ti_Data));
274 ns.BlockPen = tag->ti_Data;
275 break;
277 case SA_Type:
278 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Type 0x%lx\n",tag->ti_Data));
279 ns.Type &= ~SCREENTYPE;
280 ns.Type |= tag->ti_Data;
281 break;
283 case SA_Title:
284 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Title <%s>\n",tag->ti_Data));
285 ns.DefaultTitle = (UBYTE *)tag->ti_Data;
286 break;
288 case SA_ID:
289 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ID <%s>\n",tag->ti_Data));
290 screen->ID = (STRPTR) StrDup(tag->ti_Data);
291 break;
293 case SA_Font:
294 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Font 0x%lx\n",tag->ti_Data));
295 ns.Font = (struct TextAttr *)tag->ti_Data;
296 break;
298 case SA_Colors32:
299 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors32 0x%lx\n",tag->ti_Data));
300 colors32 = (ULONG *)tag->ti_Data;
301 break;
303 case SA_Colors:
304 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors 0x%lx\n",tag->ti_Data));
305 colors = (struct ColorSpec *)tag->ti_Data;
306 break;
308 case SA_SysFont:
309 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SysFont 0x%lx\n",tag->ti_Data));
310 sysfont = (WORD)tag->ti_Data;
311 break;
313 case SA_BitMap:
314 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap 0x%lx\n",tag->ti_Data));
315 if(tag->ti_Data)
317 ns.Type |= CUSTOMBITMAP;
318 ns.CustomBitMap = (struct BitMap *)tag->ti_Data;
320 else
322 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap==NULL specified, custom bitmap use disabled\n"));
324 break;
326 /* Name of this public screen. */
327 case SA_PubName:
328 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubName <%s>\n",tag->ti_Data));
329 if (!tag->ti_Data)
331 screen->pubScrNode = AllocMem(sizeof(struct PubScreenNode), MEMF_CLEAR);
332 break;
334 else
336 struct Screen *old;
338 LockPubScreenList();
340 if (strcmp((char *)tag->ti_Data, "Workbench") == 0)
342 #warning This would still not be safe, if a normal app tried to open its own screen with SA_PubName=Workbench
343 if (GetPrivIBase(IntuitionBase)->WorkBench)
345 UnlockPubScreenList();
347 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
349 return NULL;
351 workbench = TRUE;
353 else
355 old = LockPubScreen((STRPTR)tag->ti_Data);
357 if (old != NULL)
359 UnlockPubScreen(NULL, old);
360 SetError(OSERR_PUBNOTUNIQUE);
361 UnlockPubScreenList();
362 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
364 return NULL;
368 UnlockPubScreenList();
371 screen->pubScrNode = AllocMem(sizeof(struct PubScreenNode), MEMF_CLEAR);
373 DEBUG_OPENSCREEN(dprintf("OpenScreen: pubScrNode 0x%lx\n",screen->pubScrNode));
375 if (screen->pubScrNode == NULL)
377 SetError(OSERR_NOMEM);
378 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
380 return NULL;
383 if ((ns.Type & SCREENTYPE) == CUSTOMSCREEN)
385 ns.Type &= ~SCREENTYPE;
386 ns.Type |= PUBLICSCREEN;
389 screen->pubScrNode->psn_Node.ln_Name = AllocVec(MAXPUBSCREENNAME + 1,
390 MEMF_ANY);
392 if (screen->pubScrNode->psn_Node.ln_Name == NULL)
394 SetError(OSERR_NOMEM);
395 FreeMem(screen->pubScrNode, sizeof(struct PubScreenNode));
396 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
398 return NULL;
401 /* Always open public screens in private mode. */
402 screen->pubScrNode->psn_Flags |= PSNF_PRIVATE;
403 strcpy(screen->pubScrNode->psn_Node.ln_Name, (STRPTR)tag->ti_Data);
404 break;
406 /* Signal bit number to use when signalling public screen
407 signal task. */
408 case SA_PubSig:
409 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubSig 0x%lx\n",tag->ti_Data));
410 if (screen->pubScrNode == NULL)
412 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
414 return NULL;
416 /* If no PubTask is set, we set the calling task as default */
417 if (screen->pubScrNode->psn_SigTask == NULL)
418 screen->pubScrNode->psn_SigTask = FindTask(NULL);
420 screen->pubScrNode->psn_SigBit = (UBYTE)tag->ti_Data;
421 break;
423 /* Task that should be signalled when the public screen loses
424 its last visitor window. */
425 case SA_PubTask:
426 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubTask 0x%lx\n",tag->ti_Data));
427 if (screen->pubScrNode == NULL)
429 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
430 return NULL;
432 screen->pubScrNode->psn_SigTask = (struct Task *)tag->ti_Data;
433 break;
435 case SA_BackFill:
436 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackFill Hook 0x%lx\n",tag->ti_Data));
437 layer_info_hook = (struct Hook *)tag->ti_Data;
438 break;
440 case SA_Quiet:
441 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Quiet 0x%lx\n",tag->ti_Data));
442 if (tag->ti_Data)
444 ns.Type |= SCREENQUIET;
446 else
448 ns.Type &= ~SCREENQUIET;
450 break;
452 case SA_ShowTitle:
453 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ShowTitle 0x%lx\n",tag->ti_Data));
454 if (tag->ti_Data)
456 ns.Type |= SHOWTITLE;
458 else
460 ns.Type &= ~SHOWTITLE;
462 break;
464 case SA_Pens:
465 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Pens 0x%lx\n",tag->ti_Data));
466 customdripens = (UWORD *)tag->ti_Data;
467 break;
469 case SA_DisplayID:
470 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DisplayID 0x%lx\n",tag->ti_Data));
471 //if (modeid == INVALID_ID)
472 modeid = tag->ti_Data;
473 break;
475 case SA_SharePens:
476 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SharePens 0x%lx\n",tag->ti_Data));
477 sharepens = tag->ti_Data ? TRUE : FALSE;
478 if (tag->ti_Data)
480 ns.Type |= PENSHARED;
482 else
484 ns.Type &= ~PENSHARED;
486 break;
488 case SA_Interleaved:
489 #ifdef __MORPHOS__
490 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Interleaved 0x%lx\n",tag->ti_Data));
491 if (tag->ti_Data)
493 allocbitmapflags |= BMF_INTERLEAVED;
495 else
497 allocbitmapflags &= ~BMF_INTERLEAVED;
499 #endif
500 break;
502 case SA_Behind:
503 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Behind 0x%lx\n",tag->ti_Data));
504 if (tag->ti_Data)
506 ns.Type |= SCREENBEHIND;
508 else
510 ns.Type &= ~SCREENBEHIND;
512 break;
514 case SA_DClip:
515 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DClip 0x%lx\n",tag->ti_Data));
516 dclip = (struct Rectangle *)tag->ti_Data;
517 break;
519 case SA_Overscan:
520 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_OverScan 0x%lx\n",tag->ti_Data));
521 overscan = tag->ti_Data;
522 break;
524 case SA_LikeWorkbench:
525 case SA_ErrorCode:
527 * handled elsewhere
529 break;
531 case SA_AutoScroll:
532 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_AutoScroll 0x%lx\n",tag->ti_Data));
533 ns.Type |= AUTOSCROLL;
534 break;
536 case SA_FullPalette:
537 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FullPalette 0x%lx\n",tag->ti_Data));
538 break;
540 case SA_ColorMapEntries:
541 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ColorMapEntries 0x%lx\n",tag->ti_Data));
542 break;
544 case SA_Parent:
545 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Parent 0x%lx\n",tag->ti_Data));
546 break;
548 case SA_Draggable:
549 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Draggable 0x%lx\n",tag->ti_Data));
550 break;
552 case SA_Exclusive:
553 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Exclusive 0x%lx\n",tag->ti_Data));
554 break;
556 case SA_VideoControl:
557 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_VideoControl 0x%lx\n",tag->ti_Data));
558 break;
560 case SA_FrontChild:
561 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FrontChild 0x%lx\n",tag->ti_Data));
562 break;
564 case SA_BackChild:
565 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackChild 0x%lx\n",tag->ti_Data));
566 break;
568 case SA_MinimizeISG:
569 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_MinimizeISG 0x%lx\n",tag->ti_Data));
570 break;
572 #warning TODO: Missing SA_ Tags
573 default:
574 DEBUG_OPENSCREEN(dprintf("OpenScreen: unknown tag 0x%lx data 0x%lx\n",
575 tag->ti_Tag,
576 tag->ti_Data));
577 break;
579 } /* switch (tag->ti_Tag) */
581 } /* while ((tag = NextTagItem (&tagList))) */
583 } /* if (tagList) */
585 DEBUG_OPENSCREEN(dprintf("OpenScreen: Left %d Top %d Width %d Height %d Depth %d Tags 0x%lx\n",
586 ns.LeftEdge, ns.TopEdge, ns.Width, ns.Height, ns.Depth, tagList));
588 /* First Init the RastPort then get the BitPlanes!! */
590 modetags[0].ti_Data = ns.Depth;
591 if (ns.Width != STDSCREENWIDTH)
593 modetags[1].ti_Data = ns.Width;
595 else
597 modetags[1].ti_Tag = TAG_IGNORE;
600 if (ns.Height != STDSCREENHEIGHT)
602 modetags[2].ti_Data = ns.Height;
604 else
606 modetags[2].ti_Tag = TAG_IGNORE;
609 #ifdef __MORPHOS__
610 // if default HIRES_KEY or HIRESLACE_KEY is passed, make sure we find a replacement
611 // cybergraphx mode
613 if (INVALID_ID != modeid)
615 if (FindDisplayInfo(modeid) == NULL)
617 switch(modeid)
619 case HIRES_KEY:
620 case HIRESLACE_KEY:
622 struct TagItem bestmodetags[] =
624 { CYBRBIDTG_Depth , 0UL },
625 { CYBRBIDTG_NominalWidth , 0UL },
626 { CYBRBIDTG_NominalHeight , 0UL },
627 { TAG_DONE }
630 bestmodetags[0].ti_Data = 8;
631 bestmodetags[1].ti_Data = ns.Width;
632 bestmodetags[2].ti_Data = ns.Height;
634 DEBUG_OPENSCREEN(dprintf("resetting native mode id !!\n");)
635 DEBUG_OPENSCREEN(dprintf("ns.Width %ld ns.Height %ld ns.Depth %ld !!\n",
636 (LONG) ns.Width, (LONG) ns.Height, (LONG) ns.Depth);)
639 modeid = BestCModeIDTagList(bestmodetags);
641 DEBUG_OPENSCREEN(dprintf("BestCModeIDTagList returned %ld\n",modeid);)
643 break;
645 default:
646 break;
651 #endif
653 if (INVALID_ID == modeid)
655 modeid = BestModeIDA(modetags);
656 if (INVALID_ID == modeid)
658 DEBUG_OPENSCREEN(dprintf("!!! OpenScreen(): Could not find valid modeid !!!\n");)
659 FireScreenNotifyMessage((IPTR) NULL, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
661 return NULL;
665 DEBUG_OPENSCREEN(dprintf("OpenScreen: ModeID 0x%08lx\n", modeid));
667 #ifdef __MORPHOS__
669 InitRastPort(&screen->Screen.RastPort);
670 rp_inited = TRUE;
671 success = FALSE;
672 numcolors = 0;
674 if ((displayinfo = FindDisplayInfo(modeid)) != NULL &&
675 GetDisplayInfoData(displayinfo, &dimensions, sizeof(dimensions), DTAG_DIMS, modeid) &&
676 GetDisplayInfoData(displayinfo, &monitor, sizeof(monitor), DTAG_MNTR, modeid))
678 success = TRUE;
680 screen->Monitor = monitor.Mspc;
682 if (dclip == NULL)
684 switch (overscan)
686 case OSCAN_STANDARD:
687 dclip = &dimensions.StdOScan;
688 break;
690 case OSCAN_MAX:
691 dclip = &dimensions.MaxOScan;
692 break;
694 case OSCAN_VIDEO:
695 dclip = &dimensions.VideoOScan;
696 break;
698 default:
699 dclip = &dimensions.TxtOScan;
700 break;
704 if (ns.Width == STDSCREENWIDTH)
705 ns.Width = dclip->MaxX - dclip->MinX + 1;
707 if (ns.Height == STDSCREENHEIGHT)
708 ns.Height = dclip->MaxY - dclip->MinY + 1;
710 DEBUG_OPENSCREEN(dprintf("OpenScreen: Monitor 0x%lx Width %ld Height %ld\n",
711 screen->Monitor, ns.Width, ns.Height));
713 if (ns.Type & CUSTOMBITMAP)
715 struct BitMap *custombm;
717 custombm = ns.CustomBitMap;
719 if (IsCyberModeID(modeid) && custombm)
721 int pixfmt = GetCyberIDAttr(CYBRIDATTR_PIXFMT,modeid);
723 if(GetCyberMapAttr(custombm,CYBRMATTR_PIXFMT) != pixfmt)
725 // incompatible formats !
726 custombm = NULL;
730 if(custombm != NULL)
732 screen->Screen.RastPort.BitMap = custombm;
733 ns.Depth = GetBitMapAttr(ns.CustomBitMap,BMA_DEPTH);
734 DEBUG_OPENSCREEN(dprintf("OpenScreen: CustomBitmap Depth %ld\n",
735 ns.Depth));
737 else
739 ns.CustomBitMap = NULL;
740 ns.Type &= ~CUSTOMBITMAP;
743 else
745 screen->Screen.RastPort.BitMap = NULL;
749 if(screen->Screen.RastPort.BitMap == NULL)
751 ULONG pixfmt;
752 ULONG Depth;
754 Depth = (dimensions.MaxDepth > 8) ? dimensions.MaxDepth : ns.Depth;
756 switch(Depth)
758 case 15:
759 pixfmt = PIXFMT_RGB15;
760 break;
761 case 16:
762 pixfmt = PIXFMT_RGB16;
763 break;
764 case 24:
765 pixfmt = PIXFMT_BGR24;
766 break;
767 case 32:
768 pixfmt = PIXFMT_ARGB32;
769 break;
770 default:
771 pixfmt = PIXFMT_LUT8;
772 break;
775 if (IsCyberModeID(modeid))
777 pixfmt = GetCyberIDAttr(CYBRIDATTR_PIXFMT,modeid);
781 allocbitmapflags |= (BMF_SPECIALFMT|BMF_CLEAR);
783 screen->Screen.RastPort.BitMap = AllocBitMap(ns.Width,
784 ns.Height,
785 Depth,
786 allocbitmapflags | (pixfmt << 24),
787 NULL);
789 screen->AllocatedBitmap = screen->Screen.RastPort.BitMap;
791 memcpy(&screen->Screen.BitMap,screen->Screen.RastPort.BitMap,sizeof(struct BitMap));
794 DEBUG_OPENSCREEN(dprintf("OpenScreen: BitMap 0x%lx\n",
795 screen->Screen.RastPort.BitMap));
797 else
799 DEBUG_OPENSCREEN(dprintf("OpenScreen: no displayinfo\n"));
801 #else
802 if ((displayinfo = FindDisplayInfo(modeid)) != NULL &&
803 GetDisplayInfoData(displayinfo, (UBYTE *)&dimensions, sizeof(dimensions), DTAG_DIMS, modeid) &&
804 GetDisplayInfoData(displayinfo, (UBYTE *)&monitor, sizeof(monitor), DTAG_MNTR, modeid))
806 screen->Monitor = monitor.Mspc;
808 if (dclip == NULL)
810 switch (overscan)
812 case OSCAN_STANDARD:
813 dclip = &dimensions.StdOScan;
814 break;
816 case OSCAN_MAX:
817 dclip = &dimensions.MaxOScan;
818 break;
820 case OSCAN_VIDEO:
821 dclip = &dimensions.VideoOScan;
822 break;
824 default:
825 dclip = &dimensions.TxtOScan;
826 break;
830 if (ns.Width == STDSCREENWIDTH)
831 ns.Width = dclip->MaxX - dclip->MinX + 1;
833 if (ns.Height == STDSCREENHEIGHT)
834 ns.Height = dclip->MaxY - dclip->MinY + 1;
838 if ((success = InitRastPort (&screen->Screen.RastPort)))
840 rp_inited = TRUE;
843 screen->Screen.RastPort.BitMap = screen->AllocatedBitmap = AllocScreenBitMap(modeid);
845 #endif
846 D(bug("got bitmap\n"));
848 /* Init screen's viewport */
849 InitVPort(&screen->Screen.ViewPort);
851 /* Allocate a RasInfo struct in which we have a pointer
852 to the struct BitMap, into which the driver can
853 store its stuff. (Eg. pointer to a BitMap HIDD object)
855 screen->Screen.ViewPort.RasInfo = AllocMem(sizeof(struct RasInfo), MEMF_ANY | MEMF_CLEAR);
857 DEBUG_OPENSCREEN(dprintf("OpenScreen: RasInfo 0x%lx\n",
858 screen->Screen.ViewPort.RasInfo));
860 if (!success ||
861 (screen->Screen.RastPort.BitMap == NULL) ||
862 (screen->Screen.ViewPort.RasInfo == NULL))
864 ok = FALSE;
866 else
868 /* Store pointer to bitmap, so we can get hold of it
869 from withing LoadRGBxx() functions
871 D(bug("got allocated stuff\n"));
872 screen->Screen.ViewPort.RasInfo->BitMap = screen->Screen.RastPort.BitMap;
876 if (ok)
878 /* Read depth from the bitmap to avoid AttachPalExtra/ObtainPen getting
879 * confused if cgx decided to allocate a higher depth bitmap than what
880 * was asked.
882 ns.Depth = GetBitMapAttr(screen->Screen.RastPort.BitMap,BMA_DEPTH);
884 numcolors = (ns.Depth <= 8) ? (1L << ns.Depth) : 256;
886 /* Get a color map structure. Sufficient colors?? */
888 DEBUG_OPENSCREEN(dprintf("OpenScreen: Colormap Entries %ld\n",
889 numcolors));
891 if ((screen->Screen.ViewPort.ColorMap = GetColorMap(numcolors < 32 ? 32 : numcolors)) != NULL)
894 #ifndef __MORPHOS__ /* Use VideoControl for MorphOS */
895 screen->Screen.ViewPort.ColorMap->VPModeID = modeid;
896 #endif
898 if (0 == AttachPalExtra(screen->Screen.ViewPort.ColorMap,
899 &screen->Screen.ViewPort))
901 #if 0
902 int i = 0;
903 char *alloclist;
904 UWORD *refcnt;
906 refcnt =(UWORD*) screen->Screen.ViewPort.ColorMap->PalExtra->pe_RefCnt;
907 alloclist = (UBYTE *)(refcnt + screen->Screen.ViewPort.ColorMap->Count);
909 DEBUG_OPENSCREEN(dprintf("OpenScreen: PalExtra alloclist 0x%lx Count %ld\n",alloclist,screen->Screen.ViewPort.ColorMap->Count));
911 while(i < screen->Screen.ViewPort.ColorMap->Count)
913 // initialize alloc list to -1,0,1,2,3,4
915 DEBUG_OPENSCREEN(dprintf("OpenScreen: alloclist[%ld]=%ld\n",
916 i,alloclist[i]));
917 i++;
919 #endif
921 else
923 ok = FALSE;
926 else
928 ok = FALSE;
931 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx\n",
932 screen->Screen.ViewPort.ColorMap));
935 #ifdef __MORPHOS__
937 screen->ModeID = modeid;
939 if (ok)
941 struct ViewPortExtra *vpe = GfxNew(VIEWPORT_EXTRA_TYPE);
943 DEBUG_OPENSCREEN(dprintf("OpenScreen: ViewPortExtra 0x%lx\n", vpe));
945 ok = FALSE;
947 if (vpe)
949 struct TagItem tags[6];
951 memcpy(&vpe->DisplayClip, dclip,sizeof(struct Rectangle));
953 screen->Screen.ViewPort.DWidth = dclip->MaxX - dclip->MinX + 1;//ns.Width; /* or from dclip ? */
954 screen->Screen.ViewPort.DHeight = dclip->MaxY - dclip->MinY + 1;//ns.Height;
956 tags[0].ti_Tag = VTAG_ATTACH_CM_SET;
957 tags[0].ti_Data = (IPTR)&screen->Screen.ViewPort;
958 tags[1].ti_Tag = VTAG_VIEWPORTEXTRA_SET;
959 tags[1].ti_Data = (IPTR)vpe;
960 tags[2].ti_Tag = VTAG_NORMAL_DISP_SET;
961 tags[2].ti_Data = (IPTR)displayinfo;
962 tags[3].ti_Tag = VTAG_VPMODEID_SET;
963 tags[3].ti_Data = modeid;
964 tags[4].ti_Tag = VTAG_END_CM;
965 tags[5].ti_Tag = TAG_END;
967 if (VideoControl(screen->Screen.ViewPort.ColorMap, tags) == 0)
969 DEBUG_OPENSCREEN(dprintf("OpenScreen: VideoControl ok\n"));
970 ok = TRUE;
972 else
974 DEBUG_OPENSCREEN(dprintf("OpenScreen: VideoControl failed\n"));
978 // added 2002-03-10, pre iprefs openscreen has all first 4 colours black (cyfm)
979 // removed 2002-26-12, I now set the pens on start (zapek)
980 #if 0
981 if ((p = GetPrivIBase(IntuitionBase)->Colors))
983 int Sum;
985 DEBUG_OPENSCREEN(dprintf("OpenScreen: Intuition Color32 Table 0x%lx\n",p);)
987 Sum = p[0].red + p[0].green + p[0].blue;
988 Sum += p[1].red + p[1].green + p[1].blue;
989 Sum += p[2].red + p[2].green + p[2].blue;
990 Sum += p[3].red + p[3].green + p[3].blue;
991 if (Sum==0)
993 int i;
995 DEBUG_OPENSCREEN(dprintf("OpenScreen: All 4 first colours black, reset !!\n");)
997 for (i = 0; i < COLORTABLEENTRIES; i++)
999 DEBUG_OPENSCREEN(dprintf("OpenScreen: Current Color32[%ld] R 0x%lx G 0x%lx B 0x%lx\n",
1001 p[i].red, p[i].green, p[i].blue));
1003 p[0].red = 0xAAAAAAAA;
1004 p[0].green = 0xAAAAAAAA;
1005 p[0].blue = 0xAAAAAAAA;
1007 p[1].red = 0x00000000;
1008 p[1].green = 0x00000000;
1009 p[1].blue = 0x00000000;
1011 p[2].red = 0xFFFFFFFF;
1012 p[2].green = 0xFFFFFFFF;
1013 p[2].blue = 0xFFFFFFFF;
1015 p[3].red = 0x55555555;
1016 p[3].green = 0x77777777;
1017 p[3].blue = 0xAAAAAAAA;
1021 #endif
1024 #endif
1026 if (ok)
1028 struct Color32 *p;
1029 int k, c;
1030 UWORD *q;
1032 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set first 4 colors\n"));
1034 p = GetPrivIBase(IntuitionBase)->Colors;
1035 for (k = 0; k < 4 && k < numcolors; ++k)
1037 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB32 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1038 screen->Screen.ViewPort,
1039 k, p[k].red, p[k].green, p[k].blue));
1040 SetRGB32(&screen->Screen.ViewPort, k, p[k].red, p[k].green, p[k].blue);
1043 if (ns.Depth >= 3)
1045 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set last 4 colors\n"));
1047 #warning Isn`t that only set for FullPalette ?
1048 for (k = 0; k < 4; ++k)
1050 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB32 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1051 screen->Screen.ViewPort,
1052 numcolors - k - 1, p[k+4].red, p[k+4].green, p[k+4].blue));
1054 ObtainPen(screen->Screen.ViewPort.ColorMap,
1055 numcolors - 4 + k,
1056 p[k+4].red,
1057 p[k+4].green,
1058 p[k+4].blue,
1063 DEBUG_OPENSCREEN(dprintf("OpenScreen: Obtain Mousepointer colors\n"));
1065 /* Allocate pens for the mouse pointer */
1066 q = &GetPrivIBase(IntuitionBase)->ActivePreferences->color17;
1067 if (numcolors < 20)
1068 /* FIXME: this assumes that we have at least 16 colors */
1069 c = numcolors - 7;
1070 else
1071 c = 17;
1072 for (k = 0; k < 3; ++k, ++q)
1074 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx Pen %ld R 0x%lx G 0x%lx B 0x%lx\n",
1075 screen->Screen.ViewPort.ColorMap,
1076 k + c,
1077 (*q >> 8) * 0x11111111,
1078 ((*q >> 4) & 0xf) * 0x11111111,
1079 (*q & 0xf) * 0x11111111));
1080 ObtainPen(screen->Screen.ViewPort.ColorMap,
1081 k + c,
1082 (*q >> 8) * 0x11111111,
1083 ((*q >> 4) & 0xf) * 0x11111111,
1084 (*q & 0xf) * 0x11111111,
1086 /* The following piece is left for reference only. It came from
1087 classic Amiga where mouse pointer was implemented as a hardware
1088 sprite. It always uses DAC registers 17 - 19, even for screens
1089 with small depth.
1090 In future we probably need some other mechanism for setting
1091 pointer palette, probably separate HIDD methods.
1092 if (k + 17 < numcolors)
1094 ObtainPen(screen->Screen.ViewPort.ColorMap,
1095 k + 17,
1096 (*q >> 8) * 0x11111111,
1097 ((*q >> 4) & 0xf) * 0x11111111,
1098 (*q & 0xf) * 0x11111111,
1099 PEN_EXCLUSIVE);
1101 else
1103 ** Can't be allocated, but can still be set. **
1104 SetRGB32(&screen->Screen.ViewPort,
1105 k + 17,
1106 (*q >> 8) * 0x11111111,
1107 ((*q >> 4) & 0xf) * 0x11111111,
1108 (*q & 0xf) * 0x11111111);
1112 if (colors) /* if SA_Colors tag exists */
1114 DEBUG_OPENSCREEN(dprintf("OpenScreen: set SA_Colors 0x%lx\n",colors));
1115 for(; colors->ColorIndex != (WORD)~0; colors++)
1117 DEBUG_OPENSCREEN(dprintf("OpenScreen: SetRGB4 Viewport 0x%lx Index %ld R 0x%lx G 0x%lx B 0x%lx\n",
1118 screen->Screen.ViewPort,
1119 colors,
1120 colors->Red,
1121 colors->Green,
1122 colors->Blue));
1123 SetRGB4(&screen->Screen.ViewPort,
1124 colors->ColorIndex,
1125 colors->Red,
1126 colors->Green,
1127 colors->Blue);
1131 if (colors32) /* if SA_Colors32 tag exists */
1133 DEBUG_OPENSCREEN(dprintf("OpenScreen: LoadRGB32 colors32 0x%lx\n",colors32));
1134 LoadRGB32(&screen->Screen.ViewPort, (const ULONG *)colors32);
1137 D(bug("Loaded colors\n"));
1139 COPY(LeftEdge);
1140 COPY(TopEdge);
1141 COPY(Width);
1142 COPY(Height);
1143 COPY(DetailPen);
1144 COPY(BlockPen);
1145 COPY(Font);
1146 COPY(DefaultTitle);
1148 //intui68k filters this
1149 screen->Screen.Flags = (ns.Type & ~NS_EXTENDED);
1151 /* Temporary hack */
1152 if (ns.Width >= 500 || ns.Height >= 300)
1153 screen->Screen.Flags |= SCREENHIRES;
1155 #ifndef __MORPHOS__
1156 /* Mark the bitmap of the screen as an AROS-displayed BitMap */
1157 screen->Screen.RastPort.BitMap->Flags |= BMF_AROS_HIDD;
1158 #endif
1161 Copy the data from the rastport's bitmap
1162 to the screen's bitmap structure
1164 screen->Screen.BitMap = *screen->Screen.RastPort.BitMap;
1166 #ifdef __MORPHOS__
1167 screen->Screen.WBorTop = 2;
1168 screen->Screen.WBorLeft = 4;
1169 screen->Screen.WBorRight = 4;
1170 screen->Screen.WBorBottom = 2;
1171 #else
1172 screen->Screen.WBorTop = 3; /* Amiga default is 2 */
1173 screen->Screen.WBorLeft = 4;
1174 screen->Screen.WBorRight = 4;
1175 screen->Screen.WBorBottom = 2; /* Amiga default is 2 */
1176 #endif
1178 screen->Screen.Title = ns.DefaultTitle;
1180 if (screen->ID == NULL) if (screen->Screen.Title) screen->ID = StrDup(screen->Screen.Title);
1182 DEBUG_OPENSCREEN(dprintf("OpenScreen: init layers\n"));
1183 InitLayers(&screen->Screen.LayerInfo);
1184 li_inited = TRUE;
1186 #if 0
1187 /* Root layer now installed automatically by first call
1188 to CreateLayerTagList */
1190 #ifdef CreateLayerTagList
1192 struct TagItem tags[4] =
1194 {LA_Visible , FALSE },
1195 {LA_Priority, ROOTPRIORITY },
1196 {TAG_DONE }
1199 screen->rootLayer =
1200 CreateLayerTagList(&screen->Screen.LayerInfo,
1201 screen->Screen.RastPort.BitMap,
1202 screen->Screen.LeftEdge,
1203 screen->Screen.TopEdge,
1204 screen->Screen.LeftEdge + screen->Screen.Width - 1,
1205 screen->Screen.TopEdge + screen->Screen.Height - 1,
1207 tags);
1209 DEBUG_OPENSCREEN(dprintf("OpenScreen: rootLayer 0x%lx\n",screen->rootLayer));
1211 #endif
1212 #endif
1214 if (NULL != layer_info_hook)
1216 DEBUG_OPENSCREEN(dprintf("OpenScreen: instal layerinfohook\n"));
1217 InstallLayerInfoHook(&screen->Screen.LayerInfo, layer_info_hook);
1219 D(bug("layers intited screen\n"));
1221 screen->DInfo.dri.dri_Version = DRI_VERSION;
1222 screen->DInfo.dri.dri_NumPens = NUMDRIPENS;
1223 screen->DInfo.dri.dri_Pens = screen->Pens;
1224 /* dri_Depth is 8 on hi/true color screens like in AmigaOS with picasso96/cybergraphx */
1225 screen->DInfo.dri.dri_Depth = (ns.Depth <= 8) ? ns.Depth : 8;
1226 #warning These are probably monitor dependent
1227 screen->DInfo.dri.dri_Resolution.X = 44;
1228 screen->DInfo.dri.dri_Resolution.Y = 44;
1230 if (ns.Depth > 8) screen->DInfo.dri.dri_Flags = DRIF_DIRECTCOLOR;
1232 screen->DInfo.dri_Screen = &screen->Screen;
1234 /* SA_SysFont overrides SA_Font! */
1236 DEBUG_OPENSCREEN(dprintf("OpenScreen: SysFont = %d, ns.Font = %p\n", sysfont, ns.Font));
1238 if (sysfont == 0)
1240 /* Is handled below */
1241 DEBUG_OPENSCREEN(dprintf("OpenScreen: skip SysFont for now\n"));
1243 else if (sysfont == 1)
1245 #if 1
1246 /* Use safe OpenFont here - Piru
1248 screen->DInfo.dri.dri_Font = SafeReopenFont(IntuitionBase, &GetPrivIBase(IntuitionBase)->ScreenFont);
1249 #else
1251 #warning: Really hacky way of re-opening ScreenFont
1253 Forbid();
1254 screen->DInfo.dri.dri_Font = GetPrivIBase(IntuitionBase)->ScreenFont;
1255 screen->DInfo.dri.dri_Font->tf_Accessors++;
1256 Permit();
1257 #endif
1259 screen->SpecialFlags |= SF_SysFont;
1261 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set ScreenFont\n"));
1264 else if (ns.Font)
1266 screen->DInfo.dri.dri_Font = OpenFont(ns.Font);
1267 DEBUG_OPENSCREEN(dprintf("OpenScreen: custom font 0x%lx\n",screen->DInfo.dri.dri_Font));
1270 if (!screen->DInfo.dri.dri_Font)
1272 /* GfxBase->DefaultFont is *not* always topaz 8. It
1273 can be set with the Font prefs program!! */
1275 #if 1
1276 /* Use safe OpenFont.. - Piru
1278 screen->DInfo.dri.dri_Font = SafeReopenFont(IntuitionBase, &GfxBase->DefaultFont);
1279 #else
1281 #warning: Really hacky way of re-opening system default font
1283 Forbid();
1284 screen->DInfo.dri.dri_Font = GfxBase->DefaultFont;
1285 screen->DInfo.dri.dri_Font->tf_Accessors++;
1286 Permit();
1287 #endif
1290 if (!screen->DInfo.dri.dri_Font) ok = FALSE;
1292 } /* if (ok) */
1294 if (ok)
1296 /* set default values for pens */
1297 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set Default Pens\n"));
1299 CopyMem(ns.Depth == 1 ? GetPrivIBase(IntuitionBase)->DriPens2
1300 : ns.Depth == 4 ? GetPrivIBase(IntuitionBase)->DriPens4
1301 : GetPrivIBase(IntuitionBase)->DriPens8,
1302 screen->Pens,
1303 sizeof(screen->Pens));
1305 if (ns.Depth > 1)
1307 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set NewLook\n"));
1308 screen->DInfo.dri.dri_Flags |= DRIF_NEWLOOK;
1312 if (customdripens)
1314 WORD i;
1316 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set Custom Pens\n"));
1318 screen->Pens[DETAILPEN] = screen->Screen.DetailPen;
1319 screen->Pens[BLOCKPEN] = screen->Screen.BlockPen;
1321 for(i = 0; (i < NUMDRIPENS) && (customdripens[i] != (UWORD)~0); i++)
1323 DEBUG_OPENSCREEN(dprintf("OpenScreen: Pen[%ld] %ld\n",i,screen->Pens[i]));
1324 screen->Pens[i] = customdripens[i];
1327 else
1330 * Let`s do some broken software validation of the pens
1331 * so we may not run into a black desktop.
1334 DEBUG_OPENSCREEN(dprintf("OpenScreen: Check Default Pens if the make sense\n"));
1335 if (screen->Screen.DetailPen == screen->Screen.BlockPen)
1337 DEBUG_OPENSCREEN(dprintf("OpenScreen: DetailPen==BlockPen..correct\n"));
1338 screen->Screen.DetailPen = 0;
1339 screen->Screen.BlockPen = 1;
1341 else
1342 if (screen->Screen.BlockPen == 0)
1344 DEBUG_OPENSCREEN(dprintf("OpenScreen: BlockPen==0..correct\n"));
1345 screen->Screen.BlockPen = screen->Screen.DetailPen;
1346 screen->Screen.DetailPen = 0;
1349 screen->Pens[DETAILPEN] = screen->Screen.DetailPen;
1350 screen->Pens[BLOCKPEN] = screen->Screen.BlockPen;
1353 /* Allocate shared/exclusive colors */
1356 BYTE color_alloced[256];
1358 WORD i;
1360 for(i = 0; i < 256; i++)
1362 color_alloced[i] = FALSE;
1365 /* Mouse pointer colors */
1367 color_alloced[17] = TRUE;
1368 color_alloced[18] = TRUE;
1369 color_alloced[19] = TRUE;
1371 /* The Pens in the DrawInfo must be allocated as shared */
1373 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen DrawInfo Pens as shared\n"));
1375 for(i = 0; i < NUMDRIPENS; i++)
1377 int pen = screen->Pens[i];
1379 if (!color_alloced[pen])
1381 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen ColorMap 0x%lx Pen %ld\n",
1382 screen->Screen.ViewPort.ColorMap,
1383 pen));
1385 ObtainPen(screen->Screen.ViewPort.ColorMap,
1386 pen,
1390 PENF_NO_SETCOLOR);
1391 color_alloced[pen] = TRUE;
1394 DEBUG_OPENSCREEN(dprintf("OpenScreen: done\n"));
1396 /* If SA_SharePens is FALSE then allocate the rest of the colors
1397 in the colormap as exclusive */
1399 if (!sharepens)
1401 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen the remaining Pens as exclusive\n"));
1403 for(i = 0; i < numcolors; i++)
1405 if (!color_alloced[i])
1407 DEBUG_OPENSCREEN(dprintf("OpenScreen: ObtainPen ColorMap 0x%lx Pen %ld\n",
1408 screen->Screen.ViewPort.ColorMap,
1409 i));
1410 ObtainPen(screen->Screen.ViewPort.ColorMap,
1415 PENF_EXCLUSIVE | PENF_NO_SETCOLOR);
1419 } /* if (!sharepens) */
1424 #ifndef __MORPHOS__
1425 if (ok)
1427 if (!SetFrontBitMap(screen->Screen.RastPort.BitMap, TRUE))
1428 ok = FALSE;
1429 else
1430 frontbm_set = TRUE;
1432 #endif
1434 #ifdef SKINS
1435 if (ok)
1437 ULONG realdepth;
1439 screen->DInfo.dri_Screen = &screen->Screen; //useful sometimes ;)
1441 realdepth = GetBitMapAttr( screen->Screen.RastPort.BitMap, BMA_DEPTH );
1442 if (realdepth > 8)
1444 screen->DInfo.dri_Flags |= DRIF_DIRECTCOLOR;
1446 else
1448 screen->DInfo.dri_Flags &= ~DRIF_DIRECTCOLOR;
1451 if (!(screen->DInfo.dri_Colors = AllocMem(4 * DRIPEN_NUMDRIPENS,MEMF_PUBLIC)))
1452 ok = FALSE;
1454 if (ok)
1456 CopyMem(&defaultdricolors,screen->DInfo.dri_Colors,sizeof (defaultdricolors));
1457 memset(((UBYTE *) screen->DInfo.dri_Colors) + sizeof(defaultdricolors), 0, 4 * DRIPEN_NUMDRIPENS - sizeof(defaultdricolors));
1460 if (ok)
1462 if ((screen->DInfo.dri_Customize = AllocMem(sizeof (struct IntuitionCustomize),MEMF_PUBLIC|MEMF_CLEAR)))
1464 struct IntuitionCustomize *ic;
1465 ic = screen->DInfo.dri_Customize;
1466 screen->DInfo.dri_Flags |= DRIF_SKINSSUPPORT;
1467 /* This initializes CustomizePrefs structure */
1469 int_SkinAction(SKA_LoadSkin,(ULONG*)&screen->DInfo,(struct Screen *)screen,IntuitionBase);
1471 else
1473 ok = FALSE;
1478 if (ok)
1480 struct windowclassprefs *wcprefs;
1482 wcprefs = (struct windowclassprefs *)int_GetCustomPrefs(TYPE_WINDOWCLASS,&screen->DInfo,IntuitionBase);
1483 if (wcprefs->flags & WINDOWCLASS_PREFS_1TO1FRAMES)
1485 screen->Screen.WBorLeft = screen->Screen.WBorTop;
1486 screen->Screen.WBorRight = screen->Screen.WBorTop;
1487 screen->Screen.WBorBottom = screen->Screen.WBorTop;
1489 #ifdef TITLEHACK
1490 screen->Screen.WBorTop += wcprefs->titlebarincrement;
1491 #endif
1492 int_FreeCustomPrefs(TYPE_WINDOWCLASS,&screen->DInfo,IntuitionBase);
1495 #endif
1497 if (ok)
1499 IPTR userbuffersize;
1501 struct NewDecorator *nd;
1503 nd = ((struct IntIntuitionBase *)(IntuitionBase))->Decorator;
1505 ObtainSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
1507 struct DosLibrary *DOSBase;
1509 DOSBase = OpenLibrary("dos.library", 40);
1510 if (DOSBase)
1512 struct Node *node;
1513 if (!IsListEmpty(&GetPrivIBase(IntuitionBase)->Decorations))
1515 node = GetPrivIBase(IntuitionBase)->Decorations.lh_Head;
1516 for (; node->ln_Succ; node = node->ln_Succ)
1518 struct NewDecorator *d = (struct NewDecorator *) node;
1519 if ((d->nd_IntPattern != NULL) && (screen->ID != NULL)) if (MatchPattern(d->nd_IntPattern, screen->ID)) nd = d;
1523 CloseLibrary((struct Library *) DOSBase);
1526 // if (MatchPattern(tl->parsename, task->tc_Node.ln_Name)) b = tl;
1528 if (nd != NULL)
1530 screen->ScrDecorObj = nd->nd_Screen;
1531 screen->WinDecorObj = nd->nd_Window;
1532 screen->MenuDecorObj = nd->nd_Menu;
1534 else
1536 screen->ScrDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorObj;
1537 screen->WinDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorObj;
1538 screen->MenuDecorObj = ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorObj;
1540 screen->Decorator = nd;
1542 if (screen->Decorator) screen->Decorator->nd_cnt++;
1544 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
1546 GetAttr(SDA_UserBuffer, screen->ScrDecorObj, &userbuffersize);
1548 if (userbuffersize)
1550 screen->DecorUserBufferSize = userbuffersize;
1551 screen->DecorUserBuffer = (IPTR) AllocMem(userbuffersize, MEMF_ANY | MEMF_CLEAR);
1552 if (!screen->DecorUserBuffer) ok = FALSE;
1556 if (ok)
1558 struct TagItem sysi_tags[] =
1560 {SYSIA_Which , MENUCHECK },
1561 {SYSIA_DrawInfo , (IPTR)&screen->DInfo },
1562 {SYSIA_UserBuffer, screen->DecorUserBuffer },
1564 {TAG_DONE }
1567 screen->DInfo.dri.dri_CheckMark = NewObjectA(NULL, "sysiclass", sysi_tags);
1568 DEBUG_OPENSCREEN(dprintf("OpenScreen: CheckMark 0x%lx\n",
1569 screen->DInfo.dri.dri_CheckMark));
1571 sysi_tags[0].ti_Data = AMIGAKEY;
1573 screen->DInfo.dri.dri_AmigaKey = NewObjectA(NULL, "sysiclass", sysi_tags);
1574 DEBUG_OPENSCREEN(dprintf("OpenScreen: AmigaKey 0x%lx\n",
1575 screen->DInfo.dri.dri_AmigaKey));
1577 sysi_tags[0].ti_Data = SUBMENUIMAGE;
1579 screen->DInfo.dri.dri_SubMenuImage = NewObjectA(NULL, "sysiclass", sysi_tags);
1580 DEBUG_OPENSCREEN(dprintf("OpenScreen: SubMenuImage 0x%lx\n",
1581 screen->DInfo.dri.dri_SubMenuImage));
1583 #ifdef SKINS
1584 sysi_tags[0].ti_Data = SUBMENUIMAGE;
1585 screen->DInfo.dri_Customize->submenu = NewObjectA(NULL, "sysiclass", sysi_tags);
1586 sysi_tags[0].ti_Data = MENUTOGGLEIMAGE;
1587 screen->DInfo.dri_Customize->menutoggle = NewObjectA(NULL, "sysiclass", sysi_tags);
1588 if (!screen->DInfo.dri_Customize->submenu ||
1589 !screen->DInfo.dri_Customize->menutoggle) ok = FALSE;
1590 #endif
1592 if (!screen->DInfo.dri.dri_CheckMark || !screen->DInfo.dri.dri_AmigaKey || !screen->DInfo.dri.dri_SubMenuImage) ok = FALSE;
1597 if (ok)
1599 SetFont(&screen->Screen.RastPort, screen->DInfo.dri.dri_Font);
1601 AskFont(&screen->Screen.RastPort, (struct TextAttr *) &screen->textattr);
1603 screen->Screen.Font = (struct TextAttr *) &screen->textattr;
1605 DEBUG_OPENSCREEN(dprintf("OpenScreen: Font %s/%d\n",
1606 screen->textattr.tta_Name, screen->textattr.tta_YSize));
1608 #ifdef __MORPHOS__
1609 screen->Screen.BarVBorder = 1;
1610 screen->Screen.BarHBorder = 5;
1611 screen->Screen.MenuVBorder = 2;
1612 screen->Screen.MenuHBorder = 4;
1613 #else
1614 screen->Screen.BarVBorder = 1; /* on the Amiga it is (usually?) 1 */
1615 screen->Screen.BarHBorder = 5;
1616 screen->Screen.MenuVBorder = 2; /* on the Amiga it is (usually?) 2 */
1617 screen->Screen.MenuHBorder = 4;
1618 #endif
1620 struct IntDrawInfo *dri = &screen->DInfo;
1621 struct sdpInitScreen msg;
1623 msg.MethodID = SDM_INITSCREEN;
1624 msg.sdp_Screen = &screen->Screen;
1625 msg.sdp_TrueColor = screen->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR;
1626 msg.sdp_FontHeight = screen->DInfo.dri.dri_Font->tf_YSize;
1627 msg.sdp_BarVBorder = screen->Screen.BarVBorder;
1628 msg.sdp_BarHBorder = screen->Screen.BarHBorder;
1629 msg.sdp_MenuVBorder = screen->Screen.MenuVBorder;
1630 msg.spd_MenuHBorder = screen->Screen.MenuHBorder;
1631 msg.sdp_WBorTop = screen->Screen.WBorTop;
1632 msg.sdp_WBorLeft = screen->Screen.WBorLeft;
1633 msg.sdp_WBorRight = screen->Screen.WBorRight;
1634 msg.sdp_WBorBottom = screen->Screen.WBorBottom;
1636 #ifdef TITLEHACK
1637 msg.sdp_TitleHack = screen->Screen.WBorTop-2;
1638 #else
1639 msg.sdp_TitleHack = 0;
1640 #endif
1642 msg.sdp_BarHeight = msg.sdp_FontHeight + msg.sdp_BarVBorder * 2 + msg.sdp_TitleHack;
1643 msg.sdp_UserBuffer = ((struct IntScreen *)screen)->DecorUserBuffer;
1645 if (!DoMethodA(((struct IntScreen *)(screen))->ScrDecorObj, (Msg)&msg)) ok = FALSE;
1646 if (ok)
1648 screen->Screen.BarHeight = msg.sdp_BarHeight;
1649 screen->Screen.BarVBorder = msg.sdp_BarVBorder;
1650 screen->Screen.BarHBorder = msg.sdp_BarHBorder;
1651 screen->Screen.MenuVBorder = msg.sdp_MenuVBorder;
1652 screen->Screen.MenuHBorder = msg.spd_MenuHBorder;
1653 screen->Screen.WBorTop = msg.sdp_WBorTop;
1654 screen->Screen.WBorLeft = msg.sdp_WBorLeft;
1655 screen->Screen.WBorRight = msg.sdp_WBorRight;
1656 screen->Screen.WBorBottom = msg.sdp_WBorBottom;
1661 if (ok)
1665 #define SDEPTH_HEIGHT (screen->Screen.BarHeight + 1)
1666 #ifdef IA_Screen
1667 #undef IA_Screen
1668 #endif
1669 #define IA_Screen (IA_Dummy + 0x1f) /* OS v44 includes!*/
1671 struct TagItem sdepth_tags[] =
1673 {GA_Image , 0 },
1674 {GA_Top , 0 },
1675 #if SQUARE_WIN_GADGETS
1676 {GA_Width , SDEPTH_HEIGHT },
1677 #endif
1678 {GA_Height , SDEPTH_HEIGHT },
1679 {GA_SysGadget , TRUE },
1680 {GA_SysGType , GTYP_SDEPTH },
1681 {GA_RelVerify , TRUE },
1682 {TAG_DONE }
1685 Object *im = 0;
1687 if (!(screen->Screen.Flags & SCREENQUIET))
1689 im = CreateStdSysImage(SDEPTHIMAGE, SDEPTH_HEIGHT, &screen->Screen, (APTR) ((struct IntScreen *)screen)->DecorUserBuffer,
1690 (struct DrawInfo *)&screen->DInfo, IntuitionBase);
1693 sdepth_tags[0].ti_Data = (IPTR)im;
1695 screen->depthgadget = NewObjectA(NULL, BUTTONGCLASS, sdepth_tags );
1697 DEBUG_OPENSCREEN(dprintf("OpenScreen: DepthGadget 0x%lx\n",
1698 screen->depthgadget));
1700 screen->Screen.FirstGadget = (struct Gadget *)screen->depthgadget;
1701 if (screen->Screen.FirstGadget)
1703 struct IntDrawInfo *dri = &screen->DInfo;
1704 struct sdpLayoutScreenGadgets msg;
1706 screen->Screen.FirstGadget->GadgetType |= GTYP_SCRGADGET;
1708 msg.MethodID = SDM_LAYOUT_SCREENGADGETS;
1709 msg.sdp_TrueColor = screen->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR;
1710 msg.sdp_Layer = screen->Screen.BarLayer;
1711 msg.sdp_Gadgets = screen->Screen.FirstGadget;
1712 msg.sdp_Flags = SDF_LSG_INITIAL | SDF_LSG_MULTIPLE;
1713 msg.sdp_UserBuffer = ((struct IntScreen *)screen)->DecorUserBuffer;
1715 DoMethodA(((struct IntScreen *)(screen))->ScrDecorObj, (Msg)&msg);
1717 #if 0
1718 struct TagItem gadtags[] =
1720 {GA_RelRight, 0 },
1721 {TAG_DONE }
1723 IPTR width;
1725 GetAttr(GA_Width, screen->depthgadget, &width);
1727 gadtags[0].ti_Data = -width + 1;
1728 SetAttrsA(screen->depthgadget, gadtags);
1729 #endif
1732 else
1734 if (im) DisposeObject(im);
1739 #if 1
1741 int i;
1743 for (i = 0;i <= screen->DInfo.dri.dri_NumPens; i++)
1745 DEBUG_OPENSCREEN(dprintf("OpenScreen: dri_Pen[%ld] = %ld\n",i,screen->DInfo.dri.dri_Pens[i]));
1748 #endif
1750 #ifdef USEWINDOWLOCK
1751 /* let's wait for user to finish window drag/size actions to avoid
1752 deadlocks and not break user's input */
1753 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1754 windowlock = TRUE;
1755 #endif
1757 #ifdef SKINS
1758 int_CalcSkinInfo(&screen->Screen,IntuitionBase);
1759 int_InitTitlebarBuffer(screen,IntuitionBase);
1760 #endif
1762 D(bug("callling SetRast()\n"));
1764 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set background color Pen %ld\n",screen->Pens[BACKGROUNDPEN]));
1765 /* Set screen to background color */
1766 SetRast(&screen->Screen.RastPort, screen->Pens[BACKGROUNDPEN]);
1768 D(bug("SetRast() called\n"));
1770 DEBUG_OPENSCREEN(dprintf("OpenScreen: Creating screen bar\n"));
1772 #ifdef SKINS
1773 if (workbench)
1775 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_NOWBTITLEBAR) screen->SpecialFlags |= SF_InvisibleBar;
1776 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_DISAPPEARINGTITLEBAR) screen->SpecialFlags |= SF_AppearingBar;
1778 #endif
1780 //jDc: ALL screens MUST have BarLayer!
1781 CreateScreenBar(&screen->Screen, IntuitionBase);
1783 D(bug("[intuition] OpenScreen: ScreenBar = %p\n", screen->Screen.BarLayer));
1785 if (!screen->Screen.BarLayer) ok = FALSE;
1788 ** jDc: better modify the screen list in sync with inputhandler, this for example allows us to scan the list
1789 ** without any locks when we are on input.device context
1791 if (ok)
1793 struct OpenScreenActionMsg msg;
1794 struct List *list = LockPubScreenList();
1796 msg.Screen = screen;
1797 msg.NewScreen = &ns;
1798 msg.List = list;
1800 DEBUG_OPENSCREEN(dprintf("OpenScreen: Calling DoSyncAction()\n"));
1802 DoSyncAction((APTR)int_openscreen,&msg.msg,IntuitionBase);
1804 DEBUG_OPENSCREEN(dprintf("OpenScreen: DoSyncAction returned\n"));
1806 UnlockPubScreenList();
1809 } /* if (ok) */
1811 if (ok)
1813 GetAttr(POINTERA_SharedPointer, GetPrivIBase(IntuitionBase)->DefaultPointer, (IPTR *)&screen->Pointer);
1814 ObtainSharedPointer(screen->Pointer, IntuitionBase);
1815 DEBUG_OPENSCREEN(dprintf("OpenScreen: Sprite DefaultPtr 0x%lx\n",&screen->Pointer));
1818 #ifdef __MORPHOS__
1819 if (ok)
1821 ok = MakeScreen(&screen->Screen) == 0;
1822 DEBUG_OPENSCREEN(dprintf("OpenScreen: MakeScreen %s\n", ok ? "ok" : "failed"));
1825 if (ok)
1827 ok = RethinkDisplay() == 0;
1828 DEBUG_OPENSCREEN(dprintf("OpenScreen: RethinkDisplay %s\n", ok ? "ok" : "failed"));
1830 #endif
1832 #ifdef SKINS
1833 if (ok)
1835 FireMenuMessage(MMCODE_STARTCLOCK,NULL,NULL,IntuitionBase);
1837 #endif
1839 #ifdef USEWINDOWLOCK
1840 if (windowlock) ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->WindowLock);
1841 #endif
1843 if (!ok)
1845 #ifndef __MORPHOS__
1846 if (frontbm_set)
1848 if (NULL != old_front_bm)
1849 SetFrontBitMap(old_front_bm, FALSE);
1851 #endif
1853 if (li_inited)
1855 DEBUG_OPENSCREEN(dprintf("OpenScreen: Get ThinLayerInfo\n"));
1856 ThinLayerInfo(&screen->Screen.LayerInfo);
1859 if (screen->Screen.ViewPort.ColorMap)
1861 #ifdef __MORPHOS__
1862 struct TagItem tags[2];
1864 tags[0].ti_Tag = VTAG_ATTACH_CM_GET;
1865 tags[0].ti_Data = 0;
1866 tags[1].ti_Tag = VTAG_END_CM;
1868 if (VideoControl(screen->Screen.ViewPort.ColorMap, tags) == 0 &&
1869 tags[0].ti_Data)
1871 GfxFree((APTR)tags[0].ti_Data);
1873 #endif
1875 FreeColorMap(screen->Screen.ViewPort.ColorMap);
1878 if (screen->Screen.BarLayer)
1880 DEBUG_OPENSCREEN(dprintf("OpenScreen: KillScreenBar\n"));
1881 KillScreenBar(&screen->Screen, IntuitionBase);
1884 #ifdef SKINS
1885 DisposeObject(screen->DInfo.dri_Customize->submenu);
1886 DisposeObject(screen->DInfo.dri_Customize->menutoggle);
1887 if (screen->DInfo.dri_Customize) FreeMem(screen->DInfo.dri_Customize,sizeof (struct IntuitionCustomize));
1888 if (screen->DInfo.dri_Colors) FreeMem(screen->DInfo.dri_Colors,4 * DRIPEN_NUMDRIPENS);
1889 #endif
1890 if (screen->DInfo.dri.dri_AmigaKey)
1892 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose AmigaKey Object\n"));
1893 DisposeObject(screen->DInfo.dri.dri_AmigaKey);
1895 if (screen->DInfo.dri.dri_CheckMark)
1897 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose CheckMark Object\n"));
1898 DisposeObject(screen->DInfo.dri.dri_CheckMark);
1901 if (screen->DInfo.dri.dri_SubMenuImage)
1903 DEBUG_OPENSCREEN(dprintf("OpenScreen: Dispose SubMenuImage Object\n"));
1904 DisposeObject(screen->DInfo.dri.dri_SubMenuImage);
1907 if (screen->DInfo.dri.dri_Font)
1909 DEBUG_OPENSCREEN(dprintf("OpenScreen: Close Font\n"));
1910 CloseFont(screen->DInfo.dri.dri_Font);
1913 if (screen->AllocatedBitmap && !(ns.Type & CUSTOMBITMAP))
1915 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free BitMap\n"));
1916 FreeBitMap(screen->AllocatedBitmap);
1919 if (screen->Screen.ViewPort.RasInfo)
1921 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free RasInfo\n"));
1922 FreeMem(screen->Screen.ViewPort.RasInfo, sizeof (struct RasInfo));
1925 if (rp_inited)
1927 DEBUG_OPENSCREEN(dprintf("OpenScreen: Trash Rastport\n"));
1928 DeinitRastPort(&screen->Screen.RastPort);
1931 if (screen->DecorUserBuffer)
1933 FreeMem((IPTR) screen->DecorUserBuffer, screen->DecorUserBufferSize);
1936 if (screen->Decorator) screen->Decorator->nd_cnt--;
1938 if (screen->ID) FreeVec(screen->ID);
1940 DEBUG_OPENSCREEN(dprintf("OpenScreen: Free Screen\n"));
1941 FreeMem (screen, sizeof (struct IntScreen));
1943 screen = 0;
1945 } /* if (!ok) */
1947 DEBUG_OPENSCREEN(dprintf("OpenScreen: return 0x%lx\n", screen));
1949 FireScreenNotifyMessage((IPTR) screen, SNOTIFY_AFTER_OPENSCREEN, IntuitionBase);
1951 ReturnPtr ("OpenScreen", struct Screen *, (struct Screen *)screen);
1953 AROS_LIBFUNC_EXIT
1955 } /* OpenScreen */
1957 static VOID int_openscreen(struct OpenScreenActionMsg *msg,
1958 struct IntuitionBase *IntuitionBase)
1960 ULONG lock;
1961 struct IntScreen *screen = msg->Screen;
1962 struct NewScreen *ns = msg->NewScreen;
1963 struct List *list = msg->List;
1965 DEBUG_OPENSCREEN(dprintf("OpenScreen: Checking for pubScrNode (0x%lx)\n",screen->pubScrNode));
1967 /* If this is a public screen, we link it into the intuition global
1968 public screen list */
1969 if (screen->pubScrNode != NULL)
1971 /* Set the pointer to ourselves */
1972 GetPrivScreen(screen)->pubScrNode->psn_Screen = &screen->Screen;
1974 DEBUG_OPENSCREEN(dprintf("OpenScreen: Add Screen to PubList\n"));
1975 AddTail(list, (struct Node *)GetPrivScreen(screen)->pubScrNode);
1978 lock = LockIBase((ULONG)NULL);
1979 if (ns->Type & SCREENBEHIND)
1981 struct Screen **ptr = &IntuitionBase->FirstScreen;
1983 DEBUG_OPENSCREEN(dprintf("OpenScreen: Sort Behind\n"));
1984 if (!*ptr)
1985 IntuitionBase->ActiveScreen = &screen->Screen;
1986 while (*ptr)
1987 ptr = &(*ptr)->NextScreen;
1988 *ptr = &screen->Screen;
1990 else
1992 screen->Screen.NextScreen = IntuitionBase->FirstScreen;
1993 IntuitionBase->FirstScreen =
1994 IntuitionBase->ActiveScreen = &screen->Screen;
1995 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set as ActiveScreen\n"));
1998 /* set the default pub screen */
1999 if (GetPrivIBase(IntuitionBase)->IControlPrefs.ic_Flags & ICF_DEFPUBSCREEN)
2001 if ((IntuitionBase->FirstScreen == &screen->Screen) && screen->pubScrNode && (screen->Screen.Flags & (PUBLICSCREEN | WBENCHSCREEN)))
2003 GetPrivIBase(IntuitionBase)->DefaultPubScreen = &screen->Screen;
2007 UnlockIBase(lock);
2009 D(bug("set active screen\n"));
2011 AddResourceToList(screen, RESOURCE_SCREEN, IntuitionBase);