2 Copyright © 2013-2014, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
8 #include <hidd/graphics.h>
10 #include <graphics/driver.h>
11 #include <graphics/sprite.h>
12 #include <intuition/intuition.h>
13 #include <intuition/intuitionbase.h>
14 #include <intuition/classes.h>
15 #include <intuition/classusr.h>
16 #include <intuition/monitorclass.h>
17 #include <proto/alib.h>
18 #include <proto/exec.h>
19 #include <proto/intuition.h>
20 #include <proto/oop.h>
21 #include <proto/utility.h>
23 #include "intuition_intern.h"
24 #include "intuition_customize.h"
25 #include "monitorclass_private.h"
27 /*i***************************************************************************
30 --background_screenclass--
36 In AROS screens are BOOPSI objects. It is possible to modify certain
37 properties of the screen by using the SetAttrs() and GetAttr()
38 functions. screenclass by itself is private to the system and does not
39 have a public ID. The user can't create objects of this class
40 manually. Screens are created and destroyed as usual, using
41 the OpenScreen() and CloseScreen() functions.
43 This class is fully compatible with MorphOS starting from v2.x.
45 *****************************************************************************/
47 IPTR
ScreenClass__OM_DISPOSE(Class
*cl
, Object
*o
, Msg msg
)
49 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
50 struct IntScreen
*screen
= INST_DATA(cl
, o
);
52 /* Free decoration objects */
53 DisposeObject(screen
->WinDecorObj
);
54 DisposeObject(screen
->MenuDecorObj
);
55 DisposeObject(screen
->ScrDecorObj
);
57 /* Free decoration buffer */
58 FreeMem((APTR
)screen
->DecorUserBuffer
, screen
->DecorUserBufferSize
);
60 if ((screen
->Decorator
!= ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
) &&
61 (screen
->Decorator
!= NULL
))
63 struct NewDecorator
*nd
= screen
->Decorator
;
65 ObtainSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
68 if (nd
->nd_IntPattern
== NULL
)
71 * If no pattern is defined, we assume it was old default decorator
72 * which fell out of use. Unload it.
74 int_UnloadDecorator(nd
, IntuitionBase
);
77 ReleaseSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
80 return DoSuperMethodA(cl
, o
, msg
);
83 static IPTR
GetScreen(ULONG attrID
, struct IntScreen
*screen
, struct IntuitionBase
*IntuitionBase
)
87 GetAttr(attrID
, screen
->IMonitorNode
, (IPTR
*)&mon
);
91 ULONG lock
= LockIBase(0);
92 struct Screen
*ret
= FindFirstScreen(mon
, IntuitionBase
);
94 if (ret
&& ((ret
->Flags
& SCREENTYPE
) == CUSTOMSCREEN
))
96 /* We want only public screens */
108 /*i***************************************************************************
120 Position of left edge of the screen relative to top-left physical
133 *****************************************************************************/
135 /*i***************************************************************************
147 Position of top edge of the screen relative to top-left physical
160 *****************************************************************************/
161 /*i***************************************************************************
173 Width of the screen (not display) in pixels.
185 *****************************************************************************/
187 /*i***************************************************************************
199 Height of the screen (not display) in pixels.
211 *****************************************************************************/
213 /*i***************************************************************************
228 This attribute returns the real depth; however, old structure fields,
229 for example screen->RastPort.BitMap->bm_Depth, in case of direct-color
230 screens will contain 8 for purposes of backwards compatibility.
240 *****************************************************************************/
242 /*i***************************************************************************
254 Public screen name (system name, not human-readable title).
266 *****************************************************************************/
268 /*i***************************************************************************
280 Display mode ID of the screen.
292 *****************************************************************************/
294 /*i***************************************************************************
306 Supplying this attribute during screen creation (to OpenScreen() or
307 OpenScreenTagList() functions) causes this screen to be created and
308 opened behind all other screens.
310 Querying this attribute returns its initial value.
322 *****************************************************************************/
324 /*i***************************************************************************
336 Name of the monitorclass object (AKA display device name) to which
350 *****************************************************************************/
352 /*i***************************************************************************
364 Returns display device (monitorclass) object to which this screen
378 *****************************************************************************/
380 /*i***************************************************************************
386 [..G], struct Screen *
392 Get a pointer to a public screen displayed on a monitor placed in
393 top-left diagonal direction relative to this screen's one. If the
394 frontmost screen on the given monitor is not public, NULL will be
398 AROS supports screen composition, so more than one screen is actually
399 displayed at any given time. In order to match MorphOS semantics this
400 attribute takes into account only the frontmost screen on the given
408 monitorclass/MA_TopLeftMonitor
412 *****************************************************************************/
414 /*i***************************************************************************
420 [..G], struct Screen *
426 Get a pointer to a public screen displayed on a monitor placed in top
427 direction relative to this screen's one. If the frontmost screen on
428 the given monitor is not public, NULL will be returned.
431 AROS supports screen composition, so more than one screen is actually
432 displayed at any given time. In order to match MorphOS semantics this
433 attribute takes into account only the frontmost screen on the given
441 monitorclass/MA_TopMiddleMonitor
445 *****************************************************************************/
447 /*i***************************************************************************
453 [..G], struct Screen *
459 Get a pointer to a screen displayed on a monitor placed in top-right
460 diagonal direction relative to this screen's one. If the frontmost
461 screen on the given monitor is not public, NULL will be returned.
464 AROS supports screen composition, so more than one screen is actually
465 displayed at any given time. In order to match MorphOS semantics this
466 attribute takes into account only the frontmost screen on the given
474 monitorclass/MA_TopRightMonitor
478 *****************************************************************************/
480 /*i***************************************************************************
486 [..G], struct Screen *
492 Get a pointer to a public screen displayed on a monitor placed in left
493 direction relative to this screen's one. If the frontmost screen on
494 the given monitor is not public, NULL will be returned.
497 AROS supports screen composition, so more than one screen is actually
498 displayed at any given time. In order to match MorphOS semantics this
499 attribute takes into account only the frontmost screen on the given
507 monitorclass/MA_MiddleLeftMonitor
511 *****************************************************************************/
513 /*i***************************************************************************
519 [..G], struct Screen *
525 Get a pointer to a public screen displayed on a monitor placed in left
526 direction relative to this screen's one. If the frontmost screen on
527 the given monitor is not public, NULL will be returned.
530 AROS supports screen composition, so more than one screen is actually
531 displayed at any given time. In order to match MorphOS semantics this
532 attribute takes into account only the frontmost screen on the given
540 monitorclass/MA_MiddleRightMonitor
544 *****************************************************************************/
546 /*i***************************************************************************
552 [..G], struct Screen *
558 Get a pointer to a public screen displayed on a monitor placed in
559 bottom-left diagonal direction relative to this screen's one. If the
560 frontmost screen on the given monitor is not public, NULL will be
564 AROS supports screen composition, so more than one screen is actually
565 displayed at any given time. In order to match MorphOS semantics this
566 attribute takes into account only the frontmost screen on the given
574 monitorclass/MA_BottomLeftMonitor
578 *****************************************************************************/
580 /*i***************************************************************************
583 SA_BottomMiddleScreen
586 [..G], struct Screen *
592 Get a pointer to a public screen displayed on a monitor placed in
593 bottom direction relative to this screen's one. If the frontmost
594 screen on the given monitor is not public, NULL will be returned.
597 AROS supports screen composition, so more than one screen is actually
598 displayed at any given time. In order to match MorphOS semantics this
599 attribute takes into account only the frontmost screen on the given
607 monitorclass/MA_BottomMiddleMonitor
611 *****************************************************************************/
613 /*i***************************************************************************
619 [..G], struct Screen *
625 Get a pointer to a screen displayed on a monitor placed in
626 bottom-right diagonal direction relative to this screen's one. If the
627 frontmost screen on the given monitor is not public, NULL will be
631 AROS supports screen composition, so more than one screen is actually
632 displayed at any given time. In order to match MorphOS semantics this
633 attribute takes into account only the frontmost screen on the given
641 monitorclass/MA_BottomRightMonitor
645 *****************************************************************************/
647 /*i***************************************************************************
659 This attribute is currently reserved and exists only for source
660 compatibility with MorphOS.
672 *****************************************************************************/
674 /*i***************************************************************************
686 Setting this attribute to FALSE makes mouse pointer invisible on your
687 custom screen. The default value is TRUE. Setting this attribute on
688 public screens is ignored.
700 *****************************************************************************/
702 /*i***************************************************************************
714 Setting this attribute to TRUE enables use of the SA_GammaRed,
715 SA_GammaBlue and SA_GammaGreen attributes to supply a custom gamma
716 correction table for your screen.
719 Since in AROS more than one screen can be visible simultaneously, the
720 current display gamma correction table is determined by the frontmost
721 screen on that display.
731 *****************************************************************************/
733 IPTR
ScreenClass__OM_GET(Class
*cl
, Object
*o
, struct opGet
*msg
)
735 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
736 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
737 OOP_AttrBase HiddBitMapAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
738 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
739 struct IntScreen
*screen
= INST_DATA(cl
, o
);
741 switch (msg
->opg_AttrID
)
744 *msg
->opg_Storage
= screen
->Screen
.LeftEdge
;
748 *msg
->opg_Storage
= screen
->Screen
.TopEdge
;
752 *msg
->opg_Storage
= screen
->Screen
.Width
;
756 *msg
->opg_Storage
= screen
->Screen
.Height
;
760 *msg
->opg_Storage
= screen
->realdepth
;
764 *msg
->opg_Storage
= (IPTR
)screen
->pubScrNode
->psn_Node
.ln_Name
;
768 *msg
->opg_Storage
= screen
->ModeID
;
772 *msg
->opg_Storage
= (screen
->Screen
.Flags
& SCREENBEHIND
) ? TRUE
: FALSE
;
776 *msg
->opg_Storage
= screen
->GammaControl
.Active
;
780 return GetAttr(MA_MonitorName
, screen
->IMonitorNode
, msg
->opg_Storage
);
782 case SA_MonitorObject
:
783 *msg
->opg_Storage
= (IPTR
)screen
->IMonitorNode
;
786 case SA_TopLeftScreen
:
787 *msg
->opg_Storage
= GetScreen(MA_TopLeftMonitor
, screen
, IntuitionBase
);
790 case SA_TopMiddleScreen
:
791 *msg
->opg_Storage
= GetScreen(MA_TopMiddleMonitor
, screen
, IntuitionBase
);
794 case SA_TopRightScreen
:
795 *msg
->opg_Storage
= GetScreen(MA_TopRightMonitor
, screen
, IntuitionBase
);
798 case SA_MiddleLeftScreen
:
799 *msg
->opg_Storage
= GetScreen(MA_MiddleLeftMonitor
, screen
, IntuitionBase
);
802 case SA_MiddleRightScreen
:
803 *msg
->opg_Storage
= GetScreen(MA_MiddleRightMonitor
, screen
, IntuitionBase
);
806 case SA_BottomLeftScreen
:
807 *msg
->opg_Storage
= GetScreen(MA_BottomLeftMonitor
, screen
, IntuitionBase
);
810 case SA_BottomMiddleScreen
:
811 *msg
->opg_Storage
= GetScreen(MA_BottomMiddleMonitor
, screen
, IntuitionBase
);
814 case SA_BottomRightScreen
:
815 *msg
->opg_Storage
= GetScreen(MA_BottomRightMonitor
, screen
, IntuitionBase
);
819 *msg
->opg_Storage
= screen
->ShowPointer
;
823 *msg
->opg_Storage
= (IPTR
)screen
->GammaControl
.GammaTableR
;
827 *msg
->opg_Storage
= (IPTR
)screen
->GammaControl
.GammaTableB
;
831 *msg
->opg_Storage
= (IPTR
)screen
->GammaControl
.GammaTableG
;
834 case SA_DisplayWidth
:
835 *msg
->opg_Storage
= screen
->Screen
.ViewPort
.DWidth
;
838 case SA_DisplayHeight
:
839 *msg
->opg_Storage
= screen
->Screen
.ViewPort
.DHeight
;
843 if (IS_HIDD_BM(screen
->Screen
.RastPort
.BitMap
))
847 OOP_GetAttr(HIDD_BM_OBJ(screen
->Screen
.RastPort
.BitMap
), aHidd_BitMap_PixFmt
, (IPTR
*)&pixfmt
);
848 OOP_GetAttr(pixfmt
, aHidd_PixFmt_CgxPixFmt
, msg
->opg_Storage
);
852 *msg
->opg_Storage
= -1;
856 case SA_ScreenbarTextYPos
:
857 *msg
->opg_Storage
= screen
->Screen
.BarVBorder
+ screen
->Screen
.BarLayer
->rp
->TxBaseline
;
860 case SA_ScreenbarTextPen
:
861 *msg
->opg_Storage
= screen
->Pens
[BARDETAILPEN
];
864 case SA_ScreenbarTextFont
:
865 *msg
->opg_Storage
= (IPTR
)screen
->Screen
.BarLayer
->rp
->Font
;
868 case SA_CompositingFlags
:
869 *msg
->opg_Storage
= (IPTR
)(screen
->SpecialFlags
>> 8);
872 case SA_AlphaPreCompositingHook
:
873 *msg
->opg_Storage
= (IPTR
)screen
->preAlphaCompHook
;
876 case SA_OpacitySupport
: /* These are reserved in AROS */
877 case SA_SourceAlphaSupport
:
878 case SA_ScreenbarSignal
:
879 case SA_CompositingLayers
:
880 *msg
->opg_Storage
= 0;
890 IPTR
ScreenClass__OM_SET(Class
*cl
, Object
*o
, struct opSet
*msg
)
892 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
893 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
894 struct IntScreen
*screen
= INST_DATA(cl
, o
);
895 struct TagItem
*tstate
= msg
->ops_AttrList
;
897 BOOL showpointer
= screen
->ShowPointer
;
898 BOOL movescreen
= FALSE
;
899 BOOL gammaset
= FALSE
;
901 while((tag
= NextTagItem(&tstate
)))
906 if (screen
->SpecialFlags
& SF_Draggable
)
908 screen
->Screen
.LeftEdge
= tag
->ti_Data
;
914 if (screen
->SpecialFlags
& SF_Draggable
)
916 screen
->Screen
.TopEdge
= tag
->ti_Data
;
922 showpointer
= tag
->ti_Data
;
926 if (screen
->GammaControl
.UseGammaControl
)
928 screen
->GammaControl
.GammaTableR
= (UBYTE
*)tag
->ti_Data
;
934 if (screen
->GammaControl
.UseGammaControl
)
936 screen
->GammaControl
.GammaTableB
= (UBYTE
*)tag
->ti_Data
;
942 if (screen
->GammaControl
.UseGammaControl
)
944 screen
->GammaControl
.GammaTableG
= (UBYTE
*)tag
->ti_Data
;
949 case SA_AlphaPreCompositingHook
:
951 screen
->preAlphaCompHook
= (struct Hook
*)tag
->ti_Data
;
960 * Move the screen to (0, 0) relative of current position.
961 * LeftEdge/TopEdge have been already updated.
963 ScreenPosition(&screen
->Screen
, SPOS_RELATIVE
, 0, 0, 0, 0);
966 if (showpointer
!= screen
->ShowPointer
)
968 screen
->ShowPointer
= showpointer
;
969 /* TODO: Actually implement this */
975 * Update gamma table on the monitor.
976 * The monitorclass takes care itself about whether this screen
977 * currently controlls gamma table.
979 DoMethod((Object
*)screen
->IMonitorNode
, MM_SetScreenGamma
, &GetPrivScreen(screen
)->GammaControl
, FALSE
);