2 Copyright © 1995-2013, 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 "monitorclass_intern.h"
25 #include "monitorclass_private.h"
27 /*i***************************************************************************
30 --background_monitorclass--
36 In AROS display drivers have associated BOOPSI objects of MONITORCLASS
37 class. This class provides information about relative physical
38 placement of monitors in user's workspace as well as some additional
41 MONITORCLASS is a pseudo-name. This class is in fact private to the
42 system and does not have a public ID. The user can't create objects of
45 This class is fully compatible with MorphOS starting from v2.6.
47 *****************************************************************************/
49 Object
*DisplayDriverNotify(APTR obj
, BOOL add
, struct IntuitionBase
*IntuitionBase
)
53 Object
*mon
= NewObject(GetPrivIBase(IntuitionBase
)->monitorclass
, NULL
, MA_MonitorHandle
, obj
, TAG_DONE
);
55 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon
));
57 /* Install default mouse pointer on the new monitor */
58 Object
*ptr
= GetPrivIBase(IntuitionBase
)->DefaultPointer
;
61 struct SharedPointer
*pointer
;
63 GetAttr(POINTERA_SharedPointer
, ptr
, (IPTR
*)&pointer
);
64 DoMethod(mon
, MM_SetPointerShape
, pointer
);
77 /*i**************************************************************************/
79 static void SetPointerPos(struct IMonitorNode
*data
, struct IntuitionBase
*IntuitionBase
)
81 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
82 ULONG x
= data
->mouseX
;
83 ULONG y
= data
->mouseY
;
85 DB2(bug("[monitorclass] SetPointerPos(%d, %d), pointer 0x%p\n", x
, y
, data
->pointer
));
88 /* Update sprite position, just for backwards compatibility */
89 data
->pointer
->sprite
->es_SimpleSprite
.x
= x
;
90 data
->pointer
->sprite
->es_SimpleSprite
.y
= y
;
93 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x
, y
));
94 HIDD_Gfx_SetCursorPos(data
->handle
->gfxhidd
, x
, y
);
97 /*i**************************************************************************/
99 static void ActivationHandler(Object
*mon
, OOP_Object
*bitmap
)
101 Class
*cl
= OCLASS(mon
);
102 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
104 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
105 GetPrivIBase(IntuitionBase
)->NewMonitor
= mon
;
108 /*i**************************************************************************/
110 static void ResetGamma(struct IMonitorNode
*data
)
112 data
->active_r
= &data
->gamma
[GAMMA_R
];
113 data
->active_g
= &data
->gamma
[GAMMA_G
];
114 data
->active_b
= &data
->gamma
[GAMMA_B
];
117 Object
*MonitorClass__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
119 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
120 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
121 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
122 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
123 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
124 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
125 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
126 struct MonitorHandle
*handle
= (struct MonitorHandle
*)GetTagData(MA_MonitorHandle
, 0, msg
->ops_AttrList
);
127 HIDDT_ModeID mode
= vHidd_ModeID_Invalid
;
128 struct IMonitorNode
*data
;
129 OOP_Object
*sync
, *pixfmt
;
130 /* Tags order is important because CallBackData needs to be set before
131 function pointer. Otherwise the function can be called with a wrong
133 struct TagItem tags
[] =
135 {aHidd_Gfx_ActiveCallBackData
, 0 },
136 {aHidd_Gfx_ActiveCallBack
, (IPTR
)ActivationHandler
},
140 D(kprintf("[monitorclass] OM_NEW\n"));
145 o
= (Object
*)DoSuperMethodA(cl
, o
, (Msg
)msg
);
149 data
= INST_DATA(cl
, o
);
151 data
->handle
= handle
;
153 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
154 just some pixelformats will be processed more than once */
155 while ((mode
= HIDD_Gfx_NextModeID(handle
->gfxhidd
, mode
, &sync
, &pixfmt
)) != vHidd_ModeID_Invalid
)
159 OOP_GetAttr(pixfmt
, aHidd_PixFmt_CgxPixFmt
, &cgxpf
);
160 D(bug("[monitorclass] Mode 0x%08lX, CGX pixfmt %ld\n", mode
, cgxpf
));
164 data
->pfobjects
[cgxpf
] = pixfmt
;
165 data
->pixelformats
[cgxpf
] = TRUE
;
169 if (OOP_GET(data
->handle
->gfxhidd
, aHidd_Gfx_SupportsGamma
))
173 D(bug("[monitorclass] Creating gamma table\n"));
175 data
->gamma
= AllocMem(256 * 3, MEMF_ANY
);
178 DoSuperMethod(cl
, o
, OM_DISPOSE
);
182 /* Create default gamma table */
183 for (i
= 0; i
< 256; i
++)
185 data
->gamma
[i
+ GAMMA_R
] = i
;
186 data
->gamma
[i
+ GAMMA_G
] = i
;
187 data
->gamma
[i
+ GAMMA_B
] = i
;
192 OOP_GetAttr(handle
->gfxhidd
, aHidd_Name
, (IPTR
*)&data
->MonitorName
);
194 tags
[0].ti_Data
= (IPTR
)o
;
195 OOP_SetAttrs(handle
->gfxhidd
, tags
);
197 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
198 AddTail((struct List
*)&GetPrivIBase(IntuitionBase
)->MonitorList
, (struct Node
*)data
);
199 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
204 /*i***************************************************************************
216 Query monitor driver name.
228 *****************************************************************************/
230 /*i***************************************************************************
242 Query video card hardware manufacturer name
245 Not all drivers may specify manufacturer string. NULL is a valid
256 *****************************************************************************/
258 /*i***************************************************************************
270 Query video card hardware's numeric manufacturer ID (which may come
271 from PCI, Zorro, etc).
274 Not all drivers may have assigned IDs. For example VGA driver and
275 virtual hosted drivers do not associate themselves with any IDs.
286 *****************************************************************************/
288 /*i***************************************************************************
300 Query video card hardware's numeric product ID (which may come from
304 Not all drivers may have assigned IDs. For example VGA driver and
305 virtual hosted drivers do not associate themselves with any IDs.
316 *****************************************************************************/
318 /*i***************************************************************************
330 Query total size of video card memory in bytes.
343 *****************************************************************************/
345 /*i***************************************************************************
357 Query table of supported pixelformats.
359 A returned value is a pointer to static array of ULONGs, one ULONG per
360 CyberGraphX pixelformat. Values of these ULONGs are actually booleans.
361 A TRUE value in the array says that the pixelformat is supported,
362 FALSE means it is not.
369 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
370 if (pfs[PUXFMT_LUT8])
371 printf("The display driver supports LUT8 format\n");
380 *****************************************************************************/
382 /*i***************************************************************************
394 Get a pointer to a monitor placed in top-left diagonal direction
395 relative tothe current one.
397 This attribute is used to describe relative placement of monitors in
398 user's physical environment.
405 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
409 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
410 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
411 MA_BottomRightMonitor
415 *****************************************************************************/
417 /*i***************************************************************************
429 Get a pointer to a monitor placed in top direction relative to the
432 This attribute is used to describe relative placement of monitors in
433 the user's physical environment.
440 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
441 pointer to a monitor object.
444 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
445 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
446 MA_BottomRightMonitor
450 *****************************************************************************/
452 /*i***************************************************************************
464 Get a pointer to a monitor placed in top-right diagonal direction
465 relative to the current one.
467 This attribute is used to describe relative placement of monitors in
468 the user's physical environment.
475 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
476 pointer to a monitor object.
479 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
480 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
481 MA_BottomRightMonitor
485 *****************************************************************************/
487 /*i***************************************************************************
499 Get a pointer to a monitor placed in left direction relative to
502 This attribute is used to describe relative placement of monitors in
503 the user's physical environment.
510 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
511 pointer to a monitor object.
514 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
515 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
516 MA_BottomRightMonitor
520 *****************************************************************************/
522 /*i***************************************************************************
525 MA_MiddleRightMonitor
534 Get a pointer to a monitor placed in right direction relative to
537 This attribute is used to describe relative placement of monitors in
538 the user's physical environment.
545 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
546 pointer to a monitor object.
549 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
550 MA_MiddleLeftMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor,
551 MA_BottomRightMonitor
555 *****************************************************************************/
557 /*i***************************************************************************
569 Get a pointer to a monitor placed in bottom-left diagonal direction
570 relative to the current one.
572 This attribute is used to describe relative placement of monitors in
573 the user's physical environment.
580 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
581 pointer to a monitor object.
584 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
585 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomMiddleMonitor,
586 MA_BottomRightMonitor
590 *****************************************************************************/
592 /*i***************************************************************************
595 MA_BottomMiddleMonitor
604 Get a pointer to a monitor placed in bottom direction relative to the
607 This attribute is used to describe relative placement of monitors in
608 the user's physical environment.
615 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
616 pointer to a monitor object.
619 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
620 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
621 MA_BottomRightMonitor
625 *****************************************************************************/
627 /*i***************************************************************************
630 MA_BottomRightMonitor
639 Get a pointer to a monitor placed in bottom-right diagonal direction
640 relative to the current one.
642 This attribute is used to describe relative placement of monitors in
643 the user's physical environment.
650 In MorphOS up to v2.5 this attribute returns a monitor ID, not a
651 pointer to a monitor object.
654 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior,
655 MA_MiddleLeftMonitor, MA_MiddleRightMonitor, MA_BottomLeftMonitor,
656 MA_BottomMiddleMonitor
660 *****************************************************************************/
662 /*i***************************************************************************
674 Query if the display driver supports gamma control.
683 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
687 *****************************************************************************/
689 /*i***************************************************************************
701 Query supported mouse pointer sprite formats.
703 The returned value is a combination of the following bit flags:
704 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm)
706 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for
707 example clear or inverse), 2-3 visible
708 PointerType_ARGB - Direct color bitmap (hi-color or truecolor,
709 possibly with alpha channel
722 *****************************************************************************/
724 /*i***************************************************************************
736 Query CyberGraphX driver name. It is the name which can be given to
737 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName
751 *****************************************************************************/
753 /*i***************************************************************************
765 Query the video card's memory clock in Hertz. 0 is a valid value
779 *****************************************************************************/
781 /*i***************************************************************************
793 Check if this monitor is a window on hosted OS desktop.
795 This means that the host OS is responsible for handling mouse input
796 and display activation. Monitors with this attribute set to TRUE
797 should be ignored by multi-display desktop configuration software.
799 These monitors should have no spatial links to other monitors.
800 Activation of these monitors is done by clicking on their windows on
801 the host's desktop and is handled by the driver itself.
804 This attribute is AROS-specific; it does not exist in MorphOS.
814 *****************************************************************************/
816 /*i**************************************************************************/
818 IPTR
MonitorClass__OM_GET(Class
*cl
, Object
*o
, struct opGet
*msg
)
820 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
821 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
822 OOP_AttrBase HiddAttrBase
= GetPrivIBase(IntuitionBase
)->HiddAttrBase
;
823 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
824 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
826 D(kprintf("[monitorclass] OM_GET\n"));
828 switch (msg
->opg_AttrID
)
831 *msg
->opg_Storage
= (IPTR
)data
->MonitorName
;
834 case MA_Manufacturer
:
835 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_ProducerName
, msg
->opg_Storage
);
838 case MA_ManufacturerID
:
839 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Producer
, msg
->opg_Storage
);
843 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Product
, msg
->opg_Storage
);
847 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemorySize
, msg
->opg_Storage
);
850 case MA_PixelFormats
:
851 *msg
->opg_Storage
= (IPTR
)data
->pixelformats
;
854 case MA_TopLeftMonitor
:
855 *msg
->opg_Storage
= (IPTR
)data
->topleft
;
858 case MA_TopMiddleMonitor
:
859 *msg
->opg_Storage
= (IPTR
)data
->topmiddle
;
862 case MA_TopRightMonitor
:
863 *msg
->opg_Storage
= (IPTR
)data
->topright
;
866 case MA_MiddleLeftMonitor
:
867 *msg
->opg_Storage
= (IPTR
)data
->middleleft
;
870 case MA_MiddleRightMonitor
:
871 *msg
->opg_Storage
= (IPTR
)data
->middleright
;
874 case MA_BottomLeftMonitor
:
875 *msg
->opg_Storage
= (IPTR
)data
->bottomleft
;
878 case MA_BottomMiddleMonitor
:
879 *msg
->opg_Storage
= (IPTR
)data
->bottommiddle
;
882 case MA_BottomRightMonitor
:
883 *msg
->opg_Storage
= (IPTR
)data
->bottomright
;
886 case MA_GammaControl
:
887 *msg
->opg_Storage
= data
->gamma
? TRUE
: FALSE
;
891 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_HWSpriteTypes
, msg
->opg_Storage
);
895 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_DriverName
, msg
->opg_Storage
);
899 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_MemoryClock
, msg
->opg_Storage
);
903 OOP_GetAttr(data
->handle
->gfxhidd
, aHidd_Gfx_IsWindowed
, msg
->opg_Storage
);
907 *msg
->opg_Storage
= data
->handle
->id
;
911 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
917 /*i**************************************************************************/
919 IPTR
MonitorClass__OM_SET(Class
*cl
, Object
*o
, struct opSet
*msg
)
921 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
922 struct Library
*UtilityBase
= GetPrivIBase(IntuitionBase
)->UtilityBase
;
923 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
924 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
925 struct TagItem
*tag
, *tstate
;
927 tstate
= msg
->ops_AttrList
;
928 while((tag
= NextTagItem(&tstate
))) {
929 switch (tag
->ti_Tag
) {
930 case MA_TopLeftMonitor
:
931 data
->topleft
= (Object
*)tag
->ti_Data
;
934 case MA_TopMiddleMonitor
:
935 data
->topmiddle
= (Object
*)tag
->ti_Data
;
938 case MA_TopRightMonitor
:
939 data
->topright
= (Object
*)tag
->ti_Data
;
942 case MA_MiddleLeftMonitor
:
943 data
->middleleft
= (Object
*)tag
->ti_Data
;
946 case MA_MiddleRightMonitor
:
947 data
->middleright
= (Object
*)tag
->ti_Data
;
950 case MA_BottomLeftMonitor
:
951 data
->bottomleft
= (Object
*)tag
->ti_Data
;
954 case MA_BottomMiddleMonitor
:
955 data
->bottommiddle
= (Object
*)tag
->ti_Data
;
958 case MA_BottomRightMonitor
:
959 data
->bottomright
= (Object
*)tag
->ti_Data
;
962 case MA_PointerVisible
:
963 HIDD_Gfx_SetCursorVisible(data
->handle
->gfxhidd
, tag
->ti_Data
);
967 return DoSuperMethodA(cl
, o
, (Msg
)msg
);
970 /*i**************************************************************************/
972 #define Relink(nextAttr, prev, prevAttr, next) \
974 SetAttrs(prev, nextAttr, next, TAG_DONE); \
976 SetAttrs(next, prevAttr, prev, TAG_DONE)
978 IPTR
MonitorClass__OM_DISPOSE(Class
*cl
, Object
*o
, Msg msg
)
980 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
981 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
982 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
983 struct IMonitorNode
*data
= INST_DATA(cl
, o
);
984 struct TagItem tags
[] =
986 {aHidd_Gfx_ActiveCallBack
, 0},
990 D(kprintf("MonitorClass: OM_DISPOSE\n"));
992 /* Disable activation callback */
993 OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
995 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
996 Remove((struct Node
*)data
);
998 /* Remove this monitor from spatial links */
999 Relink(MA_BottomRightMonitor
, data
->topleft
, MA_TopLeftMonitor
, data
->bottomright
);
1000 Relink(MA_BottomMiddleMonitor
, data
->topmiddle
, MA_TopMiddleMonitor
, data
->bottommiddle
);
1001 Relink(MA_BottomLeftMonitor
, data
->topright
, MA_TopRightMonitor
, data
->bottomleft
);
1002 Relink(MA_MiddleLeftMonitor
, data
->middleright
, MA_MiddleRightMonitor
, data
->middleleft
);
1004 /* If an active monitor is being removed, we should activate another one */
1005 if (GetPrivIBase(IntuitionBase
)->ActiveMonitor
== o
)
1006 ActivateMonitor((Object
*)GetHead(&GetPrivIBase(IntuitionBase
)->MonitorList
), -1, -1, IntuitionBase
);
1008 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
1011 FreeMem(data
->gamma
, 256 * 3);
1013 return DoSuperMethodA(cl
, o
, msg
);
1016 /*i***************************************************************************
1022 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat,
1023 struct BitMap **Store);
1025 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
1030 This method is provided only for source code compatibility with the
1031 MorphOS operating system.
1033 Under MorphOS this method returns a pointer to internal root bitmap of
1034 the display driver corresponding to the specified pixelformat.
1035 Displayable bitmaps are supposed to be created as friends of the root
1038 In AROS displayable bitmaps need complete display mode information and
1039 not only pixelformat. So this method will never be implemented and will
1040 always return a NULL pointer. In order to create a displayable RTG
1041 bitmap on AROS the user needs to supply a taglist with
1042 BMATags_DisplayID specification to the AllocBitMap() function.
1045 obj - A monitor object
1046 MethodID - MM_GetRootBitMap
1047 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1048 Store - A storage where root bitmap pointer will be placed.
1060 graphics.library/AllocBitMap()
1064 *****************************************************************************/
1066 IPTR
MonitorClass__MM_GetRootBitMap(Class
*cl
, Object
*obj
, struct msGetRootBitMap
*msg
)
1073 /*i***************************************************************************
1079 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1081 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1086 Ask the display driver for type of 3D support for the given
1089 Supplied storage will be filled with one of:
1090 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1091 MSQUERY3D_NODRIVER - There is no 3D support for the given
1093 MSQUERY3D_SWDRIVER - A software 3D support is available for the
1095 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the
1099 obj - A monitor object to query
1100 MethodID - MM_Query3DSupport
1101 PixelFormat - A CyberGraphX pixelformat code
1102 Store - A pointer to a storage where return value will be placed
1117 *****************************************************************************/
1119 IPTR
MonitorClass__MM_Query3DSupport(Class
*cl
, Object
*obj
, struct msQuery3DSupport
*msg
)
1121 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1122 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1123 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1124 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1125 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1126 OOP_Object
*pf
= data
->pfobjects
[msg
->PixelFormat
];
1129 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, pf
))
1130 *msg
->Store
= MSQUERY3D_HWDRIVER
;
1134 OOP_GetAttr(pf
, aHidd_PixFmt_Depth
, &depth
);
1136 *msg
->Store
= MSQUERY3D_SWDRIVER
;
1138 *msg
->Store
= MSQUERY3D_NODRIVER
;
1141 *msg
->Store
= MSQUERY3D_UNKNOWN
;
1146 /*i***************************************************************************
1149 MM_GetDefaultGammaTables
1152 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1155 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1160 Get default gamma correction tables for the monitor.
1163 obj - A monitor object to query
1164 MethodID - MM_GetDefaultGammaTables
1165 Red - A pointer to an array of 256 bytes where gamma correction
1166 data for the red component will be placed. You may specify
1167 a NULL pointer in order to ignore this component.
1168 Green - A pointer to an array of 256 bytes where gamma correction
1169 data for the green component will be placed. You may
1170 specify a NULL pointer in order to ignore this component.
1171 Blue - A pointer to an array of 256 bytes where gamma correction
1172 data for the blue component will be placed. You may specify
1173 a NULL pointer in order to ignore this component.
1185 MM_SetDefaultGammaTables
1189 *****************************************************************************/
1191 void MonitorClass__MM_GetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msGetDefaultGammaTables
*msg
)
1193 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1198 CopyMem(&data
->gamma
[GAMMA_R
], msg
->Red
, 256);
1200 CopyMem(&data
->gamma
[GAMMA_G
], msg
->Green
, 256);
1202 CopyMem(&data
->gamma
[GAMMA_B
], msg
->Blue
, 256);
1206 /*i***************************************************************************
1209 MM_GetDefaultPixelFormat
1212 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1214 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1219 Get the driver's preferred pixelformat for the specified bitmap depth.
1222 obj - A monitor object
1223 MethodID - MM_GetDefaultPixelFormat
1224 Depth - Depth to ask about
1225 Store - A pointer to an ULONG location where CyberGraphX
1226 pixelformat number will be placed. -1 means unsupported
1242 *****************************************************************************/
1244 IPTR
MonitorClass__MM_GetDefaultPixelFormat(Class
*cl
, Object
*obj
, struct msGetDefaultPixelFormat
*msg
)
1246 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1247 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1248 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1249 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1252 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++) {
1253 if (data
->pfobjects
[i
]) {
1256 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1257 if (depth
== msg
->Depth
) {
1264 if (i
== MONITOR_MAXPIXELFORMATS
)
1270 /*i***************************************************************************
1276 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width,
1279 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1285 Get the maximum allowed size of a mouse pointer sprite.
1288 obj - A monitor object
1289 MethodID - MM_GetPointerBounds
1290 PointerType - Pointer type (one of PointerType_...)
1291 Width - A pointer to an ULONG location where width will be
1293 Height - A pointer to an ULONG location where height will be
1297 FALSE is given pointer type is not supported, TRUE otherwise.
1300 Width and Height are considered undefined if the method returns FALSE.
1311 *****************************************************************************/
1313 IPTR
MonitorClass__MM_GetPointerBounds(Class
*cl
, Object
*obj
, struct msGetPointerBounds
*msg
)
1315 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1316 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1317 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1319 return HIDD_Gfx_GetMaxSpriteSize(data
->handle
->gfxhidd
, msg
->PointerType
, msg
->Width
, msg
->Height
);
1322 /*i***************************************************************************
1328 DoMethod(Object *obj, ULONG MethodID);
1330 DoMethodA(Object *obj, Msg *msg);
1335 Starts screensaver on the monitor.
1337 At the moment AROS has no integrated screensaver support. The method
1338 is considered reserved and not implemented.
1341 obj - A monitor object
1342 MethodID - MM_RunBlanker
1354 MM_EnterPowerSaveMode, MM_ExitBlanker
1358 *****************************************************************************/
1360 IPTR
MonitorClass__MM_RunBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1362 /* We have no integrated screensaver support */
1367 /*i***************************************************************************
1370 MM_EnterPowerSaveMode
1373 DoMethod(Object *obj, ULONG MethodID);
1375 DoMethodA(Object *obj, Msg *msg);
1380 Starts power saving mode on the monitor.
1383 obj - A monitor object
1384 MethodID - MM_EnterPowerSaveMode
1396 MM_RunBlanker, MM_ExitBlanker
1399 Current implementation just immediately sets DMPS level to "Off" for
1402 *****************************************************************************/
1404 IPTR
MonitorClass__MM_EnterPowerSaveMode(Class
*cl
, Object
*obj
, Msg
*msg
)
1406 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1407 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1408 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1409 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1410 struct TagItem tags
[] =
1412 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_Off
},
1416 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1419 /*i***************************************************************************
1425 DoMethod(Object *obj, ULONG MethodID);
1427 DoMethodA(Object *obj, Msg *msg);
1432 Stops screensaver and/or power saving mode on the monitor.
1435 obj - A monitor object
1436 MethodID - MM_ExitBlanker
1448 MM_EnterPowerSaveMode, MM_RunBlanker
1452 *****************************************************************************/
1454 IPTR
MonitorClass__MM_ExitBlanker(Class
*cl
, Object
*obj
, Msg
*msg
)
1456 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1457 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1458 OOP_AttrBase HiddGfxAttrBase
= GetPrivIBase(IntuitionBase
)->HiddGfxAttrBase
;
1459 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1460 struct TagItem tags
[] =
1462 {aHidd_Gfx_DPMSLevel
, vHidd_Gfx_DPMSLevel_On
},
1466 return OOP_SetAttrs(data
->handle
->gfxhidd
, tags
);
1469 /*i***************************************************************************
1472 MM_SetDefaultGammaTables
1475 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green,
1478 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1483 Set default gamma correction tables for the monitor.
1486 obj - A monitor object to query
1487 MethodID - MM_GetDefaultGammaTables
1488 Red - A pointer to an array of 256 bytes where gamma correction
1489 data for the red component is placed. You may specify a
1490 NULL pointer in order to ignore this component.
1491 Green - A pointer to an array of 256 bytes where gamma correction
1492 data for the green component is placed. You may specify a
1493 NULL pointer in order to ignore this component.
1494 Blue - A pointer to an array of 256 bytes where gamma correction
1495 data for the blue component is placed. You may specify a
1496 NULL pointer in order to ignore this component.
1502 This method is AROS-specific.
1509 MM_GetDefaultGammaTables
1513 *****************************************************************************/
1515 IPTR
MonitorClass__MM_SetDefaultGammaTables(Class
*cl
, Object
*obj
, struct msSetDefaultGammaTables
*msg
)
1517 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1518 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1525 CopyMem(msg
->Red
, &data
->gamma
[GAMMA_R
], 256);
1527 CopyMem(msg
->Green
, &data
->gamma
[GAMMA_G
], 256);
1529 CopyMem(msg
->Blue
, &data
->gamma
[GAMMA_B
], 256);
1531 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1533 if (data
->screenGamma
== 3)
1536 * All three components are determined by screen.
1544 * This monitor currently uses default gamma table.
1547 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1549 ret
= HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1552 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1559 /*i**************************************************************************/
1561 ULONG
MonitorClass__MM_GetCompositionFlags(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1563 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1564 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1565 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1566 struct HIDD_ModeProperties modeprops
;
1568 HIDD_Gfx_ModeProperties(data
->handle
->gfxhidd
, msg
->ModeID
& (!data
->handle
->mask
),
1569 &modeprops
, sizeof(modeprops
));
1570 return modeprops
.CompositionFlags
;
1573 /*i**************************************************************************/
1575 void MonitorClass__MM_SetPointerPos(Class
*cl
, Object
*obj
, struct msSetPointerPos
*msg
)
1577 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1578 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1580 data
->mouseX
= msg
->x
;
1581 data
->mouseY
= msg
->y
;
1582 SetPointerPos(data
, IntuitionBase
);
1585 /*i**************************************************************************/
1587 IPTR
MonitorClass__MM_CheckID(Class
*cl
, Object
*obj
, struct msGetCompositionFlags
*msg
)
1589 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1591 return ((msg
->ModeID
& data
->handle
->mask
) == data
->handle
->id
);
1594 /*i**************************************************************************/
1596 IPTR
MonitorClass__MM_SetPointerShape(Class
*cl
, Object
*obj
, struct msSetPointerShape
*msg
)
1598 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1599 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1600 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1604 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg
->pointer
, data
->pointer
));
1605 /* Don't do anything if already set */
1606 if (data
->pointer
== msg
->pointer
)
1609 bm
= msg
->pointer
->sprite
->es_BitMap
;
1610 /* Currently we don't work with non-hidd sprites */
1611 if (!IS_HIDD_BM(bm
))
1614 res
= HIDD_Gfx_SetCursorShape(data
->handle
->gfxhidd
, HIDD_BM_OBJ(bm
), msg
->pointer
->xoffset
, msg
->pointer
->yoffset
);
1615 D(bug("[monitorclass] SetPointerShape() returned %d\n", res
));
1617 data
->pointer
= msg
->pointer
;
1618 /* This will fix up sprite position if hotspot changed */
1619 SetPointerPos(data
, IntuitionBase
);
1625 void MonitorClass__MM_SetScreenGamma(Class
*cl
, Object
*obj
, struct msSetScreenGamma
*msg
)
1627 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1631 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1632 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1633 struct GammaControl
*gamma
= msg
->gamma
;
1635 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1639 UBYTE screengamma
= 0;
1642 if (gamma
->UseGammaControl
)
1644 if (gamma
->GammaTableR
)
1646 data
->active_r
= gamma
->GammaTableR
;
1649 if (gamma
->GammaTableB
)
1651 data
->active_b
= gamma
->GammaTableB
;
1654 if (gamma
->GammaTableG
)
1656 data
->active_g
= gamma
->GammaTableG
;
1662 * The condition here reflects the following variants:
1663 * 1. We used default gamma and switched to custom one.
1664 * 2. We used custom gamma and switched to default one.
1665 * 3. We changed custom gamma.
1667 if (data
->screenGamma
|| screengamma
|| msg
->force
)
1669 data
->screenGamma
= screengamma
;
1670 HIDD_Gfx_SetGamma(data
->handle
->gfxhidd
, data
->active_r
, data
->active_g
, data
->active_b
);
1674 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->ViewLordLock
);
1679 * Find the best (closest to the given) depth with 3D support.
1680 * This method will give the priority to hardware 3D.
1682 ULONG
MonitorClass__MM_FindBest3dDepth(Class
*cl
, Object
*obj
, struct msFindBest3dDepth
*msg
)
1684 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1685 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1686 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1687 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1688 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1692 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1694 if (data
->pfobjects
[i
])
1698 OOP_GetAttr(data
->pfobjects
[i
], aHidd_PixFmt_Depth
, &depth
);
1700 if (depth
< msg
->depth
)
1702 /* Skip all pixelformats with depth less than requested */
1706 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1708 /* Found hardware 3D ? Good. */
1712 if ((depth
> 8) && (swdepth
== -1))
1714 /* This remembers the first depth suitable for software 3D */
1724 * Calculate 3D capability index.
1725 * Used for finding the best 3D monitor.
1727 ULONG
MonitorClass__MM_Calc3dCapability(Class
*cl
, Object
*obj
, Msg msg
)
1729 struct IntuitionBase
*IntuitionBase
= (struct IntuitionBase
*)cl
->cl_UserData
;
1730 struct Library
*OOPBase
= GetPrivIBase(IntuitionBase
)->OOPBase
;
1731 OOP_MethodID HiddGfxBase
= GetPrivIBase(IntuitionBase
)->ib_HiddGfxBase
;
1732 OOP_AttrBase HiddPixFmtAttrBase
= GetPrivIBase(IntuitionBase
)->HiddPixFmtAttrBase
;
1733 struct IMonitorNode
*data
= INST_DATA(cl
, obj
);
1737 for (i
= 0; i
< MONITOR_MAXPIXELFORMATS
; i
++)
1739 if (data
->pfobjects
[i
])
1741 if (HIDD_Gfx_QueryHardware3D(data
->handle
->gfxhidd
, data
->pfobjects
[i
]))
1744 * Each HW 3D mode scores 2.
1745 * As a result, monitor with one HW 3D mode will beat SW-only 3D.
1749 else if (OOP_GET(data
->pfobjects
[i
], aHidd_PixFmt_Depth
) > 8)
1751 /* Any number of SW 3D modes scores 1 */