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 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"
153 , newScreen
->LeftEdge
161 if (IntuitionBase
->FirstScreen
)
162 old_front_bm
= IntuitionBase
->FirstScreen
->RastPort
.BitMap
;
165 FireScreenNotifyMessage((IPTR
) newScreen
, SNOTIFY_BEFORE_OPENSCREEN
, IntuitionBase
);
169 if (newScreen
->Type
& NS_EXTENDED
)
171 tagList
= ((struct ExtNewScreen
*)newScreen
)->Extension
;
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
));
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
;
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
);
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
));
208 FireScreenNotifyMessage((IPTR
) NULL
, SNOTIFY_AFTER_OPENSCREEN
, IntuitionBase
);
209 SetError(OSERR_NOMEM
);
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
;
231 sharepens
= TRUE
; /* not sure */
234 while((tag
= NextTagItem ((const struct TagItem
**)&tagList
)))
237 DEBUG_OPENSCREEN(dprintf("OpenScreen: Tag 0x%08lx Data 0x%08lx\n",
238 tag
->ti_Tag
, tag
->ti_Data
));
243 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Left %ld\n",tag
->ti_Data
));
244 ns
.LeftEdge
= tag
->ti_Data
;
248 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Top %ld\n",tag
->ti_Data
));
249 ns
.TopEdge
= tag
->ti_Data
;
253 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Width %ld\n",tag
->ti_Data
));
254 ns
.Width
= tag
->ti_Data
;
258 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Height %ld\n",tag
->ti_Data
));
259 ns
.Height
= tag
->ti_Data
;
263 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Depth %ld\n",tag
->ti_Data
));
264 ns
.Depth
= tag
->ti_Data
;
268 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DetailPen %ld\n",tag
->ti_Data
));
269 ns
.DetailPen
= tag
->ti_Data
;
273 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BlockPen %ld\n",tag
->ti_Data
));
274 ns
.BlockPen
= tag
->ti_Data
;
278 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Type 0x%lx\n",tag
->ti_Data
));
279 ns
.Type
&= ~SCREENTYPE
;
280 ns
.Type
|= tag
->ti_Data
;
284 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Title <%s>\n",tag
->ti_Data
));
285 ns
.DefaultTitle
= (UBYTE
*)tag
->ti_Data
;
289 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ID <%s>\n",tag
->ti_Data
));
290 screen
->ID
= (STRPTR
) StrDup(tag
->ti_Data
);
294 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Font 0x%lx\n",tag
->ti_Data
));
295 ns
.Font
= (struct TextAttr
*)tag
->ti_Data
;
299 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors32 0x%lx\n",tag
->ti_Data
));
300 colors32
= (ULONG
*)tag
->ti_Data
;
304 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Colors 0x%lx\n",tag
->ti_Data
));
305 colors
= (struct ColorSpec
*)tag
->ti_Data
;
309 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SysFont 0x%lx\n",tag
->ti_Data
));
310 sysfont
= (WORD
)tag
->ti_Data
;
314 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap 0x%lx\n",tag
->ti_Data
));
317 ns
.Type
|= CUSTOMBITMAP
;
318 ns
.CustomBitMap
= (struct BitMap
*)tag
->ti_Data
;
322 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BitMap==NULL specified, custom bitmap use disabled\n"));
326 /* Name of this public screen. */
328 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_PubName <%s>\n",tag
->ti_Data
));
331 screen
->pubScrNode
= AllocMem(sizeof(struct PubScreenNode
), MEMF_CLEAR
);
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
);
355 old
= LockPubScreen((STRPTR
)tag
->ti_Data
);
359 UnlockPubScreen(NULL
, old
);
360 SetError(OSERR_PUBNOTUNIQUE
);
361 UnlockPubScreenList();
362 FireScreenNotifyMessage((IPTR
) NULL
, SNOTIFY_AFTER_OPENSCREEN
, IntuitionBase
);
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
);
383 if ((ns
.Type
& SCREENTYPE
) == CUSTOMSCREEN
)
385 ns
.Type
&= ~SCREENTYPE
;
386 ns
.Type
|= PUBLICSCREEN
;
389 screen
->pubScrNode
->psn_Node
.ln_Name
= AllocVec(MAXPUBSCREENNAME
+ 1,
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
);
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
);
406 /* Signal bit number to use when signalling public screen
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
);
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
;
423 /* Task that should be signalled when the public screen loses
424 its last visitor window. */
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
);
432 screen
->pubScrNode
->psn_SigTask
= (struct Task
*)tag
->ti_Data
;
436 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackFill Hook 0x%lx\n",tag
->ti_Data
));
437 layer_info_hook
= (struct Hook
*)tag
->ti_Data
;
441 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Quiet 0x%lx\n",tag
->ti_Data
));
444 ns
.Type
|= SCREENQUIET
;
448 ns
.Type
&= ~SCREENQUIET
;
453 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ShowTitle 0x%lx\n",tag
->ti_Data
));
456 ns
.Type
|= SHOWTITLE
;
460 ns
.Type
&= ~SHOWTITLE
;
465 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Pens 0x%lx\n",tag
->ti_Data
));
466 customdripens
= (UWORD
*)tag
->ti_Data
;
470 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DisplayID 0x%lx\n",tag
->ti_Data
));
471 //if (modeid == INVALID_ID)
472 modeid
= tag
->ti_Data
;
476 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_SharePens 0x%lx\n",tag
->ti_Data
));
477 sharepens
= tag
->ti_Data
? TRUE
: FALSE
;
480 ns
.Type
|= PENSHARED
;
484 ns
.Type
&= ~PENSHARED
;
490 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Interleaved 0x%lx\n",tag
->ti_Data
));
493 allocbitmapflags
|= BMF_INTERLEAVED
;
497 allocbitmapflags
&= ~BMF_INTERLEAVED
;
503 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Behind 0x%lx\n",tag
->ti_Data
));
506 ns
.Type
|= SCREENBEHIND
;
510 ns
.Type
&= ~SCREENBEHIND
;
515 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_DClip 0x%lx\n",tag
->ti_Data
));
516 dclip
= (struct Rectangle
*)tag
->ti_Data
;
520 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_OverScan 0x%lx\n",tag
->ti_Data
));
521 overscan
= tag
->ti_Data
;
524 case SA_LikeWorkbench
:
532 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_AutoScroll 0x%lx\n",tag
->ti_Data
));
533 ns
.Type
|= AUTOSCROLL
;
537 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FullPalette 0x%lx\n",tag
->ti_Data
));
540 case SA_ColorMapEntries
:
541 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_ColorMapEntries 0x%lx\n",tag
->ti_Data
));
545 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Parent 0x%lx\n",tag
->ti_Data
));
549 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Draggable 0x%lx\n",tag
->ti_Data
));
553 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_Exclusive 0x%lx\n",tag
->ti_Data
));
556 case SA_VideoControl
:
557 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_VideoControl 0x%lx\n",tag
->ti_Data
));
561 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_FrontChild 0x%lx\n",tag
->ti_Data
));
565 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_BackChild 0x%lx\n",tag
->ti_Data
));
569 DEBUG_OPENSCREEN(dprintf("OpenScreen: SA_MinimizeISG 0x%lx\n",tag
->ti_Data
));
572 #warning TODO: Missing SA_ Tags
574 DEBUG_OPENSCREEN(dprintf("OpenScreen: unknown tag 0x%lx data 0x%lx\n",
579 } /* switch (tag->ti_Tag) */
581 } /* while ((tag = NextTagItem (&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
;
597 modetags
[1].ti_Tag
= TAG_IGNORE
;
600 if (ns
.Height
!= STDSCREENHEIGHT
)
602 modetags
[2].ti_Data
= ns
.Height
;
606 modetags
[2].ti_Tag
= TAG_IGNORE
;
610 // if default HIRES_KEY or HIRESLACE_KEY is passed, make sure we find a replacement
613 if (INVALID_ID
!= modeid
)
615 if (FindDisplayInfo(modeid
) == NULL
)
622 struct TagItem bestmodetags
[] =
624 { CYBRBIDTG_Depth
, 0UL },
625 { CYBRBIDTG_NominalWidth
, 0UL },
626 { CYBRBIDTG_NominalHeight
, 0UL },
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
);)
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
);
665 DEBUG_OPENSCREEN(dprintf("OpenScreen: ModeID 0x%08lx\n", modeid
));
669 InitRastPort(&screen
->Screen
.RastPort
);
674 if ((displayinfo
= FindDisplayInfo(modeid
)) != NULL
&&
675 GetDisplayInfoData(displayinfo
, &dimensions
, sizeof(dimensions
), DTAG_DIMS
, modeid
) &&
676 GetDisplayInfoData(displayinfo
, &monitor
, sizeof(monitor
), DTAG_MNTR
, modeid
))
680 screen
->Monitor
= monitor
.Mspc
;
687 dclip
= &dimensions
.StdOScan
;
691 dclip
= &dimensions
.MaxOScan
;
695 dclip
= &dimensions
.VideoOScan
;
699 dclip
= &dimensions
.TxtOScan
;
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 !
732 screen
->Screen
.RastPort
.BitMap
= custombm
;
733 ns
.Depth
= GetBitMapAttr(ns
.CustomBitMap
,BMA_DEPTH
);
734 DEBUG_OPENSCREEN(dprintf("OpenScreen: CustomBitmap Depth %ld\n",
739 ns
.CustomBitMap
= NULL
;
740 ns
.Type
&= ~CUSTOMBITMAP
;
745 screen
->Screen
.RastPort
.BitMap
= NULL
;
749 if(screen
->Screen
.RastPort
.BitMap
== NULL
)
754 Depth
= (dimensions
.MaxDepth
> 8) ? dimensions
.MaxDepth
: ns
.Depth
;
759 pixfmt
= PIXFMT_RGB15
;
762 pixfmt
= PIXFMT_RGB16
;
765 pixfmt
= PIXFMT_BGR24
;
768 pixfmt
= PIXFMT_ARGB32
;
771 pixfmt
= PIXFMT_LUT8
;
775 if (IsCyberModeID(modeid
))
777 pixfmt
= GetCyberIDAttr(CYBRIDATTR_PIXFMT
,modeid
);
781 allocbitmapflags
|= (BMF_SPECIALFMT
|BMF_CLEAR
);
783 screen
->Screen
.RastPort
.BitMap
= AllocBitMap(ns
.Width
,
786 allocbitmapflags
| (pixfmt
<< 24),
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
));
799 DEBUG_OPENSCREEN(dprintf("OpenScreen: no displayinfo\n"));
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
;
813 dclip
= &dimensions
.StdOScan
;
817 dclip
= &dimensions
.MaxOScan
;
821 dclip
= &dimensions
.VideoOScan
;
825 dclip
= &dimensions
.TxtOScan
;
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
)))
843 screen
->Screen
.RastPort
.BitMap
= screen
->AllocatedBitmap
= AllocScreenBitMap(modeid
);
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
));
861 (screen
->Screen
.RastPort
.BitMap
== NULL
) ||
862 (screen
->Screen
.ViewPort
.RasInfo
== NULL
))
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
;
878 /* Read depth from the bitmap to avoid AttachPalExtra/ObtainPen getting
879 * confused if cgx decided to allocate a higher depth bitmap than what
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",
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
;
898 if (0 == AttachPalExtra(screen
->Screen
.ViewPort
.ColorMap
,
899 &screen
->Screen
.ViewPort
))
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",
931 DEBUG_OPENSCREEN(dprintf("OpenScreen: ColorMap 0x%lx\n",
932 screen
->Screen
.ViewPort
.ColorMap
));
937 screen
->ModeID
= modeid
;
941 struct ViewPortExtra
*vpe
= GfxNew(VIEWPORT_EXTRA_TYPE
);
943 DEBUG_OPENSCREEN(dprintf("OpenScreen: ViewPortExtra 0x%lx\n", 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"));
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)
981 if ((p
= GetPrivIBase(IntuitionBase
)->Colors
))
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
;
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;
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
);
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
,
1063 DEBUG_OPENSCREEN(dprintf("OpenScreen: Obtain Mousepointer colors\n"));
1065 /* Allocate pens for the mouse pointer */
1066 q
= &GetPrivIBase(IntuitionBase
)->ActivePreferences
->color17
;
1068 /* FIXME: this assumes that we have at least 16 colors */
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
,
1077 (*q
>> 8) * 0x11111111,
1078 ((*q
>> 4) & 0xf) * 0x11111111,
1079 (*q
& 0xf) * 0x11111111));
1080 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
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
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,
1096 (*q >> 8) * 0x11111111,
1097 ((*q >> 4) & 0xf) * 0x11111111,
1098 (*q & 0xf) * 0x11111111,
1103 ** Can't be allocated, but can still be set. **
1104 SetRGB32(&screen->Screen.ViewPort,
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
,
1123 SetRGB4(&screen
->Screen
.ViewPort
,
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"));
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
;
1156 /* Mark the bitmap of the screen as an AROS-displayed BitMap */
1157 screen
->Screen
.RastPort
.BitMap
->Flags
|= BMF_AROS_HIDD
;
1161 Copy the data from the rastport's bitmap
1162 to the screen's bitmap structure
1164 screen
->Screen
.BitMap
= *screen
->Screen
.RastPort
.BitMap
;
1167 screen
->Screen
.WBorTop
= 2;
1168 screen
->Screen
.WBorLeft
= 4;
1169 screen
->Screen
.WBorRight
= 4;
1170 screen
->Screen
.WBorBottom
= 2;
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 */
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
);
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
},
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,
1209 DEBUG_OPENSCREEN(dprintf("OpenScreen: rootLayer 0x%lx\n",screen
->rootLayer
));
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
));
1240 /* Is handled below */
1241 DEBUG_OPENSCREEN(dprintf("OpenScreen: skip SysFont for now\n"));
1243 else if (sysfont
== 1)
1246 /* Use safe OpenFont here - Piru
1248 screen
->DInfo
.dri
.dri_Font
= SafeReopenFont(IntuitionBase
, &GetPrivIBase(IntuitionBase
)->ScreenFont
);
1251 #warning: Really hacky way of re-opening ScreenFont
1254 screen
->DInfo
.dri
.dri_Font
= GetPrivIBase(IntuitionBase
)->ScreenFont
;
1255 screen
->DInfo
.dri
.dri_Font
->tf_Accessors
++;
1259 screen
->SpecialFlags
|= SF_SysFont
;
1261 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set ScreenFont\n"));
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!! */
1276 /* Use safe OpenFont.. - Piru
1278 screen
->DInfo
.dri
.dri_Font
= SafeReopenFont(IntuitionBase
, &GfxBase
->DefaultFont
);
1281 #warning: Really hacky way of re-opening system default font
1284 screen
->DInfo
.dri
.dri_Font
= GfxBase
->DefaultFont
;
1285 screen
->DInfo
.dri
.dri_Font
->tf_Accessors
++;
1290 if (!screen
->DInfo
.dri
.dri_Font
) ok
= FALSE
;
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
,
1303 sizeof(screen
->Pens
));
1307 DEBUG_OPENSCREEN(dprintf("OpenScreen: Set NewLook\n"));
1308 screen
->DInfo
.dri
.dri_Flags
|= DRIF_NEWLOOK
;
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
];
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;
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];
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
,
1385 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
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 */
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
,
1410 ObtainPen(screen
->Screen
.ViewPort
.ColorMap
,
1415 PENF_EXCLUSIVE
| PENF_NO_SETCOLOR
);
1419 } /* if (!sharepens) */
1427 if (!SetFrontBitMap(screen
->Screen
.RastPort
.BitMap
, TRUE
))
1439 screen
->DInfo
.dri_Screen
= &screen
->Screen
; //useful sometimes ;)
1441 realdepth
= GetBitMapAttr( screen
->Screen
.RastPort
.BitMap
, BMA_DEPTH
);
1444 screen
->DInfo
.dri_Flags
|= DRIF_DIRECTCOLOR
;
1448 screen
->DInfo
.dri_Flags
&= ~DRIF_DIRECTCOLOR
;
1451 if (!(screen
->DInfo
.dri_Colors
= AllocMem(4 * DRIPEN_NUMDRIPENS
,MEMF_PUBLIC
)))
1456 CopyMem(&defaultdricolors
,screen
->DInfo
.dri_Colors
,sizeof (defaultdricolors
));
1457 memset(((UBYTE
*) screen
->DInfo
.dri_Colors
) + sizeof(defaultdricolors
), 0, 4 * DRIPEN_NUMDRIPENS
- sizeof(defaultdricolors
));
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
);
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
;
1490 screen
->Screen
.WBorTop
+= wcprefs
->titlebarincrement
;
1492 int_FreeCustomPrefs(TYPE_WINDOWCLASS
,&screen
->DInfo
,IntuitionBase
);
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);
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;
1530 screen
->ScrDecorObj
= nd
->nd_Screen
;
1531 screen
->WinDecorObj
= nd
->nd_Window
;
1532 screen
->MenuDecorObj
= nd
->nd_Menu
;
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
);
1550 screen
->DecorUserBufferSize
= userbuffersize
;
1551 screen
->DecorUserBuffer
= (IPTR
) AllocMem(userbuffersize
, MEMF_ANY
| MEMF_CLEAR
);
1552 if (!screen
->DecorUserBuffer
) ok
= FALSE
;
1558 struct TagItem sysi_tags
[] =
1560 {SYSIA_Which
, MENUCHECK
},
1561 {SYSIA_DrawInfo
, (IPTR
)&screen
->DInfo
},
1562 {SYSIA_UserBuffer
, screen
->DecorUserBuffer
},
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
));
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
;
1592 if (!screen
->DInfo
.dri
.dri_CheckMark
|| !screen
->DInfo
.dri
.dri_AmigaKey
|| !screen
->DInfo
.dri
.dri_SubMenuImage
) ok
= FALSE
;
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
));
1609 screen
->Screen
.BarVBorder
= 1;
1610 screen
->Screen
.BarHBorder
= 5;
1611 screen
->Screen
.MenuVBorder
= 2;
1612 screen
->Screen
.MenuHBorder
= 4;
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;
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
;
1637 msg
.sdp_TitleHack
= screen
->Screen
.WBorTop
-2;
1639 msg
.sdp_TitleHack
= 0;
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
;
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
;
1665 #define SDEPTH_HEIGHT (screen->Screen.BarHeight + 1)
1669 #define IA_Screen (IA_Dummy + 0x1f) /* OS v44 includes!*/
1671 struct TagItem sdepth_tags
[] =
1675 #if SQUARE_WIN_GADGETS
1676 {GA_Width
, SDEPTH_HEIGHT
},
1678 {GA_Height
, SDEPTH_HEIGHT
},
1679 {GA_SysGadget
, TRUE
},
1680 {GA_SysGType
, GTYP_SDEPTH
},
1681 {GA_RelVerify
, TRUE
},
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
);
1718 struct TagItem gadtags
[] =
1725 GetAttr(GA_Width
, screen
->depthgadget
, &width
);
1727 gadtags
[0].ti_Data
= -width
+ 1;
1728 SetAttrsA(screen
->depthgadget
, gadtags
);
1734 if (im
) DisposeObject(im
);
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
]));
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
);
1758 int_CalcSkinInfo(&screen
->Screen
,IntuitionBase
);
1759 int_InitTitlebarBuffer(screen
,IntuitionBase
);
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"));
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
;
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
1793 struct OpenScreenActionMsg msg
;
1794 struct List
*list
= LockPubScreenList();
1796 msg
.Screen
= screen
;
1797 msg
.NewScreen
= &ns
;
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();
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
));
1821 ok
= MakeScreen(&screen
->Screen
) == 0;
1822 DEBUG_OPENSCREEN(dprintf("OpenScreen: MakeScreen %s\n", ok
? "ok" : "failed"));
1827 ok
= RethinkDisplay() == 0;
1828 DEBUG_OPENSCREEN(dprintf("OpenScreen: RethinkDisplay %s\n", ok
? "ok" : "failed"));
1835 FireMenuMessage(MMCODE_STARTCLOCK
,NULL
,NULL
,IntuitionBase
);
1839 #ifdef USEWINDOWLOCK
1840 if (windowlock
) ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->WindowLock
);
1848 if (NULL
!= old_front_bm
)
1849 SetFrontBitMap(old_front_bm
, FALSE
);
1855 DEBUG_OPENSCREEN(dprintf("OpenScreen: Get ThinLayerInfo\n"));
1856 ThinLayerInfo(&screen
->Screen
.LayerInfo
);
1859 if (screen
->Screen
.ViewPort
.ColorMap
)
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 &&
1871 GfxFree((APTR
)tags
[0].ti_Data
);
1875 FreeColorMap(screen
->Screen
.ViewPort
.ColorMap
);
1878 if (screen
->Screen
.BarLayer
)
1880 DEBUG_OPENSCREEN(dprintf("OpenScreen: KillScreenBar\n"));
1881 KillScreenBar(&screen
->Screen
, IntuitionBase
);
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
);
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
));
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
));
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
);
1957 static VOID
int_openscreen(struct OpenScreenActionMsg
*msg
,
1958 struct IntuitionBase
*IntuitionBase
)
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"));
1985 IntuitionBase
->ActiveScreen
= &screen
->Screen
;
1987 ptr
= &(*ptr
)->NextScreen
;
1988 *ptr
= &screen
->Screen
;
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
;
2009 D(bug("set active screen\n"));
2011 AddResourceToList(screen
, RESOURCE_SCREEN
, IntuitionBase
);