2 Copyright 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
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>
30 #include <proto/cybergraphics.h>
31 #include <cybergraphx/cybergraphics.h>
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"
41 #ifndef DEBUG_OpenScreen
42 #define DEBUG_OpenScreen 0
48 #include <aros/debug.h>
50 struct OpenScreenActionMsg
52 struct IntuiActionMsg msg
;
53 struct IntScreen
*Screen
;
54 struct NewScreen
*NewScreen
;
58 static VOID
int_openscreen(struct OpenScreenActionMsg
*msg
,
59 struct IntuitionBase
*IntuitionBase
);
62 extern const ULONG defaultdricolors
[DRIPEN_NUMDRIPENS
];
64 //FIXME: NUMDRIPENS == DRIPEN_NUMDRIPENS ???
65 extern const ULONG defaultdricolors
[NUMDRIPENS
];
70 static const char THIS_FILE
[] = __FILE__
;
73 /*****************************************************************************
77 AROS_LH1(struct Screen
*, OpenScreen
,
80 AROS_LHA(struct NewScreen
*, newScreen
, A0
),
83 struct IntuitionBase
*, IntuitionBase
, 33, Intuition
)
102 29-10-95 digulla automatically created from
103 intuition_lib.fd and clib/intuition_protos.h
105 *****************************************************************************/
110 struct TagItem
*tag
, *tagList
;
111 struct IntScreen
*screen
;
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
;
119 BOOL ok
= TRUE
, rp_inited
= FALSE
, li_inited
= FALSE
, sharepens
= FALSE
;
121 BOOL windowlock
= FALSE
;
123 struct Rectangle
*dclip
= NULL
;
124 LONG overscan
= OSCAN_TEXT
;
125 DisplayInfoHandle displayinfo
;
126 struct DimensionInfo dimensions
;
127 struct MonitorInfo monitor
;
129 ULONG allocbitmapflags
= BMF_DISPLAYABLE
;
131 BOOL frontbm_set
= FALSE
;
132 struct BitMap
*old_front_bm
= NULL
;
136 BOOL workbench
= FALSE
;
137 struct TagItem modetags
[] =
139 { BIDTAG_Depth
, 0UL },
140 { BIDTAG_DesiredWidth
, 0UL },
141 { BIDTAG_DesiredHeight
, 0UL },
144 ULONG modeid
= INVALID_ID
;
146 /* Intuition not up yet? */
147 if (!GetPrivIBase(IntuitionBase
)->DefaultPointer
)
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"
157 , newScreen
->LeftEdge
165 if (IntuitionBase
->FirstScreen
)
166 old_front_bm
= IntuitionBase
->FirstScreen
->RastPort
.BitMap
;
169 FireScreenNotifyMessage((IPTR
) newScreen
, SNOTIFY_BEFORE_OPENSCREEN
, IntuitionBase
);
173 if (newScreen
->Type
& NS_EXTENDED
)
175 tagList
= ((struct ExtNewScreen
*)newScreen
)->Extension
;
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
));
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
;
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
);
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
));
212 FireScreenNotifyMessage((IPTR
) NULL
, SNOTIFY_AFTER_OPENSCREEN
, IntuitionBase
);
213 SetError(OSERR_NOMEM
);
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
;
235 sharepens
= TRUE
; /* not sure */
238 while((tag
= NextTagItem ((const struct TagItem
**)&tagList
)))
241 DEBUG_OPENSCREEN(dprintf("OpenScreen: Tag 0x%08lx Data 0x%08lx\n",
242 tag
->ti_Tag
, tag
->ti_Data
));
247 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Left %ld\n",tag
->ti_Data
));
248 ns
.LeftEdge
= tag
->ti_Data
;
252 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Top %ld\n",tag
->ti_Data
));
253 ns
.TopEdge
= tag
->ti_Data
;
257 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Width %ld\n",tag
->ti_Data
));
258 ns
.Width
= tag
->ti_Data
;
262 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Height %ld\n",tag
->ti_Data
));
263 ns
.Height
= tag
->ti_Data
;
267 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Depth %ld\n",tag
->ti_Data
));
268 ns
.Depth
= tag
->ti_Data
;
272 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DetailPen %ld\n",tag
->ti_Data
));
273 ns
.DetailPen
= tag
->ti_Data
;
277 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BlockPen %ld\n",tag
->ti_Data
));
278 ns
.BlockPen
= tag
->ti_Data
;
282 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Type 0x%lx\n",tag
->ti_Data
));
283 ns
.Type
&= ~SCREENTYPE
;
284 ns
.Type
|= tag
->ti_Data
;
288 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Title <%s>\n",tag
->ti_Data
));
289 ns
.DefaultTitle
= (UBYTE
*)tag
->ti_Data
;
293 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ID <%s>\n",tag
->ti_Data
));
294 screen
->ID
= StrDup((STRPTR
)tag
->ti_Data
);
298 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Font 0x%lx\n",tag
->ti_Data
));
299 ns
.Font
= (struct TextAttr
*)tag
->ti_Data
;
303 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors32 0x%lx\n",tag
->ti_Data
));
304 colors32
= (ULONG
*)tag
->ti_Data
;
308 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors 0x%lx\n",tag
->ti_Data
));
309 colors
= (struct ColorSpec
*)tag
->ti_Data
;
313 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SysFont 0x%lx\n",tag
->ti_Data
));
314 sysfont
= (WORD
)tag
->ti_Data
;
318 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap 0x%lx\n",tag
->ti_Data
));
321 ns
.Type
|= CUSTOMBITMAP
;
322 ns
.CustomBitMap
= (struct BitMap
*)tag
->ti_Data
;
326 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap==NULL specified, custom bitmap use disabled\n"));
330 /* Name of this public screen. */
332 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubName <%s>\n",tag
->ti_Data
));
335 screen
->pubScrNode
= AllocMem(sizeof(struct PubScreenNode
), MEMF_CLEAR
);
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
);
359 old
= LockPubScreen((STRPTR
)tag
->ti_Data
);
363 UnlockPubScreen(NULL
, old
);
364 SetError(OSERR_PUBNOTUNIQUE
);
365 UnlockPubScreenList();
366 FireScreenNotifyMessage((IPTR
) NULL
, SNOTIFY_AFTER_OPENSCREEN
, IntuitionBase
);
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
);
387 if ((ns
.Type
& SCREENTYPE
) == CUSTOMSCREEN
)
389 ns
.Type
&= ~SCREENTYPE
;
390 ns
.Type
|= PUBLICSCREEN
;
393 screen
->pubScrNode
->psn_Node
.ln_Name
= AllocVec(MAXPUBSCREENNAME
+ 1,
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
);
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
);
410 /* Signal bit number to use when signalling public screen
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
);
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
;
427 /* Task that should be signalled when the public screen loses
428 its last visitor window. */
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
);
436 screen
->pubScrNode
->psn_SigTask
= (struct Task
*)tag
->ti_Data
;
440 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackFill Hook 0x%lx\n",tag
->ti_Data
));
441 layer_info_hook
= (struct Hook
*)tag
->ti_Data
;
445 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Quiet 0x%lx\n",tag
->ti_Data
));
448 ns
.Type
|= SCREENQUIET
;
452 ns
.Type
&= ~SCREENQUIET
;
457 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ShowTitle 0x%lx\n",tag
->ti_Data
));
460 ns
.Type
|= SHOWTITLE
;
464 ns
.Type
&= ~SHOWTITLE
;
469 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Pens 0x%lx\n",tag
->ti_Data
));
470 customdripens
= (UWORD
*)tag
->ti_Data
;
474 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DisplayID 0x%lx\n",tag
->ti_Data
));
475 //if (modeid == INVALID_ID)
476 modeid
= tag
->ti_Data
;
480 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SharePens 0x%lx\n",tag
->ti_Data
));
481 sharepens
= tag
->ti_Data
? TRUE
: FALSE
;
484 ns
.Type
|= PENSHARED
;
488 ns
.Type
&= ~PENSHARED
;
494 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Interleaved 0x%lx\n",tag
->ti_Data
));
497 allocbitmapflags
|= BMF_INTERLEAVED
;
501 allocbitmapflags
&= ~BMF_INTERLEAVED
;
507 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Behind 0x%lx\n",tag
->ti_Data
));
510 ns
.Type
|= SCREENBEHIND
;
514 ns
.Type
&= ~SCREENBEHIND
;
519 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DClip 0x%lx\n",tag
->ti_Data
));
520 dclip
= (struct Rectangle
*)tag
->ti_Data
;
524 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_OverScan 0x%lx\n",tag
->ti_Data
));
525 overscan
= tag
->ti_Data
;
528 case SA_LikeWorkbench
:
536 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_AutoScroll 0x%lx\n",tag
->ti_Data
));
537 ns
.Type
|= AUTOSCROLL
;
541 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FullPalette 0x%lx\n",tag
->ti_Data
));
544 case SA_ColorMapEntries
:
545 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ColorMapEntries 0x%lx\n",tag
->ti_Data
));
549 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Parent 0x%lx\n",tag
->ti_Data
));
553 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Draggable 0x%lx\n",tag
->ti_Data
));
557 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Exclusive 0x%lx\n",tag
->ti_Data
));
560 case SA_VideoControl
:
561 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_VideoControl 0x%lx\n",tag
->ti_Data
));
565 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FrontChild 0x%lx\n",tag
->ti_Data
));
569 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackChild 0x%lx\n",tag
->ti_Data
));
573 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_MinimizeISG 0x%lx\n",tag
->ti_Data
));
576 #warning TODO: Missing SA_ Tags
578 DEBUG_OPENSCREEN(dprintf("OpenScreen: unknown tag 0x%lx data 0x%lx\n",
583 } /* switch (tag->ti_Tag) */
585 } /* while ((tag = NextTagItem (&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
;
601 modetags
[1].ti_Tag
= TAG_IGNORE
;
604 if (ns
.Height
!= STDSCREENHEIGHT
)
606 modetags
[2].ti_Data
= ns
.Height
;
610 modetags
[2].ti_Tag
= TAG_IGNORE
;
614 // if default HIRES_KEY or HIRESLACE_KEY is passed, make sure we find a replacement
617 if (INVALID_ID
!= modeid
)
619 if (FindDisplayInfo(modeid
) == NULL
)
626 struct TagItem bestmodetags
[] =
628 { CYBRBIDTG_Depth
, 0UL },
629 { CYBRBIDTG_NominalWidth
, 0UL },
630 { CYBRBIDTG_NominalHeight
, 0UL },
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
);)
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
);
669 DEBUG_OPENSCREEN(dprintf("OpenScreen: ModeID 0x%08lx\n", modeid
));
673 InitRastPort(&screen
->Screen
.RastPort
);
678 if ((displayinfo
= FindDisplayInfo(modeid
)) != NULL
&&
679 GetDisplayInfoData(displayinfo
, &dimensions
, sizeof(dimensions
), DTAG_DIMS
, modeid
) &&
680 GetDisplayInfoData(displayinfo
, &monitor
, sizeof(monitor
), DTAG_MNTR
, modeid
))
684 screen
->Monitor
= monitor
.Mspc
;
691 dclip
= &dimensions
.StdOScan
;
695 dclip
= &dimensions
.MaxOScan
;
699 dclip
= &dimensions
.VideoOScan
;
703 dclip
= &dimensions
.TxtOScan
;
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 !
736 screen
->Screen
.RastPort
.BitMap
= custombm
;
737 ns
.Depth
= GetBitMapAttr(ns
.CustomBitMap
,BMA_DEPTH
);
738 DEBUG_OPENSCREEN(dprintf("OpenScreen: CustomBitmap Depth %ld\n",
743 ns
.CustomBitMap
= NULL
;
744 ns
.Type
&= ~CUSTOMBITMAP
;
749 screen
->Screen
.RastPort
.BitMap
= NULL
;
753 if(screen
->Screen
.RastPort
.BitMap
== NULL
)
758 Depth
= (dimensions
.MaxDepth
> 8) ? dimensions
.MaxDepth
: ns
.Depth
;
763 pixfmt
= PIXFMT_RGB15
;
766 pixfmt
= PIXFMT_RGB16
;
769 pixfmt
= PIXFMT_BGR24
;
772 pixfmt
= PIXFMT_ARGB32
;
775 pixfmt
= PIXFMT_LUT8
;
779 if (IsCyberModeID(modeid
))
781 pixfmt
= GetCyberIDAttr(CYBRIDATTR_PIXFMT
,modeid
);
785 allocbitmapflags
|= (BMF_SPECIALFMT
|BMF_CLEAR
);
787 screen
->Screen
.RastPort
.BitMap
= AllocBitMap(ns
.Width
,
790 allocbitmapflags
| (pixfmt
<< 24),
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
));
803 DEBUG_OPENSCREEN(dprintf("OpenScreen: no displayinfo\n"));
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
;
817 dclip
= &dimensions
.StdOScan
;
821 dclip
= &dimensions
.MaxOScan
;
825 dclip
= &dimensions
.VideoOScan
;
829 dclip
= &dimensions
.TxtOScan
;
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
)))
847 screen
->Screen
.RastPort
.BitMap
= screen
->AllocatedBitmap
= AllocScreenBitMap(modeid
);
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
));
865 (screen
->Screen
.RastPort
.BitMap
== NULL
) ||
866 (screen
->Screen
.ViewPort
.RasInfo
== NULL
))
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
;
882 /* Read depth from the bitmap to avoid AttachPalExtra/ObtainPen getting
883 * confused if cgx decided to allocate a higher depth bitmap than what
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",
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
;
902 if (0 == AttachPalExtra(screen
->Screen
.ViewPort
.ColorMap
,
903 &screen
->Screen
.ViewPort
))
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",
935 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx\n",
936 screen
->Screen
.ViewPort
.ColorMap
));
941 screen
->ModeID
= modeid
;
945 struct ViewPortExtra
*vpe
= GfxNew(VIEWPORT_EXTRA_TYPE
);
947 DEBUG_OPENSCREEN(dprintf("OpenScreen: ViewPortExtra 0x%lx\n", 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"));
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)
985 if ((p
= GetPrivIBase(IntuitionBase
)->Colors
))
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
;
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;
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
);
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
,
1067 DEBUG_OPENSCREEN(dprintf("OpenScreen: Obtain Mousepointer colors\n"));
1069 /* Allocate pens for the mouse pointer */
1070 q
= &GetPrivIBase(IntuitionBase
)->ActivePreferences
->color17
;
1072 /* FIXME: this assumes that we have at least 16 colors */
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
,
1081 (*q
>> 8) * 0x11111111,
1082 ((*q
>> 4) & 0xf) * 0x11111111,
1083 (*q
& 0xf) * 0x11111111));
1084 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
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
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,
1100 (*q >> 8) * 0x11111111,
1101 ((*q >> 4) & 0xf) * 0x11111111,
1102 (*q & 0xf) * 0x11111111,
1107 ** Can't be allocated, but can still be set. **
1108 SetRGB32(&screen->Screen.ViewPort,
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
,
1127 SetRGB4(&screen
->Screen
.ViewPort
,
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"));
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
;
1160 /* Mark the bitmap of the screen as an AROS-displayed BitMap */
1161 screen
->Screen
.RastPort
.BitMap
->Flags
|= BMF_AROS_HIDD
;
1165 Copy the data from the rastport's bitmap
1166 to the screen's bitmap structure
1168 screen
->Screen
.BitMap
= *screen
->Screen
.RastPort
.BitMap
;
1171 screen
->Screen
.WBorTop
= 2;
1172 screen
->Screen
.WBorLeft
= 4;
1173 screen
->Screen
.WBorRight
= 4;
1174 screen
->Screen
.WBorBottom
= 2;
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 */
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
);
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
},
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,
1213 DEBUG_OPENSCREEN(dprintf("OpenScreen: rootLayer 0x%lx\n",screen
->rootLayer
));
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
));
1244 /* Is handled below */
1245 DEBUG_OPENSCREEN(dprintf("OpenScreen: skip SysFont for now\n"));
1247 else if (sysfont
== 1)
1250 /* Use safe OpenFont here - Piru
1252 screen
->DInfo
.dri
.dri_Font
= SafeReopenFont(IntuitionBase
, &GetPrivIBase(IntuitionBase
)->ScreenFont
);
1255 #warning: Really hacky way of re-opening ScreenFont
1258 screen
->DInfo
.dri
.dri_Font
= GetPrivIBase(IntuitionBase
)->ScreenFont
;
1259 screen
->DInfo
.dri
.dri_Font
->tf_Accessors
++;
1263 screen
->SpecialFlags
|= SF_SysFont
;
1265 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set ScreenFont\n"));
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!! */
1280 /* Use safe OpenFont.. - Piru
1282 screen
->DInfo
.dri
.dri_Font
= SafeReopenFont(IntuitionBase
, &GfxBase
->DefaultFont
);
1285 #warning: Really hacky way of re-opening system default font
1288 screen
->DInfo
.dri
.dri_Font
= GfxBase
->DefaultFont
;
1289 screen
->DInfo
.dri
.dri_Font
->tf_Accessors
++;
1294 if (!screen
->DInfo
.dri
.dri_Font
) ok
= FALSE
;
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
,
1307 sizeof(screen
->Pens
));
1311 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set NewLook\n"));
1312 screen
->DInfo
.dri
.dri_Flags
|= DRIF_NEWLOOK
;
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
];
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;
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];
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
,
1389 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
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 */
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
,
1414 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
1419 PENF_EXCLUSIVE
| PENF_NO_SETCOLOR
);
1423 } /* if (!sharepens) */
1431 if (!SetFrontBitMap(screen
->Screen
.RastPort
.BitMap
, TRUE
))
1443 screen
->DInfo
.dri_Screen
= &screen
->Screen
; //useful sometimes ;)
1445 realdepth
= GetBitMapAttr( screen
->Screen
.RastPort
.BitMap
, BMA_DEPTH
);
1448 screen
->DInfo
.dri_Flags
|= DRIF_DIRECTCOLOR
;
1452 screen
->DInfo
.dri_Flags
&= ~DRIF_DIRECTCOLOR
;
1455 if (!(screen
->DInfo
.dri_Colors
= AllocMem(4 * DRIPEN_NUMDRIPENS
,MEMF_PUBLIC
)))
1460 CopyMem(&defaultdricolors
,screen
->DInfo
.dri_Colors
,sizeof (defaultdricolors
));
1461 memset(((UBYTE
*) screen
->DInfo
.dri_Colors
) + sizeof(defaultdricolors
), 0, 4 * DRIPEN_NUMDRIPENS
- sizeof(defaultdricolors
));
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
);
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
;
1494 screen
->Screen
.WBorTop
+= wcprefs
->titlebarincrement
;
1496 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,&screen
->DInfo
,IntuitionBase
);
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);
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;
1534 screen
->ScrDecorObj
= nd
->nd_Screen
;
1535 screen
->WinDecorObj
= nd
->nd_Window
;
1536 screen
->MenuDecorObj
= nd
->nd_Menu
;
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
);
1554 screen
->DecorUserBufferSize
= userbuffersize
;
1555 screen
->DecorUserBuffer
= (IPTR
) AllocMem(userbuffersize
, MEMF_ANY
| MEMF_CLEAR
);
1556 if (!screen
->DecorUserBuffer
) ok
= FALSE
;
1562 struct TagItem sysi_tags
[] =
1564 {SYSIA_Which
, MENUCHECK
},
1565 {SYSIA_DrawInfo
, (IPTR
)&screen
->DInfo
},
1566 {SYSIA_UserBuffer
, screen
->DecorUserBuffer
},
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
));
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
;
1596 if (!screen
->DInfo
.dri
.dri_CheckMark
|| !screen
->DInfo
.dri
.dri_AmigaKey
|| !screen
->DInfo
.dri
.dri_SubMenuImage
) ok
= FALSE
;
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
));
1613 screen
->Screen
.BarVBorder
= 1;
1614 screen
->Screen
.BarHBorder
= 5;
1615 screen
->Screen
.MenuVBorder
= 2;
1616 screen
->Screen
.MenuHBorder
= 4;
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;
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
;
1641 msg
.sdp_TitleHack
= screen
->Screen
.WBorTop
-2;
1643 msg
.sdp_TitleHack
= 0;
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
;
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
;
1669 #define SDEPTH_HEIGHT (screen->Screen.BarHeight + 1)
1673 #define IA_Screen (IA_Dummy + 0x1f) /* OS v44 includes!*/
1675 struct TagItem sdepth_tags
[] =
1679 #if SQUARE_WIN_GADGETS
1680 {GA_Width
, SDEPTH_HEIGHT
},
1682 {GA_Height
, SDEPTH_HEIGHT
},
1683 {GA_SysGadget
, TRUE
},
1684 {GA_SysGType
, GTYP_SDEPTH
},
1685 {GA_RelVerify
, TRUE
},
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
);
1722 struct TagItem gadtags
[] =
1729 GetAttr(GA_Width
, screen
->depthgadget
, &width
);
1731 gadtags
[0].ti_Data
= -width
+ 1;
1732 SetAttrsA(screen
->depthgadget
, gadtags
);
1738 if (im
) DisposeObject(im
);
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
]));
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
);
1762 int_CalcSkinInfo(&screen
->Screen
,IntuitionBase
);
1763 int_InitTitlebarBuffer(screen
,IntuitionBase
);
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"));
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
;
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
1797 struct OpenScreenActionMsg msg
;
1798 struct List
*list
= LockPubScreenList();
1800 msg
.Screen
= screen
;
1801 msg
.NewScreen
= &ns
;
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();
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
));
1825 ok
= MakeScreen(&screen
->Screen
) == 0;
1826 DEBUG_OPENSCREEN(dprintf("OpenScreen: MakeScreen %s\n", ok
? "ok" : "failed"));
1831 ok
= RethinkDisplay() == 0;
1832 DEBUG_OPENSCREEN(dprintf("OpenScreen: RethinkDisplay %s\n", ok
? "ok" : "failed"));
1839 FireMenuMessage(MMCODE_STARTCLOCK
,NULL
,NULL
,IntuitionBase
);
1843 #ifdef USEWINDOWLOCK
1844 if (windowlock
) ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
1852 if (NULL
!= old_front_bm
)
1853 SetFrontBitMap(old_front_bm
, FALSE
);
1859 DEBUG_OPENSCREEN(dprintf("OpenScreen: Get ThinLayerInfo\n"));
1860 ThinLayerInfo(&screen
->Screen
.LayerInfo
);
1863 if (screen
->Screen
.ViewPort
.ColorMap
)
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 &&
1875 GfxFree((APTR
)tags
[0].ti_Data
);
1879 FreeColorMap(screen
->Screen
.ViewPort
.ColorMap
);
1882 if (screen
->Screen
.BarLayer
)
1884 DEBUG_OPENSCREEN(dprintf("OpenScreen: KillScreenBar\n"));
1885 KillScreenBar(&screen
->Screen
, IntuitionBase
);
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
);
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
));
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
));
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
);
1961 static VOID
int_openscreen(struct OpenScreenActionMsg
*msg
,
1962 struct IntuitionBase
*IntuitionBase
)
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"));
1989 IntuitionBase
->ActiveScreen
= &screen
->Screen
;
1991 ptr
= &(*ptr
)->NextScreen
;
1992 *ptr
= &screen
->Screen
;
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
;
2013 D(bug("set active screen\n"));
2015 AddResourceToList(screen
, RESOURCE_SCREEN
, IntuitionBase
);