Minor fixes to comments.
[AROS.git] / rom / intuition / monitorclass.c
blobf21a57501b681d9a76af3d5bafb74ccaf58b6c65
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <cybergraphx/cybergraphics.h>
8 #include <hidd/graphics.h>
9 #include <hidd/hidd.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 /*****************************************************************************************
29 NAME
30 --background--
32 LOCATION
33 MONITORCLASS
35 NOTES
36 In AROS display drivers have associated BOOPSI objects of MONITORCLASS class.
37 This class provides information about relative physical placement of monitors
38 in user's workspace as well as some additional properties.
40 MONITORCLASS is a pseudo name. This class is in fact private to the system and
41 does not have a public ID. The user can't create objects of this class manually.
43 This class is fully compatible with MorphOS starting from v2.6.
45 *****************************************************************************************/
47 Object *DisplayDriverNotify(APTR obj, BOOL add, struct IntuitionBase *IntuitionBase)
49 if (add)
51 Object *mon = NewObject(GetPrivIBase(IntuitionBase)->monitorclass, NULL, MA_MonitorHandle, obj, TAG_DONE);
53 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon));
54 if (mon) {
55 /* Install default mouse pointer on the new monitor */
56 Object *ptr = GetPrivIBase(IntuitionBase)->DefaultPointer;
58 if (ptr) {
59 struct SharedPointer *pointer;
61 GetAttr(POINTERA_SharedPointer, ptr, (IPTR *)&pointer);
62 DoMethod(mon, MM_SetPointerShape, pointer);
66 return mon;
68 else
70 DisposeObject(obj);
71 return NULL;
75 /***********************************************************************************/
77 static void SetPointerPos(struct MonitorData *data, struct IntuitionBase *IntuitionBase)
79 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
80 ULONG x = data->mouseX;
81 ULONG y = data->mouseY;
83 DB2(bug("[monitorclass] SetPointerPos(%d, %d), pointer 0x%p\n", x, y, data->pointer));
84 if (data->pointer)
86 /* Update sprite position, just for backwards compatibility */
87 data->pointer->sprite->es_SimpleSprite.x = x;
88 data->pointer->sprite->es_SimpleSprite.y = y;
91 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x, y));
92 HIDD_Gfx_SetCursorPos(data->handle->gfxhidd, x, y);
95 /***********************************************************************************/
97 static void ActivationHandler(Object *mon, OOP_Object *bitmap)
99 Class *cl = OCLASS(mon);
100 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
102 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
103 GetPrivIBase(IntuitionBase)->NewMonitor = mon;
106 /***********************************************************************************/
108 static BYTE const pixelformats[] = {
112 PIXFMT_RGB24,
113 PIXFMT_BGR24,
114 PIXFMT_RGB16,
115 PIXFMT_RGB16PC,
116 PIXFMT_BGR16,
117 PIXFMT_BGR16PC,
118 PIXFMT_RGB15,
119 PIXFMT_RGB15PC,
120 PIXFMT_BGR15,
121 PIXFMT_BGR15PC,
122 PIXFMT_ARGB32,
123 PIXFMT_BGRA32,
124 PIXFMT_RGBA32,
126 PIXFMT_ARGB32,
127 PIXFMT_BGRA32,
128 PIXFMT_RGBA32,
130 PIXFMT_LUT8,
134 Object *MonitorClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
136 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
137 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
138 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
139 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
140 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
141 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
142 struct MonitorHandle *handle = (struct MonitorHandle *)GetTagData(MA_MonitorHandle, 0, msg->ops_AttrList);
143 HIDDT_ModeID mode = vHidd_ModeID_Invalid;
144 struct MonitorData *data;
145 OOP_Object *sync, *pixfmt;
146 /* Tags order is important because CallBackData needs to be set before
147 function pointer. Otherwise the function can be called with a wrong
148 pointer. */
149 struct TagItem tags[] = {
150 {aHidd_Gfx_ActiveCallBackData, 0 },
151 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
152 {TAG_DONE , 0 }
155 D(kprintf("[monitorclass] OM_NEW\n"));
157 if (!handle)
158 return NULL;
160 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
161 if (!o)
162 return NULL;
164 data = INST_DATA(cl, o);
166 data->handle = handle;
168 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
169 just some pixelformats will be processed more than once */
170 while ((mode = HIDD_Gfx_NextModeID(handle->gfxhidd, mode, &sync, &pixfmt)) != vHidd_ModeID_Invalid) {
171 IPTR stdpf;
172 BYTE cgxpf;
174 OOP_GetAttr(pixfmt, aHidd_PixFmt_StdPixFmt, &stdpf);
175 cgxpf = pixelformats[stdpf];
176 D(bug("[monitorclass] Mode 0x%08lX, StdPixFmt %lu, CGX pixfmt %d\n", mode, stdpf, cgxpf));
178 if (cgxpf != -1) {
179 data->pfobjects[cgxpf] = pixfmt;
180 data->pixelformats[cgxpf] = TRUE;
184 tags[0].ti_Data = (IPTR)o;
185 OOP_SetAttrs(handle->gfxhidd, tags);
187 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
188 AddTail((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, (struct Node *)data);
189 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
191 return o;
194 /*****************************************************************************************
196 NAME
197 MA_MonitorName
199 SYNOPSIS
200 [..G], STRPTR
202 LOCATION
203 MONITORCLASS
205 FUNCTION
206 Query monitor driver name
208 NOTES
210 EXAMPLE
212 BUGS
214 SEE ALSO
216 INTERNALS
218 *****************************************************************************************/
220 /*****************************************************************************************
222 NAME
223 MA_Manufacturer
225 SYNOPSIS
226 [..G], STRPTR
228 LOCATION
229 MONITORCLASS
231 FUNCTION
232 Query video card hardware manufacturer name
234 NOTES
235 Not all drivers may specify manufacturer string. NULL is a valid return value.
237 EXAMPLE
239 BUGS
241 SEE ALSO
243 INTERNALS
245 *****************************************************************************************/
247 /*****************************************************************************************
249 NAME
250 MA_ManufacturerID
252 SYNOPSIS
253 [..G], ULONG
255 LOCATION
256 MONITORCLASS
258 FUNCTION
259 Query video card hardware's numeric manufacturer ID (which may come from PCI,
260 Zorro, etc).
262 NOTES
263 Not all drivers may have assigned IDs. For example VGA driver and virtual
264 hosted drivers do not associate themselves with any IDs.
266 EXAMPLE
268 BUGS
270 SEE ALSO
271 MA_ProductID
273 INTERNALS
275 *****************************************************************************************/
277 /*****************************************************************************************
279 NAME
280 MA_ProductID
282 SYNOPSIS
283 [..G], ULONG
285 LOCATION
286 MONITORCLASS
288 FUNCTION
289 Query video card hardware's numeric product ID (which may come from PCI, Zorro, etc).
291 NOTES
292 Not all drivers may have assigned IDs. For example VGA driver and virtual
293 hosted drivers do not associate themselves with any IDs.
295 EXAMPLE
297 BUGS
299 SEE ALSO
300 MA_ManufacturerID
302 INTERNALS
304 *****************************************************************************************/
306 /*****************************************************************************************
308 NAME
309 MA_MemorySize
311 SYNOPSIS
312 [..G], ULONG
314 LOCATION
315 MONITORCLASS
317 FUNCTION
318 Query total size of video card memory in bytes.
320 NOTES
322 EXAMPLE
324 BUGS
326 SEE ALSO
327 MA_MemoryClock
329 INTERNALS
331 *****************************************************************************************/
333 /*****************************************************************************************
335 NAME
336 MA_PixelFormats
338 SYNOPSIS
339 [..G], ULONG *
341 LOCATION
342 MONITORCLASS
344 FUNCTION
345 Query table of supported pixelformats.
347 A returned value is a pointer to static array of ULONGs, one ULONG per CyberGraphX
348 pixelformat. Values of these ULONGs are actually booleans. TRUE value in the array
349 says that the pixelformat is supported, FALSE means it's not.
351 NOTES
353 EXAMPLE
354 ULONG *pfs;
356 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
357 if (pfs[PUXFMT_LUT8])
358 printf("The display driver supports LUT8 format\n");
360 BUGS
362 SEE ALSO
363 MA_ManufacturerID
365 INTERNALS
367 *****************************************************************************************/
369 /*****************************************************************************************
371 NAME
372 MA_TopLeftMonitor
374 SYNOPSIS
375 [.SG], Object *
377 LOCATION
378 MONITORCLASS
380 FUNCTION
381 Get a pointer to a monitor placed in top-left diagonal direction relative to
382 the current one.
384 This attribute is used to describe relative placement of monitors in user's
385 physical environment.
387 NOTES
389 EXAMPLE
391 BUGS
392 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
393 monitor object.
395 SEE ALSO
396 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
397 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
399 INTERNALS
401 *****************************************************************************************/
403 /*****************************************************************************************
405 NAME
406 MA_TopMiddleMonitor
408 SYNOPSIS
409 [.SG], Object *
411 LOCATION
412 MONITORCLASS
414 FUNCTION
415 Get a pointer to a monitor placed in top direction relative to the current one.
417 This attribute is used to describe relative placement of monitors in user's
418 physical environment.
420 NOTES
422 EXAMPLE
424 BUGS
425 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
426 monitor object.
428 SEE ALSO
429 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
430 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
432 INTERNALS
434 *****************************************************************************************/
436 /*****************************************************************************************
438 NAME
439 MA_TopRightMonitor
441 SYNOPSIS
442 [.SG], Object *
444 LOCATION
445 MONITORCLASS
447 FUNCTION
448 Get a pointer to a monitor placed in top-right diagonal direction relative to
449 the current one.
451 This attribute is used to describe relative placement of monitors in user's
452 physical environment.
454 NOTES
456 EXAMPLE
458 BUGS
459 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
460 monitor object.
462 SEE ALSO
463 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
464 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
466 INTERNALS
468 *****************************************************************************************/
470 /*****************************************************************************************
472 NAME
473 MA_MiddleLeftMonitor
475 SYNOPSIS
476 [.SG], Object *
478 LOCATION
479 MONITORCLASS
481 FUNCTION
482 Get a pointer to a monitor placed in left direction relative to
483 the current one.
485 This attribute is used to describe relative placement of monitors in user's
486 physical environment.
488 NOTES
490 EXAMPLE
492 BUGS
493 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
494 monitor object.
496 SEE ALSO
497 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleRightMonitor,
498 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
500 INTERNALS
502 *****************************************************************************************/
504 /*****************************************************************************************
506 NAME
507 MA_MiddleRightMonitor
509 SYNOPSIS
510 [.SG], Object *
512 LOCATION
513 MONITORCLASS
515 FUNCTION
516 Get a pointer to a monitor placed in right direction relative to
517 the current one.
519 This attribute is used to describe relative placement of monitors in user's
520 physical environment.
522 NOTES
524 EXAMPLE
526 BUGS
527 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
528 monitor object.
530 SEE ALSO
531 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
532 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
534 INTERNALS
536 *****************************************************************************************/
538 /*****************************************************************************************
540 NAME
541 MA_BottomLeftMonitor
543 SYNOPSIS
544 [.SG], Object *
546 LOCATION
547 MONITORCLASS
549 FUNCTION
550 Get a pointer to a monitor placed in bottom-left diagonal direction relative to
551 the current one.
553 This attribute is used to describe relative placement of monitors in user's
554 physical environment.
556 NOTES
558 EXAMPLE
560 BUGS
561 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
562 monitor object.
564 SEE ALSO
565 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
566 MA_MiddleRightMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
568 INTERNALS
570 *****************************************************************************************/
572 /*****************************************************************************************
574 NAME
575 MA_BottomMiddleMonitor
577 SYNOPSIS
578 [.SG], Object *
580 LOCATION
581 MONITORCLASS
583 FUNCTION
584 Get a pointer to a monitor placed in bottom direction relative to the current one.
586 This attribute is used to describe relative placement of monitors in user's
587 physical environment.
589 NOTES
591 EXAMPLE
593 BUGS
594 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
595 monitor object.
597 SEE ALSO
598 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
599 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomRightMonitor
601 INTERNALS
603 *****************************************************************************************/
605 /*****************************************************************************************
607 NAME
608 MA_BottomRightMonitor
610 SYNOPSIS
611 [.SG], Object *
613 LOCATION
614 MONITORCLASS
616 FUNCTION
617 Get a pointer to a monitor placed in bottom-right diagonal direction relative to
618 the current one.
620 This attribute is used to describe relative placement of monitors in user's
621 physical environment.
623 NOTES
625 EXAMPLE
627 BUGS
628 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
629 monitor object.
631 SEE ALSO
632 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
633 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor
635 INTERNALS
637 *****************************************************************************************/
639 /*****************************************************************************************
641 NAME
642 MA_GammaControl
644 SYNOPSIS
645 [..G], BOOL
647 LOCATION
648 MONITORCLASS
650 FUNCTION
651 Query if the display driver supports gamma control
653 NOTES
655 EXAMPLE
657 BUGS
659 SEE ALSO
660 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
662 INTERNALS
664 *****************************************************************************************/
666 /*****************************************************************************************
668 NAME
669 MA_PointerType
671 SYNOPSIS
672 [..G], ULONG
674 LOCATION
675 MONITORCLASS
677 FUNCTION
678 Query supported mouse pointer sprite formats.
680 The returned value is a combination of the following bit flags:
681 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm) chipset sprite)
682 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for example clear or
683 inverse), 2-3 visible
684 PointerType_ARGB - Direct color bitmap (hi-color or truecolor, possibly with alpha
685 channel
687 NOTES
689 EXAMPLE
691 BUGS
693 SEE ALSO
694 MM_GetPointerBounds
696 INTERNALS
698 *****************************************************************************************/
700 /*****************************************************************************************
702 NAME
703 MA_DriverName
705 SYNOPSIS
706 [..G], STRPTR
708 LOCATION
709 MONITORCLASS
711 FUNCTION
712 Query CyberGraphX driver name. It is the name which can be given to
713 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName value.
715 NOTES
717 EXAMPLE
719 BUGS
721 SEE ALSO
722 MM_GetPointerBounds
724 INTERNALS
726 *****************************************************************************************/
728 /*****************************************************************************************
730 NAME
731 MA_MemoryClock
733 SYNOPSIS
734 [..G], ULONG
736 LOCATION
737 MONITORCLASS
739 FUNCTION
740 Query video card's memory clock in Hz. 0 is a valid value meaning 'unknown'.
742 NOTES
744 EXAMPLE
746 BUGS
748 SEE ALSO
749 MA_MemorySize
751 INTERNALS
753 *****************************************************************************************/
755 /*****************************************************************************************
757 NAME
758 MA_Windowed
760 SYNOPSIS
761 [..G], BOOL
763 LOCATION
764 MONITORCLASS
766 FUNCTION
767 Check if this monitor is a window on hosted OS desktop.
769 This means that the host OS is responsible for handling mouse input and display
770 activation. Monitors with this attribute set to TRUE should be ignored by
771 multi-display desktop configuration software.
773 These monitors should have no spatial links to other monitors. Activation of these
774 monitors is done by clicking on their windows on the host's desktop and is handled
775 by the driver itself.
777 NOTES
778 This attribute is AROS-specific, it does not exist in MorphOS.
780 EXAMPLE
782 BUGS
784 SEE ALSO
786 INTERNALS
788 *****************************************************************************************/
790 /***********************************************************************************/
792 IPTR MonitorClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
794 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
795 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
796 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
797 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
798 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
799 struct MonitorData *data = INST_DATA(cl, o);
801 D(kprintf("[monitorclass] OM_GET\n"));
803 switch (msg->opg_AttrID)
805 case MA_MonitorName:
806 OOP_GetAttr(data->handle->gfxhidd, aHidd_Name, msg->opg_Storage);
807 break;
809 case MA_Manufacturer:
810 OOP_GetAttr(data->handle->gfxhidd, aHidd_ProducerName, msg->opg_Storage);
811 break;
813 case MA_ManufacturerID:
814 OOP_GetAttr(data->handle->gfxhidd, aHidd_Producer, msg->opg_Storage);
815 break;
817 case MA_ProductID:
818 OOP_GetAttr(data->handle->gfxhidd, aHidd_Product, msg->opg_Storage);
819 break;
821 case MA_MemorySize:
822 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemorySize, msg->opg_Storage);
823 break;
825 case MA_PixelFormats:
826 *msg->opg_Storage = (IPTR)data->pixelformats;
827 break;
829 case MA_TopLeftMonitor:
830 *msg->opg_Storage = (IPTR)data->topleft;
831 break;
833 case MA_TopMiddleMonitor:
834 *msg->opg_Storage = (IPTR)data->topmiddle;
835 break;
837 case MA_TopRightMonitor:
838 *msg->opg_Storage = (IPTR)data->topright;
839 break;
841 case MA_MiddleLeftMonitor:
842 *msg->opg_Storage = (IPTR)data->middleleft;
843 break;
845 case MA_MiddleRightMonitor:
846 *msg->opg_Storage = (IPTR)data->middleright;
847 break;
849 case MA_BottomLeftMonitor:
850 *msg->opg_Storage = (IPTR)data->bottomleft;
851 break;
853 case MA_BottomMiddleMonitor:
854 *msg->opg_Storage = (IPTR)data->bottommiddle;
855 break;
857 case MA_BottomRightMonitor:
858 *msg->opg_Storage = (IPTR)data->bottomright;
859 break;
861 case MA_GammaControl:
862 *msg->opg_Storage = HIDD_Gfx_GetGamma(data->handle->gfxhidd, NULL, NULL, NULL);
863 break;
865 case MA_PointerType:
866 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, msg->opg_Storage);
867 break;
869 case MA_DriverName:
870 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_DriverName, msg->opg_Storage);
871 break;
873 case MA_MemoryClock:
874 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemoryClock, msg->opg_Storage);
875 break;
877 case MA_Windowed:
878 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_IsWindowed, msg->opg_Storage);
879 break;
881 default:
882 return DoSuperMethodA(cl, o, (Msg)msg);
885 return TRUE;
888 /***********************************************************************************/
890 IPTR MonitorClass__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 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
895 struct MonitorData *data = INST_DATA(cl, o);
896 struct TagItem *tag, *tstate;
898 tstate = msg->ops_AttrList;
899 while((tag = NextTagItem(&tstate))) {
900 switch (tag->ti_Tag) {
901 case MA_TopLeftMonitor:
902 data->topleft = (Object *)tag->ti_Data;
903 break;
905 case MA_TopMiddleMonitor:
906 data->topmiddle = (Object *)tag->ti_Data;
907 break;
909 case MA_TopRightMonitor:
910 data->topright = (Object *)tag->ti_Data;
911 break;
913 case MA_MiddleLeftMonitor:
914 data->middleleft = (Object *)tag->ti_Data;
915 break;
917 case MA_MiddleRightMonitor:
918 data->middleright = (Object *)tag->ti_Data;
919 break;
921 case MA_BottomLeftMonitor:
922 data->bottomleft = (Object *)tag->ti_Data;
923 break;
925 case MA_BottomMiddleMonitor:
926 data->bottommiddle = (Object *)tag->ti_Data;
927 break;
929 case MA_BottomRightMonitor:
930 data->bottomright = (Object *)tag->ti_Data;
931 break;
933 case MA_PointerVisible:
934 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
935 break;
938 return DoSuperMethodA(cl, o, (Msg)msg);
941 /***********************************************************************************/
943 #define Relink(nextAttr, prev, prevAttr, next) \
944 if (prev) \
945 SetAttrs(prev, nextAttr, next, TAG_DONE); \
946 if (next) \
947 SetAttrs(next, prevAttr, prev, TAG_DONE)
949 IPTR MonitorClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
951 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
952 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
953 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
954 struct MonitorData *data = INST_DATA(cl, o);
955 struct TagItem tags[] = {
956 {aHidd_Gfx_ActiveCallBack, 0},
957 {TAG_DONE , 0}
960 D(kprintf("MonitorClass: OM_DISPOSE\n"));
962 /* Disable activation callback */
963 OOP_SetAttrs(data->handle->gfxhidd, tags);
965 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
966 Remove((struct Node *)data);
968 /* Remove this monitor from spatial links */
969 Relink(MA_BottomRightMonitor, data->topleft, MA_TopLeftMonitor, data->bottomright);
970 Relink(MA_BottomMiddleMonitor, data->topmiddle, MA_TopMiddleMonitor, data->bottommiddle);
971 Relink(MA_BottomLeftMonitor, data->topright, MA_TopRightMonitor, data->bottomleft);
972 Relink(MA_MiddleLeftMonitor, data->middleright, MA_MiddleRightMonitor, data->middleleft);
974 /* If an active monitor is being removed, we should activate another one */
975 if (GetPrivIBase(IntuitionBase)->ActiveMonitor == o)
976 ActivateMonitor((Object *)GetHead(&GetPrivIBase(IntuitionBase)->MonitorList), -1, -1, IntuitionBase);
978 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
980 return DoSuperMethodA(cl, o, msg);
983 /************************************************************************************
985 NAME
986 MM_GetRootBitMap
988 SYNOPSIS
989 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, struct BitMap **Store);
991 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
993 LOCATION
995 FUNCTION
996 This method is provided only for source code compatibility with MorphOS operating
997 system.
999 Under MorphOS this method returns a pointer to internal root bitmap of the
1000 display driver corresponding to the specified pixelformat. Displayable bitmaps are
1001 supposed to be created as friends of the root bitmap.
1003 In AROS displayable bitmaps need complete display mode information and not
1004 only pixelformat. So this method will never be implemented and will always return NULL
1005 pointer. In order to create a displayable RTG bitmap on AROS the user needs to supply
1006 a taglist with BMATags_DisplayID specification to AllocBitMap() function.
1008 INPUTS
1009 obj - A monitor object
1010 MethodID - MM_GetRootBitMap
1011 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1012 Store - A storage where root bitmap pointer will be placed.
1014 RESULT
1015 Undefined.
1017 NOTES
1019 EXAMPLE
1021 BUGS
1023 SEE ALSO
1024 graphics.library/AllocBitMap()
1026 INTERNALS
1028 ************************************************************************************/
1030 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1032 *msg->Store = NULL;
1034 return 0;
1037 /************************************************************************************
1039 NAME
1040 MM_Query3DSupport
1042 SYNOPSIS
1043 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1045 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1047 LOCATION
1049 FUNCTION
1050 Ask the display driver for type of 3D support for the given pixelformat.
1052 Supplied storage will be filled with one of:
1053 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1054 MSQUERY3D_NODRIVER - There is no 3D support for the given pixelformat
1055 MSQUERY3D_SWDRIVER - A software 3D support is available for the given
1056 pixelformat
1057 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the given
1058 pixelformat
1060 INPUTS
1061 obj - A monitor object to query
1062 MethodID - MM_Query3DSupport
1063 PixelFormat - A CyberGraphX pixelformat code
1064 Store - A pointer to a storage where return value will be placed
1066 RESULT
1067 Undefined.
1069 NOTES
1071 EXAMPLE
1073 BUGS
1075 SEE ALSO
1077 INTERNALS
1079 ************************************************************************************/
1081 IPTR MonitorClass__MM_Query3DSupport(Class *cl, Object *obj, struct msQuery3DSupport *msg)
1083 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1084 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1085 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1086 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1087 struct MonitorData *data = INST_DATA(cl, obj);
1088 OOP_Object *pf = data->pfobjects[msg->PixelFormat];
1090 if (pf) {
1091 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1092 *msg->Store = MSQUERY3D_HWDRIVER;
1093 else {
1094 IPTR depth;
1096 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1097 if (depth > 8)
1098 *msg->Store = MSQUERY3D_SWDRIVER;
1099 else
1100 *msg->Store = MSQUERY3D_NODRIVER;
1102 } else
1103 *msg->Store = MSQUERY3D_UNKNOWN;
1105 return *msg->Store;
1108 /************************************************************************************
1110 NAME
1111 MM_GetDefaultGammaTables
1113 SYNOPSIS
1114 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1116 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1118 LOCATION
1120 FUNCTION
1121 Get default gamma correction tables for the monitor
1123 INPUTS
1124 obj - A monitor object to query
1125 MethodID - MM_GetDefaultGammaTables
1126 Red - A pointer to an array of 256 bytes where gamma correction data for
1127 red component will be placed. You may speciy a NULL pointer in order
1128 to ignore this component.
1129 Green - A pointer to an array of 256 bytes where gamma correction data for
1130 green component will be placed. You may speciy a NULL pointer in order
1131 to ignore this component.
1132 Blue - A pointer to an array of 256 bytes where gamma correction data for
1133 blue component will be placed. You may speciy a NULL pointer in order
1134 to ignore this component.
1136 RESULT
1137 Undefined.
1139 NOTES
1141 EXAMPLE
1143 BUGS
1145 SEE ALSO
1146 MM_SetDefaultGammaTables
1148 INTERNALS
1150 ************************************************************************************/
1152 IPTR MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1154 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1155 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1156 struct MonitorData *data = INST_DATA(cl, obj);
1158 /* Currently we don't use per-screen gamma tables, so we just forward the request
1159 to the driver.
1160 If we implement per-screen gamma correction, we'll need more sophisticated
1161 management here */
1162 return HIDD_Gfx_GetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1165 /************************************************************************************
1167 NAME
1168 MM_GetDefaultPixelFormat
1170 SYNOPSIS
1171 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1173 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1175 LOCATION
1177 FUNCTION
1178 Get driver's preferred pixelformat for specified bitmap depth.
1180 INPUTS
1181 obj - A monitor object
1182 MethodID - MM_GetDefaultPixelFormat
1183 Depth - Depth to ask about
1184 Store - A pointer to an ULONG location where CyberGraphX pixelformat
1185 number will be placed. -1 means unsupported depth.
1187 RESULT
1188 Undefined.
1190 NOTES
1192 EXAMPLE
1194 BUGS
1196 SEE ALSO
1198 INTERNALS
1200 ************************************************************************************/
1202 IPTR MonitorClass__MM_GetDefaultPixelFormat(Class *cl, Object *obj, struct msGetDefaultPixelFormat *msg)
1204 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1205 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1206 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1207 struct MonitorData *data = INST_DATA(cl, obj);
1208 ULONG i;
1210 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1211 if (data->pfobjects[i]) {
1212 IPTR depth;
1214 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1215 if (depth == msg->Depth) {
1216 *msg->Store = i;
1217 break;
1222 if (i == MONITOR_MAXPIXELFORMATS)
1223 *msg->Store = -1;
1225 return *msg->Store;
1228 /************************************************************************************
1230 NAME
1231 MM_GetPointerBounds
1233 SYNOPSIS
1234 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width, ULONG *Height);
1236 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1238 LOCATION
1239 monitorclass
1241 FUNCTION
1242 Get maximum allowed size of mouse pointer sprite.
1244 INPUTS
1245 obj - A monitor object
1246 MethodID - MM_GetPointerBounds
1247 PointerType - Pointer type (one of PointerType_...)
1248 Width - A pointer to an ULONG location where width will be placed.
1249 Height - A pointer to an ULONG location where height will be placed.
1251 RESULT
1252 FALSE is given pointer type is not supported, TRUE otherwise.
1254 NOTES
1255 Width and Height are considered undefined if the method returns FALSE.
1257 EXAMPLE
1259 BUGS
1261 SEE ALSO
1262 MA_PointerType
1264 INTERNALS
1266 ************************************************************************************/
1268 IPTR MonitorClass__MM_GetPointerBounds(Class *cl, Object *obj, struct msGetPointerBounds *msg)
1270 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1271 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1272 struct MonitorData *data = INST_DATA(cl, obj);
1274 return HIDD_Gfx_GetMaxSpriteSize(data->handle->gfxhidd, msg->PointerType, msg->Width, msg->Height);
1277 /************************************************************************************
1279 NAME
1280 MM_RunBlanker
1282 SYNOPSIS
1283 DoMethod(Object *obj, ULONG MethodID);
1285 DoMethodA(Object *obj, Msg *msg);
1287 LOCATION
1289 FUNCTION
1290 Starts screensaver on the monitor.
1292 At the moment AROS has no integrated screensaver support. The method is
1293 considered reserved and not implemented.
1295 INPUTS
1296 obj - A monitor object
1297 MethodID - MM_RunBlanker
1299 RESULT
1300 Undefined.
1302 NOTES
1304 EXAMPLE
1306 BUGS
1308 SEE ALSO
1309 MM_EnterPowerSaveMode, MM_ExitBlanker
1311 INTERNALS
1313 ************************************************************************************/
1315 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1317 /* We have no integrated screensaver support */
1319 return FALSE;
1322 /************************************************************************************
1324 NAME
1325 MM_EnterPowerSaveMode
1327 SYNOPSIS
1328 DoMethod(Object *obj, ULONG MethodID);
1330 DoMethodA(Object *obj, Msg *msg);
1332 LOCATION
1334 FUNCTION
1335 Starts power saving mode on the monitor.
1337 INPUTS
1338 obj - A monitor object
1339 MethodID - MM_EnterPowerSaveMode
1341 RESULT
1342 Undefined.
1344 NOTES
1346 EXAMPLE
1348 BUGS
1350 SEE ALSO
1351 MM_RunBlanker, MM_ExitBlanker
1353 INTERNALS
1354 Current implementation just immediately sets DMPS level to "Off" for the
1355 monitor.
1357 ************************************************************************************/
1359 IPTR MonitorClass__MM_EnterPowerSaveMode(Class *cl, Object *obj, Msg *msg)
1361 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1362 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1363 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1364 struct MonitorData *data = INST_DATA(cl, obj);
1365 struct TagItem tags[] =
1367 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_Off},
1368 {TAG_DONE , 0 }
1371 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1374 /************************************************************************************
1376 NAME
1377 MM_ExitBlanker
1379 SYNOPSIS
1380 DoMethod(Object *obj, ULONG MethodID);
1382 DoMethodA(Object *obj, Msg *msg);
1384 LOCATION
1386 FUNCTION
1387 Stops screensaver and/or power saving mode on the monitor.
1389 INPUTS
1390 obj - A monitor object
1391 MethodID - MM_ExitBlanker
1393 RESULT
1394 Undefined.
1396 NOTES
1398 EXAMPLE
1400 BUGS
1402 SEE ALSO
1403 MM_EnterPowerSaveMode, MM_RunBlanker
1405 INTERNALS
1407 ************************************************************************************/
1409 IPTR MonitorClass__MM_ExitBlanker(Class *cl, Object *obj, Msg *msg)
1411 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1412 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1413 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1414 struct MonitorData *data = INST_DATA(cl, obj);
1415 struct TagItem tags[] =
1417 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_On},
1418 {TAG_DONE , 0 }
1421 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1424 /************************************************************************************
1426 NAME
1427 MM_SetDefaultGammaTables
1429 SYNOPSIS
1430 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1432 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1434 LOCATION
1436 FUNCTION
1437 Set default gamma correction tables for the monitor
1439 INPUTS
1440 obj - A monitor object to query
1441 MethodID - MM_GetDefaultGammaTables
1442 Red - A pointer to an array of 256 bytes where gamma correction data for
1443 red component is placed. You may speciy a NULL pointer in order
1444 to ignore this component.
1445 Green - A pointer to an array of 256 bytes where gamma correction data for
1446 green component is placed. You may speciy a NULL pointer in order
1447 to ignore this component.
1448 Blue - A pointer to an array of 256 bytes where gamma correction data for
1449 blue component is placed. You may speciy a NULL pointer in order
1450 to ignore this component.
1452 RESULT
1453 Undefined.
1455 NOTES
1456 This method is AROS-specific.
1458 EXAMPLE
1460 BUGS
1462 SEE ALSO
1463 MM_GetDefaultGammaTables
1465 INTERNALS
1467 ************************************************************************************/
1469 IPTR MonitorClass__MM_SetDefaultGammaTables(Class *cl, Object *obj, struct msSetDefaultGammaTables *msg)
1471 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1472 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1473 struct MonitorData *data = INST_DATA(cl, obj);
1475 /* Currently we don't use per-screen gamma tables, so we just forward the request
1476 to the driver.
1477 If we implement per-screen gamma correction, we'll need more sophisticated
1478 management here */
1479 return HIDD_Gfx_SetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1482 /************************************************************************************/
1484 ULONG MonitorClass__MM_GetCompositionFlags(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1486 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1487 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1488 struct MonitorData *data = INST_DATA(cl, obj);
1489 struct HIDD_ModeProperties modeprops;
1491 HIDD_Gfx_ModeProperties(data->handle->gfxhidd, msg->ModeID & (!data->handle->mask),
1492 &modeprops, sizeof(modeprops));
1493 return modeprops.CompositionFlags;
1496 /************************************************************************************/
1498 void MonitorClass__MM_SetPointerPos(Class *cl, Object *obj, struct msSetPointerPos *msg)
1500 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1501 struct MonitorData *data = INST_DATA(cl, obj);
1503 data->mouseX = msg->x;
1504 data->mouseY = msg->y;
1505 SetPointerPos(data, IntuitionBase);
1508 /************************************************************************************/
1510 IPTR MonitorClass__MM_CheckID(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1512 struct MonitorData *data = INST_DATA(cl, obj);
1514 return ((msg->ModeID & data->handle->mask) == data->handle->id);
1517 /************************************************************************************/
1519 IPTR MonitorClass__MM_SetPointerShape(Class *cl, Object *obj, struct msSetPointerShape *msg)
1521 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1522 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1523 struct MonitorData *data = INST_DATA(cl, obj);
1524 struct BitMap *bm;
1525 BOOL res;
1527 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg->pointer, data->pointer));
1528 /* Don't do anything if already set */
1529 if (data->pointer == msg->pointer)
1530 return TRUE;
1532 bm = msg->pointer->sprite->es_BitMap;
1533 /* Currently we don't work with planar sprites */
1534 if (!(bm->Flags & BMF_SPECIALFMT))
1535 return FALSE;
1537 res = HIDD_Gfx_SetCursorShape(data->handle->gfxhidd, (OOP_Object *)bm->Planes[0], msg->pointer->xoffset, msg->pointer->yoffset);
1538 D(bug("[monitorclass] SetCursorShape() returned %d\n", res));
1539 if (res) {
1540 data->pointer = msg->pointer;
1541 /* This will fix up sprite position if hotspot changed */
1542 SetPointerPos(data, IntuitionBase);
1545 return res;