Fixed typos in comments.
[AROS.git] / rom / intuition / monitorclass.c
blob0b6bfca44057b28021b87578b41135457caf9f72
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 /* Take HotSpot into account */
87 x += data->pointer->xoffset;
88 y += data->pointer->yoffset;
90 /* Update sprite position, just for backwards compatibility */
91 data->pointer->sprite->es_SimpleSprite.x = x;
92 data->pointer->sprite->es_SimpleSprite.y = y;
95 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x, y));
96 HIDD_Gfx_SetCursorPos(data->handle->gfxhidd, x, y);
99 /***********************************************************************************/
101 static void ActivationHandler(Object *mon, OOP_Object *bitmap)
103 Class *cl = OCLASS(mon);
104 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
106 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
107 GetPrivIBase(IntuitionBase)->NewMonitor = mon;
110 /***********************************************************************************/
112 static BYTE const pixelformats[] = {
116 PIXFMT_RGB24,
117 PIXFMT_BGR24,
118 PIXFMT_RGB16,
119 PIXFMT_RGB16PC,
120 PIXFMT_BGR16,
121 PIXFMT_BGR16PC,
122 PIXFMT_RGB15,
123 PIXFMT_RGB15PC,
124 PIXFMT_BGR15,
125 PIXFMT_BGR15PC,
126 PIXFMT_ARGB32,
127 PIXFMT_BGRA32,
128 PIXFMT_RGBA32,
130 PIXFMT_ARGB32,
131 PIXFMT_BGRA32,
132 PIXFMT_RGBA32,
134 PIXFMT_LUT8,
138 Object *MonitorClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
140 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
141 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
142 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
143 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
144 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
145 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
146 struct MonitorHandle *handle = (struct MonitorHandle *)GetTagData(MA_MonitorHandle, 0, msg->ops_AttrList);
147 HIDDT_ModeID mode = vHidd_ModeID_Invalid;
148 struct MonitorData *data;
149 OOP_Object *sync, *pixfmt;
150 /* Tags order is important because CallBackData needs to be set before
151 function pointer. Otherwise the function can be called with a wrong
152 pointer. */
153 struct TagItem tags[] = {
154 {aHidd_Gfx_ActiveCallBackData, 0 },
155 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
156 {TAG_DONE , 0 }
159 D(kprintf("[monitorclass] OM_NEW\n"));
161 if (!handle)
162 return NULL;
164 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
165 if (!o)
166 return NULL;
168 data = INST_DATA(cl, o);
170 data->handle = handle;
172 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
173 just some pixelformats will be processed more than once */
174 while ((mode = HIDD_Gfx_NextModeID(handle->gfxhidd, mode, &sync, &pixfmt)) != vHidd_ModeID_Invalid) {
175 IPTR stdpf;
176 BYTE cgxpf;
178 OOP_GetAttr(pixfmt, aHidd_PixFmt_StdPixFmt, &stdpf);
179 cgxpf = pixelformats[stdpf];
180 D(bug("[monitorclass] Mode 0x%08lX, StdPixFmt %lu, CGX pixfmt %d\n", mode, stdpf, cgxpf));
182 if (cgxpf != -1) {
183 data->pfobjects[cgxpf] = pixfmt;
184 data->pixelformats[cgxpf] = TRUE;
188 tags[0].ti_Data = (IPTR)o;
189 OOP_SetAttrs(handle->gfxhidd, tags);
191 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
192 AddTail((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, (struct Node *)data);
193 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
195 return o;
198 /*****************************************************************************************
200 NAME
201 MA_MonitorName
203 SYNOPSIS
204 [..G], STRPTR
206 LOCATION
207 MONITORCLASS
209 FUNCTION
210 Query monitor driver name
212 NOTES
214 EXAMPLE
216 BUGS
218 SEE ALSO
220 INTERNALS
222 *****************************************************************************************/
224 /*****************************************************************************************
226 NAME
227 MA_Manufacturer
229 SYNOPSIS
230 [..G], STRPTR
232 LOCATION
233 MONITORCLASS
235 FUNCTION
236 Query video card hardware manufacturer name
238 NOTES
239 Not all drivers may specify manufacturer string. NULL is a valid return value.
241 EXAMPLE
243 BUGS
245 SEE ALSO
247 INTERNALS
249 *****************************************************************************************/
251 /*****************************************************************************************
253 NAME
254 MA_ManufacturerID
256 SYNOPSIS
257 [..G], ULONG
259 LOCATION
260 MONITORCLASS
262 FUNCTION
263 Query video card hardware's numeric manufacturer ID (which may come from PCI,
264 Zorro, etc).
266 NOTES
267 Not all drivers may have assigned IDs. For example VGA driver and virtual
268 hosted drivers do not associate themselves with any IDs.
270 EXAMPLE
272 BUGS
274 SEE ALSO
275 MA_ProductID
277 INTERNALS
279 *****************************************************************************************/
281 /*****************************************************************************************
283 NAME
284 MA_ProductID
286 SYNOPSIS
287 [..G], ULONG
289 LOCATION
290 MONITORCLASS
292 FUNCTION
293 Query video card hardware's numeric product ID (which may come from PCI, Zorro, etc).
295 NOTES
296 Not all drivers may have assigned IDs. For example VGA driver and virtual
297 hosted drivers do not associate themselves with any IDs.
299 EXAMPLE
301 BUGS
303 SEE ALSO
304 MA_ManufacturerID
306 INTERNALS
308 *****************************************************************************************/
310 /*****************************************************************************************
312 NAME
313 MA_MemorySize
315 SYNOPSIS
316 [..G], ULONG
318 LOCATION
319 MONITORCLASS
321 FUNCTION
322 Query total size of video card memory in bytes.
324 NOTES
326 EXAMPLE
328 BUGS
330 SEE ALSO
331 MA_MemoryClock
333 INTERNALS
335 *****************************************************************************************/
337 /*****************************************************************************************
339 NAME
340 MA_PixelFormats
342 SYNOPSIS
343 [..G], ULONG *
345 LOCATION
346 MONITORCLASS
348 FUNCTION
349 Query table of supported pixelformats.
351 A returned value is a pointer to static array of ULONGs, one ULONG per CyberGraphX
352 pixelformat. Values of these ULONGs are actually booleans. TRUE value in the array
353 says that the pixelformat is supported, FALSE means it's not.
355 NOTES
357 EXAMPLE
358 ULONG *pfs;
360 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
361 if (pfs[PUXFMT_LUT8])
362 printf("The display driver supports LUT8 format\n");
364 BUGS
366 SEE ALSO
367 MA_ManufacturerID
369 INTERNALS
371 *****************************************************************************************/
373 /*****************************************************************************************
375 NAME
376 MA_TopLeftMonitor
378 SYNOPSIS
379 [.SG], Object *
381 LOCATION
382 MONITORCLASS
384 FUNCTION
385 Get a pointer to a monitor placed in top-left diagonal direction relative to
386 the current one.
388 This attribute is used to describe relative placement of monitors in user's
389 physical environment.
391 NOTES
393 EXAMPLE
395 BUGS
396 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
397 monitor object.
399 SEE ALSO
400 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
401 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
403 INTERNALS
405 *****************************************************************************************/
407 /*****************************************************************************************
409 NAME
410 MA_TopMiddleMonitor
412 SYNOPSIS
413 [.SG], Object *
415 LOCATION
416 MONITORCLASS
418 FUNCTION
419 Get a pointer to a monitor placed in top direction relative to the current one.
421 This attribute is used to describe relative placement of monitors in user's
422 physical environment.
424 NOTES
426 EXAMPLE
428 BUGS
429 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
430 monitor object.
432 SEE ALSO
433 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
434 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
436 INTERNALS
438 *****************************************************************************************/
440 /*****************************************************************************************
442 NAME
443 MA_TopRightMonitor
445 SYNOPSIS
446 [.SG], Object *
448 LOCATION
449 MONITORCLASS
451 FUNCTION
452 Get a pointer to a monitor placed in top-right diagonal direction relative to
453 the current one.
455 This attribute is used to describe relative placement of monitors in user's
456 physical environment.
458 NOTES
460 EXAMPLE
462 BUGS
463 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
464 monitor object.
466 SEE ALSO
467 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
468 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
470 INTERNALS
472 *****************************************************************************************/
474 /*****************************************************************************************
476 NAME
477 MA_MiddleLeftMonitor
479 SYNOPSIS
480 [.SG], Object *
482 LOCATION
483 MONITORCLASS
485 FUNCTION
486 Get a pointer to a monitor placed in left direction relative to
487 the current one.
489 This attribute is used to describe relative placement of monitors in user's
490 physical environment.
492 NOTES
494 EXAMPLE
496 BUGS
497 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
498 monitor object.
500 SEE ALSO
501 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleRightMonitor,
502 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
504 INTERNALS
506 *****************************************************************************************/
508 /*****************************************************************************************
510 NAME
511 MA_MiddleRightMonitor
513 SYNOPSIS
514 [.SG], Object *
516 LOCATION
517 MONITORCLASS
519 FUNCTION
520 Get a pointer to a monitor placed in right direction relative to
521 the current one.
523 This attribute is used to describe relative placement of monitors in user's
524 physical environment.
526 NOTES
528 EXAMPLE
530 BUGS
531 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
532 monitor object.
534 SEE ALSO
535 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
536 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
538 INTERNALS
540 *****************************************************************************************/
542 /*****************************************************************************************
544 NAME
545 MA_BottomLeftMonitor
547 SYNOPSIS
548 [.SG], Object *
550 LOCATION
551 MONITORCLASS
553 FUNCTION
554 Get a pointer to a monitor placed in bottom-left diagonal direction relative to
555 the current one.
557 This attribute is used to describe relative placement of monitors in user's
558 physical environment.
560 NOTES
562 EXAMPLE
564 BUGS
565 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
566 monitor object.
568 SEE ALSO
569 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
570 MA_MiddleRightMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
572 INTERNALS
574 *****************************************************************************************/
576 /*****************************************************************************************
578 NAME
579 MA_BottomMiddleMonitor
581 SYNOPSIS
582 [.SG], Object *
584 LOCATION
585 MONITORCLASS
587 FUNCTION
588 Get a pointer to a monitor placed in bottom direction relative to the current one.
590 This attribute is used to describe relative placement of monitors in user's
591 physical environment.
593 NOTES
595 EXAMPLE
597 BUGS
598 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
599 monitor object.
601 SEE ALSO
602 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
603 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomRightMonitor
605 INTERNALS
607 *****************************************************************************************/
609 /*****************************************************************************************
611 NAME
612 MA_BottomRightMonitor
614 SYNOPSIS
615 [.SG], Object *
617 LOCATION
618 MONITORCLASS
620 FUNCTION
621 Get a pointer to a monitor placed in bottom-right diagonal direction relative to
622 the current one.
624 This attribute is used to describe relative placement of monitors in user's
625 physical environment.
627 NOTES
629 EXAMPLE
631 BUGS
632 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
633 monitor object.
635 SEE ALSO
636 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
637 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor
639 INTERNALS
641 *****************************************************************************************/
643 /*****************************************************************************************
645 NAME
646 MA_GammaControl
648 SYNOPSIS
649 [..G], BOOL
651 LOCATION
652 MONITORCLASS
654 FUNCTION
655 Query if the display driver supports gamma control
657 NOTES
659 EXAMPLE
661 BUGS
663 SEE ALSO
664 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
666 INTERNALS
668 *****************************************************************************************/
670 /*****************************************************************************************
672 NAME
673 MA_PointerType
675 SYNOPSIS
676 [..G], ULONG
678 LOCATION
679 MONITORCLASS
681 FUNCTION
682 Query supported mouse pointer sprite formats.
684 The returned value is a combination of the following bit flags:
685 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm) chipset sprite)
686 PointerType_2Plus1 - color 0 transparent, 1 undefined (can be for example clear or
687 inverse), 2-3 visible
688 PointerType_ARGB - Direct color bitmap (hi-color or truecolor, possibly with alpha
689 channel
691 NOTES
693 EXAMPLE
695 BUGS
697 SEE ALSO
698 MM_GetPointerBounds
700 INTERNALS
702 *****************************************************************************************/
704 /*****************************************************************************************
706 NAME
707 MA_DriverName
709 SYNOPSIS
710 [..G], STRPTR
712 LOCATION
713 MONITORCLASS
715 FUNCTION
716 Query CyberGraphX driver name. It is the name which can be given to
717 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName value.
719 NOTES
721 EXAMPLE
723 BUGS
725 SEE ALSO
726 MM_GetPointerBounds
728 INTERNALS
730 *****************************************************************************************/
732 /*****************************************************************************************
734 NAME
735 MA_MemoryClock
737 SYNOPSIS
738 [..G], ULONG
740 LOCATION
741 MONITORCLASS
743 FUNCTION
744 Query video card's memory clock in Hz. 0 is a valid value meaning 'unknown'.
746 NOTES
748 EXAMPLE
750 BUGS
752 SEE ALSO
753 MA_MemorySize
755 INTERNALS
757 *****************************************************************************************/
759 /*****************************************************************************************
761 NAME
762 MA_Windowed
764 SYNOPSIS
765 [..G], BOOL
767 LOCATION
768 MONITORCLASS
770 FUNCTION
771 Check if this monitor is a window on hosted OS desktop.
773 This means that the host OS is responsible for handling mouse input and display
774 activation. Monitors with this attribute set to TRUE should be ignored by
775 multi-display desktop configuration software.
777 These monitors should have no spatial links to other monitors. Activation of these
778 monitors is done by clicking on their windows on the host's desktop and is handled
779 by the driver itself.
781 NOTES
782 This attribute is AROS-specific, it does not exist in MorphOS.
784 EXAMPLE
786 BUGS
788 SEE ALSO
790 INTERNALS
792 *****************************************************************************************/
794 /***********************************************************************************/
796 IPTR MonitorClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
798 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
799 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
800 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
801 OOP_AttrBase HiddAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
802 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
803 struct MonitorData *data = INST_DATA(cl, o);
805 D(kprintf("[monitorclass] OM_GET\n"));
807 switch (msg->opg_AttrID)
809 case MA_MonitorName:
810 OOP_GetAttr(data->handle->gfxhidd, aHidd_Name, msg->opg_Storage);
811 break;
813 case MA_Manufacturer:
814 OOP_GetAttr(data->handle->gfxhidd, aHidd_ProducerName, msg->opg_Storage);
815 break;
817 case MA_ManufacturerID:
818 OOP_GetAttr(data->handle->gfxhidd, aHidd_Producer, msg->opg_Storage);
819 break;
821 case MA_ProductID:
822 OOP_GetAttr(data->handle->gfxhidd, aHidd_Product, msg->opg_Storage);
823 break;
825 case MA_MemorySize:
826 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemorySize, msg->opg_Storage);
827 break;
829 case MA_PixelFormats:
830 *msg->opg_Storage = (IPTR)data->pixelformats;
831 break;
833 case MA_TopLeftMonitor:
834 *msg->opg_Storage = (IPTR)data->topleft;
835 break;
837 case MA_TopMiddleMonitor:
838 *msg->opg_Storage = (IPTR)data->topmiddle;
839 break;
841 case MA_TopRightMonitor:
842 *msg->opg_Storage = (IPTR)data->topright;
843 break;
845 case MA_MiddleLeftMonitor:
846 *msg->opg_Storage = (IPTR)data->middleleft;
847 break;
849 case MA_MiddleRightMonitor:
850 *msg->opg_Storage = (IPTR)data->middleright;
851 break;
853 case MA_BottomLeftMonitor:
854 *msg->opg_Storage = (IPTR)data->bottomleft;
855 break;
857 case MA_BottomMiddleMonitor:
858 *msg->opg_Storage = (IPTR)data->bottommiddle;
859 break;
861 case MA_BottomRightMonitor:
862 *msg->opg_Storage = (IPTR)data->bottomright;
863 break;
865 case MA_GammaControl:
866 *msg->opg_Storage = HIDD_Gfx_GetGamma(data->handle->gfxhidd, NULL, NULL, NULL);
867 break;
869 case MA_PointerType:
870 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_HWSpriteTypes, msg->opg_Storage);
871 break;
873 case MA_DriverName:
874 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_DriverName, msg->opg_Storage);
875 break;
877 case MA_MemoryClock:
878 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_MemoryClock, msg->opg_Storage);
879 break;
881 case MA_Windowed:
882 OOP_GetAttr(data->handle->gfxhidd, aHidd_Gfx_IsWindowed, msg->opg_Storage);
883 break;
885 default:
886 return DoSuperMethodA(cl, o, (Msg)msg);
889 return TRUE;
892 /***********************************************************************************/
894 IPTR MonitorClass__OM_SET(Class *cl, Object *o, struct opSet *msg)
896 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
897 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
898 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
899 struct MonitorData *data = INST_DATA(cl, o);
900 struct TagItem *tag, *tstate;
902 tstate = msg->ops_AttrList;
903 while((tag = NextTagItem((const struct TagItem **)&tstate))) {
904 switch (tag->ti_Tag) {
905 case MA_TopLeftMonitor:
906 data->topleft = (Object *)tag->ti_Data;
907 break;
909 case MA_TopMiddleMonitor:
910 data->topmiddle = (Object *)tag->ti_Data;
911 break;
913 case MA_TopRightMonitor:
914 data->topright = (Object *)tag->ti_Data;
915 break;
917 case MA_MiddleLeftMonitor:
918 data->middleleft = (Object *)tag->ti_Data;
919 break;
921 case MA_MiddleRightMonitor:
922 data->middleright = (Object *)tag->ti_Data;
923 break;
925 case MA_BottomLeftMonitor:
926 data->bottomleft = (Object *)tag->ti_Data;
927 break;
929 case MA_BottomMiddleMonitor:
930 data->bottommiddle = (Object *)tag->ti_Data;
931 break;
933 case MA_BottomRightMonitor:
934 data->bottomright = (Object *)tag->ti_Data;
935 break;
937 case MA_PointerVisible:
938 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
939 break;
942 return DoSuperMethodA(cl, o, (Msg)msg);
945 /***********************************************************************************/
947 #define Relink(nextAttr, prev, prevAttr, next) \
948 if (prev) \
949 SetAttrs(prev, nextAttr, next, TAG_DONE); \
950 if (next) \
951 SetAttrs(next, prevAttr, prev, TAG_DONE)
953 IPTR MonitorClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
955 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
956 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
957 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
958 struct MonitorData *data = INST_DATA(cl, o);
959 struct TagItem tags[] = {
960 {aHidd_Gfx_ActiveCallBack, 0},
961 {TAG_DONE , 0}
964 D(kprintf("MonitorClass: OM_DISPOSE\n"));
966 /* Disable activation callback */
967 OOP_SetAttrs(data->handle->gfxhidd, tags);
969 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
970 Remove((struct Node *)data);
972 /* Remove this monitor from spatial links */
973 Relink(MA_BottomRightMonitor, data->topleft, MA_TopLeftMonitor, data->bottomright);
974 Relink(MA_BottomMiddleMonitor, data->topmiddle, MA_TopMiddleMonitor, data->bottommiddle);
975 Relink(MA_BottomLeftMonitor, data->topright, MA_TopRightMonitor, data->bottomleft);
976 Relink(MA_MiddleLeftMonitor, data->middleright, MA_MiddleRightMonitor, data->middleleft);
978 /* If an active monitor is being removed, we should activate another one */
979 if (GetPrivIBase(IntuitionBase)->ActiveMonitor == o)
980 ActivateMonitor((Object *)GetHead(&GetPrivIBase(IntuitionBase)->MonitorList), -1, -1, IntuitionBase);
982 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
984 return DoSuperMethodA(cl, o, msg);
987 /************************************************************************************
989 NAME
990 MM_GetRootBitMap
992 SYNOPSIS
993 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, struct BitMap **Store);
995 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
997 LOCATION
999 FUNCTION
1000 This method is provided only for source code compatibility with MorphOS operating
1001 system.
1003 Under MorphOS this method returns a pointer to internal root bitmap of the
1004 display driver corresponding to the specified pixelformat. Displayable bitmaps are
1005 supposed to be created as friends of the root bitmap.
1007 In AROS displayable bitmaps need complete display mode information and not
1008 only pixelformat. So this method will never be implemented and will always return NULL
1009 pointer. In order to create a displayable RTG bitmap on AROS the user needs to supply
1010 a taglist with BMATags_DisplayID specification to AllocBitMap() function.
1012 INPUTS
1013 obj - A monitor object
1014 MethodID - MM_GetRootBitMap
1015 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1016 Store - A storage where root bitmap pointer will be placed.
1018 RESULT
1019 Undefined.
1021 NOTES
1023 EXAMPLE
1025 BUGS
1027 SEE ALSO
1028 graphics.library/AllocBitMap()
1030 INTERNALS
1032 ************************************************************************************/
1034 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1036 *msg->Store = NULL;
1038 return 0;
1041 /************************************************************************************
1043 NAME
1044 MM_Query3DSupport
1046 SYNOPSIS
1047 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1049 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1051 LOCATION
1053 FUNCTION
1054 Ask the display driver for type of 3D support for the given pixelformat.
1056 Supplied storage will be filled with one of:
1057 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1058 MSQUERY3D_NODRIVER - There is no 3D support for the given pixelformat
1059 MSQUERY3D_SWDRIVER - A software 3D support is available for the given
1060 pixelformat
1061 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the given
1062 pixelformat
1064 INPUTS
1065 obj - A monitor object to query
1066 MethodID - MM_Query3DSupport
1067 PixelFormat - A CyberGraphX pixelformat code
1068 Store - A pointer to a storage where return value will be placed
1070 RESULT
1071 Undefined.
1073 NOTES
1075 EXAMPLE
1077 BUGS
1079 SEE ALSO
1081 INTERNALS
1083 ************************************************************************************/
1085 IPTR MonitorClass__MM_Query3DSupport(Class *cl, Object *obj, struct msQuery3DSupport *msg)
1087 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1088 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1089 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1090 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1091 struct MonitorData *data = INST_DATA(cl, obj);
1092 OOP_Object *pf = data->pfobjects[msg->PixelFormat];
1094 if (pf) {
1095 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1096 *msg->Store = MSQUERY3D_HWDRIVER;
1097 else {
1098 IPTR depth;
1100 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1101 if (depth > 8)
1102 *msg->Store = MSQUERY3D_SWDRIVER;
1103 else
1104 *msg->Store = MSQUERY3D_NODRIVER;
1106 } else
1107 *msg->Store = MSQUERY3D_UNKNOWN;
1109 return *msg->Store;
1112 /************************************************************************************
1114 NAME
1115 MM_GetDefaultGammaTables
1117 SYNOPSIS
1118 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1120 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1122 LOCATION
1124 FUNCTION
1125 Get default gamma correction tables for the monitor
1127 INPUTS
1128 obj - A monitor object to query
1129 MethodID - MM_GetDefaultGammaTables
1130 Red - A pointer to an array of 256 bytes where gamma correction data for
1131 red component will be placed. You may speciy a NULL pointer in order
1132 to ignore this component.
1133 Green - A pointer to an array of 256 bytes where gamma correction data for
1134 green component will be placed. You may speciy a NULL pointer in order
1135 to ignore this component.
1136 Blue - A pointer to an array of 256 bytes where gamma correction data for
1137 blue component will be placed. You may speciy a NULL pointer in order
1138 to ignore this component.
1140 RESULT
1141 Undefined.
1143 NOTES
1145 EXAMPLE
1147 BUGS
1149 SEE ALSO
1150 MM_SetDefaultGammaTables
1152 INTERNALS
1154 ************************************************************************************/
1156 IPTR MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1158 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1159 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1160 struct MonitorData *data = INST_DATA(cl, obj);
1162 /* Currently we don't use per-screen gamma tables, so we just forward the request
1163 to the driver.
1164 If we implement per-screen gamma correction, we'll need more sophisticated
1165 management here */
1166 return HIDD_Gfx_GetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1169 /************************************************************************************
1171 NAME
1172 MM_GetDefaultPixelFormat
1174 SYNOPSIS
1175 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1177 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1179 LOCATION
1181 FUNCTION
1182 Get driver's preferred pixelformat for specified bitmap depth.
1184 INPUTS
1185 obj - A monitor object
1186 MethodID - MM_GetDefaultPixelFormat
1187 Depth - Depth to ask about
1188 Store - A pointer to an ULONG location where CyberGraphX pixelformat
1189 number will be placed. -1 means unsupported depth.
1191 RESULT
1192 Undefined.
1194 NOTES
1196 EXAMPLE
1198 BUGS
1200 SEE ALSO
1202 INTERNALS
1204 ************************************************************************************/
1206 IPTR MonitorClass__MM_GetDefaultPixelFormat(Class *cl, Object *obj, struct msGetDefaultPixelFormat *msg)
1208 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1209 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1210 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
1211 struct MonitorData *data = INST_DATA(cl, obj);
1212 ULONG i;
1214 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1215 if (data->pfobjects[i]) {
1216 IPTR depth;
1218 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1219 if (depth == msg->Depth) {
1220 *msg->Store = i;
1221 break;
1226 if (i == MONITOR_MAXPIXELFORMATS)
1227 *msg->Store = -1;
1229 return *msg->Store;
1232 /************************************************************************************
1234 NAME
1235 MM_GetPointerBounds
1237 SYNOPSIS
1238 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width, ULONG *Height);
1240 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1242 LOCATION
1243 monitorclass
1245 FUNCTION
1246 Get maximum allowed size of mouse pointer sprite.
1248 INPUTS
1249 obj - A monitor object
1250 MethodID - MM_GetPointerBounds
1251 PointerType - Pointer type (one of PointerType_...)
1252 Width - A pointer to an ULONG location where width will be placed.
1253 Height - A pointer to an ULONG location where height will be placed.
1255 RESULT
1256 FALSE is given pointer type is not supported, TRUE otherwise.
1258 NOTES
1259 Width and Height are considered undefined if the method returns FALSE.
1261 EXAMPLE
1263 BUGS
1265 SEE ALSO
1266 MA_PointerType
1268 INTERNALS
1270 ************************************************************************************/
1272 IPTR MonitorClass__MM_GetPointerBounds(Class *cl, Object *obj, struct msGetPointerBounds *msg)
1274 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1275 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1276 struct MonitorData *data = INST_DATA(cl, obj);
1278 return HIDD_Gfx_GetMaxSpriteSize(data->handle->gfxhidd, msg->PointerType, msg->Width, msg->Height);
1281 /************************************************************************************
1283 NAME
1284 MM_RunBlanker
1286 SYNOPSIS
1287 DoMethod(Object *obj, ULONG MethodID);
1289 DoMethodA(Object *obj, Msg *msg);
1291 LOCATION
1293 FUNCTION
1294 Starts screensaver on the monitor.
1296 At the moment AROS has no integrated screensaver support. The method is
1297 considered reserved and not implemented.
1299 INPUTS
1300 obj - A monitor object
1301 MethodID - MM_RunBlanker
1303 RESULT
1304 Undefined.
1306 NOTES
1308 EXAMPLE
1310 BUGS
1312 SEE ALSO
1313 MM_EnterPowerSaveMode, MM_ExitBlanker
1315 INTERNALS
1317 ************************************************************************************/
1319 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1321 /* We have no integrated screensaver support */
1323 return FALSE;
1326 /************************************************************************************
1328 NAME
1329 MM_EnterPowerSaveMode
1331 SYNOPSIS
1332 DoMethod(Object *obj, ULONG MethodID);
1334 DoMethodA(Object *obj, Msg *msg);
1336 LOCATION
1338 FUNCTION
1339 Starts power saving mode on the monitor.
1341 INPUTS
1342 obj - A monitor object
1343 MethodID - MM_EnterPowerSaveMode
1345 RESULT
1346 Undefined.
1348 NOTES
1350 EXAMPLE
1352 BUGS
1354 SEE ALSO
1355 MM_RunBlanker, MM_ExitBlanker
1357 INTERNALS
1358 Current implementation just immediately sets DMPS level to "Off" for the
1359 monitor.
1361 ************************************************************************************/
1363 IPTR MonitorClass__MM_EnterPowerSaveMode(Class *cl, Object *obj, Msg *msg)
1365 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1366 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1367 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1368 struct MonitorData *data = INST_DATA(cl, obj);
1369 struct TagItem tags[] =
1371 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_Off},
1372 {TAG_DONE , 0 }
1375 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1378 /************************************************************************************
1380 NAME
1381 MM_ExitBlanker
1383 SYNOPSIS
1384 DoMethod(Object *obj, ULONG MethodID);
1386 DoMethodA(Object *obj, Msg *msg);
1388 LOCATION
1390 FUNCTION
1391 Stops screensaver and/or power saving mode on the monitor.
1393 INPUTS
1394 obj - A monitor object
1395 MethodID - MM_ExitBlanker
1397 RESULT
1398 Undefined.
1400 NOTES
1402 EXAMPLE
1404 BUGS
1406 SEE ALSO
1407 MM_EnterPowerSaveMode, MM_RunBlanker
1409 INTERNALS
1411 ************************************************************************************/
1413 IPTR MonitorClass__MM_ExitBlanker(Class *cl, Object *obj, Msg *msg)
1415 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1416 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
1417 OOP_AttrBase HiddGfxAttrBase = GetPrivIBase(IntuitionBase)->HiddGfxAttrBase;
1418 struct MonitorData *data = INST_DATA(cl, obj);
1419 struct TagItem tags[] =
1421 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_On},
1422 {TAG_DONE , 0 }
1425 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1428 /************************************************************************************
1430 NAME
1431 MM_SetDefaultGammaTables
1433 SYNOPSIS
1434 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1436 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1438 LOCATION
1440 FUNCTION
1441 Set default gamma correction tables for the monitor
1443 INPUTS
1444 obj - A monitor object to query
1445 MethodID - MM_GetDefaultGammaTables
1446 Red - A pointer to an array of 256 bytes where gamma correction data for
1447 red component is placed. You may speciy a NULL pointer in order
1448 to ignore this component.
1449 Green - A pointer to an array of 256 bytes where gamma correction data for
1450 green component is placed. You may speciy a NULL pointer in order
1451 to ignore this component.
1452 Blue - A pointer to an array of 256 bytes where gamma correction data for
1453 blue component is placed. You may speciy a NULL pointer in order
1454 to ignore this component.
1456 RESULT
1457 Undefined.
1459 NOTES
1460 This method is AROS-specific.
1462 EXAMPLE
1464 BUGS
1466 SEE ALSO
1467 MM_GetDefaultGammaTables
1469 INTERNALS
1471 ************************************************************************************/
1473 IPTR MonitorClass__MM_SetDefaultGammaTables(Class *cl, Object *obj, struct msSetDefaultGammaTables *msg)
1475 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1476 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1477 struct MonitorData *data = INST_DATA(cl, obj);
1479 /* Currently we don't use per-screen gamma tables, so we just forward the request
1480 to the driver.
1481 If we implement per-screen gamma correction, we'll need more sophisticated
1482 management here */
1483 return HIDD_Gfx_SetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1486 /************************************************************************************/
1488 ULONG MonitorClass__MM_GetCompositionFlags(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1490 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1491 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1492 struct MonitorData *data = INST_DATA(cl, obj);
1493 struct HIDD_ModeProperties modeprops;
1495 HIDD_Gfx_ModeProperties(data->handle->gfxhidd, msg->ModeID & (!data->handle->mask),
1496 &modeprops, sizeof(modeprops));
1497 return modeprops.CompositionFlags;
1500 /************************************************************************************/
1502 void MonitorClass__MM_SetPointerPos(Class *cl, Object *obj, struct msSetPointerPos *msg)
1504 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1505 struct MonitorData *data = INST_DATA(cl, obj);
1507 data->mouseX = msg->x;
1508 data->mouseY = msg->y;
1509 SetPointerPos(data, IntuitionBase);
1512 /************************************************************************************/
1514 IPTR MonitorClass__MM_CheckID(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1516 struct MonitorData *data = INST_DATA(cl, obj);
1518 return ((msg->ModeID & data->handle->mask) == data->handle->id);
1521 /************************************************************************************/
1523 IPTR MonitorClass__MM_SetPointerShape(Class *cl, Object *obj, struct msSetPointerShape *msg)
1525 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
1526 OOP_MethodID HiddGfxBase = GetPrivIBase(IntuitionBase)->ib_HiddGfxBase;
1527 struct MonitorData *data = INST_DATA(cl, obj);
1528 struct BitMap *bm;
1529 BOOL res;
1531 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg->pointer, data->pointer));
1532 /* Don't do anything if already set */
1533 if (data->pointer == msg->pointer)
1534 return TRUE;
1536 bm = msg->pointer->sprite->es_BitMap;
1537 /* Currently we don't work with planar sprites */
1538 if (!(bm->Flags & BMF_SPECIALFMT))
1539 return FALSE;
1541 res = HIDD_Gfx_SetCursorShape(data->handle->gfxhidd, (OOP_Object *)bm->Planes[0], msg->pointer->xoffset, msg->pointer->yoffset);
1542 D(bug("[monitorclass] SetCursorShape() returned %d\n", res));
1543 if (res) {
1544 data->pointer = msg->pointer;
1545 /* This will fix up sprite position if hotspot changed */
1546 SetPointerPos(data, IntuitionBase);
1549 return res;