Tested and debugged ToolTypes.
[AROS.git] / rom / intuition / monitorclass.c
blob9de03bab83fd7b5b69499299f49c0bafc1eb6143
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define __OOP_NOATTRBASES__
8 #include <aros/debug.h>
9 #include <cybergraphx/cybergraphics.h>
10 #include <hidd/graphics.h>
11 #include <hidd/hidd.h>
12 #include <graphics/driver.h>
13 #include <graphics/sprite.h>
14 #include <intuition/intuition.h>
15 #include <intuition/intuitionbase.h>
16 #include <intuition/classes.h>
17 #include <intuition/classusr.h>
18 #include <intuition/monitorclass.h>
19 #include <proto/alib.h>
20 #include <proto/exec.h>
21 #include <proto/intuition.h>
22 #include <proto/oop.h>
23 #include <proto/utility.h>
25 #undef HiddGfxAttrBase
26 #undef HiddPixFmtAttrBase
28 #include "intuition_intern.h"
29 #include "monitorclass_intern.h"
30 #include "monitorclass_private.h"
32 /*****************************************************************************************
34 NAME
35 --background--
37 LOCATION
38 MONITORCLASS
40 NOTES
41 In AROS display drivers have associated BOOPSI objects of MONITORCLASS class.
42 This class provides information about relative physical placement of monitors
43 in user's workspace as well as some additional properties.
45 MONITORCLASS is a pseudo name. This class is in fact private to the system and
46 does not have a public ID. The user can't create objects of this class manually.
48 This class is fully compatible with MorphOS starting from v2.6.
50 *****************************************************************************************/
52 Object *DisplayDriverNotify(APTR obj, BOOL add, struct IntuitionBase *IntuitionBase)
54 if (add)
56 Object *mon = NewObject(GetPrivIBase(IntuitionBase)->monitorclass, NULL, MA_MonitorHandle, obj, TAG_DONE);
58 D(bug("[monitorclass] Created monitorclass object 0x%p\n", mon));
59 if (mon) {
60 /* Install default mouse pointer on the new monitor */
61 Object *ptr = GetPrivIBase(IntuitionBase)->DefaultPointer;
63 if (ptr) {
64 struct SharedPointer *pointer;
66 GetAttr(POINTERA_SharedPointer, ptr, (IPTR *)&pointer);
67 DoMethod(mon, MM_SetPointerShape, pointer);
71 return mon;
73 else
75 DisposeObject(obj);
76 return NULL;
80 /***********************************************************************************/
82 static void SetPointerPos(struct MonitorData *data, struct IntuitionBase *IntuitionBase)
84 ULONG x = data->mouseX;
85 ULONG y = data->mouseY;
87 DB2(bug("[monitorclass] SetPointerPos(%d, %d), pointer 0x%p\n", x, y, data->pointer));
88 if (data->pointer)
90 /* Take HotSpot into account */
91 x += data->pointer->xoffset;
92 y += data->pointer->yoffset;
94 /* Update sprite position, just for backwards compatibility */
95 data->pointer->sprite->es_SimpleSprite.x = x;
96 data->pointer->sprite->es_SimpleSprite.y = y;
99 DB2(bug("[monitorclass] Physical coordinates: (%d, %d)\n", x, y));
100 HIDD_Gfx_SetCursorPos(data->handle->gfxhidd, x, y);
103 /***********************************************************************************/
105 #undef IntuitionBase
106 #define IntuitionBase ((struct IntuitionBase *)(cl->cl_UserData))
107 #define HiddAttrBase (GetPrivIBase(IntuitionBase)->HiddAttrBase)
108 #define HiddGfxAttrBase (GetPrivIBase(IntuitionBase)->HiddGfxAttrBase)
109 #define HiddPixFmtAttrBase (GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase)
111 /***********************************************************************************/
113 static void ActivationHandler(Object *mon, OOP_Object *bitmap)
115 Class *cl = OCLASS(mon);
117 /* NewMonitor will be picked up by input handler when the next event arrives, so no signals etc */
118 GetPrivIBase(IntuitionBase)->NewMonitor = mon;
121 /***********************************************************************************/
123 static BYTE pixelformats[] = {
127 PIXFMT_RGB24,
128 PIXFMT_BGR24,
129 PIXFMT_RGB16,
130 PIXFMT_RGB16PC,
131 PIXFMT_BGR16,
132 PIXFMT_BGR16PC,
133 PIXFMT_RGB15,
134 PIXFMT_RGB15PC,
135 PIXFMT_BGR15,
136 PIXFMT_BGR15PC,
137 PIXFMT_ARGB32,
138 PIXFMT_BGRA32,
139 PIXFMT_RGBA32,
141 PIXFMT_ARGB32,
142 PIXFMT_BGRA32,
143 PIXFMT_RGBA32,
145 PIXFMT_LUT8,
149 Object *MonitorClass__OM_NEW(Class *cl, Object *o, struct opSet *msg)
151 struct MonitorHandle *handle = (struct MonitorHandle *)GetTagData(MA_MonitorHandle, 0, msg->ops_AttrList);
152 HIDDT_ModeID mode = vHidd_ModeID_Invalid;
153 struct MonitorData *data;
154 OOP_Object *sync, *pixfmt;
155 /* Tags order is important because CallBackData needs to be set before
156 function pointer. Otherwise the function can be called with a wrong
157 pointer. */
158 struct TagItem tags[] = {
159 {aHidd_Gfx_ActiveCallBackData, 0 },
160 {aHidd_Gfx_ActiveCallBack , (IPTR)ActivationHandler},
161 {TAG_DONE , 0 }
164 D(kprintf("[monitorclass] OM_NEW\n"));
166 if (!handle)
167 return NULL;
169 o = (Object *)DoSuperMethodA(cl, o, (Msg)msg);
170 if (!o)
171 return NULL;
173 data = INST_DATA(cl, o);
175 data->handle = handle;
177 /* We can't list driver's pixelformats, we can list only modes. This does not harm however,
178 just some pixelformats will be processed more than once */
179 while ((mode = HIDD_Gfx_NextModeID(handle->gfxhidd, mode, &sync, &pixfmt)) != vHidd_ModeID_Invalid) {
180 IPTR stdpf;
181 BYTE cgxpf;
183 OOP_GetAttr(pixfmt, aHidd_PixFmt_StdPixFmt, &stdpf);
184 cgxpf = pixelformats[stdpf];
185 D(bug("[monitorclass] Mode 0x%08lX, StdPixFmt %lu, CGX pixfmt %d\n", mode, stdpf, cgxpf));
187 if (cgxpf != -1) {
188 data->pfobjects[cgxpf] = pixfmt;
189 data->pixelformats[cgxpf] = TRUE;
193 tags[0].ti_Data = (IPTR)o;
194 OOP_SetAttrs(handle->gfxhidd, tags);
196 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
197 AddTail((struct List *)&GetPrivIBase(IntuitionBase)->MonitorList, (struct Node *)data);
198 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
200 return o;
203 /*****************************************************************************************
205 NAME
206 MA_MonitorName
208 SYNOPSIS
209 [..G], STRPTR
211 LOCATION
212 MONITORCLASS
214 FUNCTION
215 Query monitor driver name
217 NOTES
219 EXAMPLE
221 BUGS
223 SEE ALSO
225 INTERNALS
227 *****************************************************************************************/
229 /*****************************************************************************************
231 NAME
232 MA_Manufacturer
234 SYNOPSIS
235 [..G], STRPTR
237 LOCATION
238 MONITORCLASS
240 FUNCTION
241 Query video card hardware manufacturer name
243 NOTES
244 Not all drivers may specify manufacturer string. NULL is a valid return value.
246 EXAMPLE
248 BUGS
250 SEE ALSO
252 INTERNALS
254 *****************************************************************************************/
256 /*****************************************************************************************
258 NAME
259 MA_ManufacturerID
261 SYNOPSIS
262 [..G], ULONG
264 LOCATION
265 MONITORCLASS
267 FUNCTION
268 Query video card hardware's numeric manufacturer ID (which may come from PCI,
269 Zorro, etc).
271 NOTES
272 Not all drivers may have assigned IDs. For example VGA driver and virtual
273 hosted drivers do not associate themselves with any IDs.
275 EXAMPLE
277 BUGS
279 SEE ALSO
280 MA_ProductID
282 INTERNALS
284 *****************************************************************************************/
286 /*****************************************************************************************
288 NAME
289 MA_ProductID
291 SYNOPSIS
292 [..G], ULONG
294 LOCATION
295 MONITORCLASS
297 FUNCTION
298 Query video card hardware's numeric product ID (which may come from PCI, Zorro, etc).
300 NOTES
301 Not all drivers may have assigned IDs. For example VGA driver and virtual
302 hosted drivers do not associate themselves with any IDs.
304 EXAMPLE
306 BUGS
308 SEE ALSO
309 MA_ManufacturerID
311 INTERNALS
313 *****************************************************************************************/
315 /*****************************************************************************************
317 NAME
318 MA_MemorySize
320 SYNOPSIS
321 [..G], ULONG
323 LOCATION
324 MONITORCLASS
326 FUNCTION
327 Query total size of video card memory in bytes.
329 NOTES
331 EXAMPLE
333 BUGS
335 SEE ALSO
336 MA_MemoryClock
338 INTERNALS
340 *****************************************************************************************/
342 /*****************************************************************************************
344 NAME
345 MA_PixelFormats
347 SYNOPSIS
348 [..G], ULONG *
350 LOCATION
351 MONITORCLASS
353 FUNCTION
354 Query table of supported pixelformats.
356 A returned value is a pointer to static array of ULONGs, one ULONG per CyberGraphX
357 pixelformat. Values of these ULONGs are actually booleans. TRUE value in the array
358 says that the pixelformat is supported, FALSE means it's not.
360 NOTES
362 EXAMPLE
363 ULONG *pfs;
365 GetAttr(MA_PixelFormats, monitor, (IPTR *)&pfs);
366 if (pfs[PUXFMT_LUT8])
367 printf("The display driver supports LUT8 format\n");
369 BUGS
371 SEE ALSO
372 MA_ManufacturerID
374 INTERNALS
376 *****************************************************************************************/
378 /*****************************************************************************************
380 NAME
381 MA_TopLeftMonitor
383 SYNOPSIS
384 [.SG], Object *
386 LOCATION
387 MONITORCLASS
389 FUNCTION
390 Get a pointer to a monitor placed in top-left diagonal direction relative to
391 the current one.
393 This attribute is used to describe relative placement of monitors in user's
394 physical environment.
396 NOTES
398 EXAMPLE
400 BUGS
401 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
402 monitor object.
404 SEE ALSO
405 MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
406 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
408 INTERNALS
410 *****************************************************************************************/
412 /*****************************************************************************************
414 NAME
415 MA_TopMiddleMonitor
417 SYNOPSIS
418 [.SG], Object *
420 LOCATION
421 MONITORCLASS
423 FUNCTION
424 Get a pointer to a monitor placed in top direction relative to the current one.
426 This attribute is used to describe relative placement of monitors in user's
427 physical environment.
429 NOTES
431 EXAMPLE
433 BUGS
434 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
435 monitor object.
437 SEE ALSO
438 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
439 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
441 INTERNALS
443 *****************************************************************************************/
445 /*****************************************************************************************
447 NAME
448 MA_TopRightMonitor
450 SYNOPSIS
451 [.SG], Object *
453 LOCATION
454 MONITORCLASS
456 FUNCTION
457 Get a pointer to a monitor placed in top-right diagonal direction relative to
458 the current one.
460 This attribute is used to describe relative placement of monitors in user's
461 physical environment.
463 NOTES
465 EXAMPLE
467 BUGS
468 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
469 monitor object.
471 SEE ALSO
472 MA_TopLeftMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor, MA_MiddleRightMonitor,
473 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
475 INTERNALS
477 *****************************************************************************************/
479 /*****************************************************************************************
481 NAME
482 MA_MiddleLeftMonitor
484 SYNOPSIS
485 [.SG], Object *
487 LOCATION
488 MONITORCLASS
490 FUNCTION
491 Get a pointer to a monitor placed in left direction relative to
492 the current one.
494 This attribute is used to describe relative placement of monitors in user's
495 physical environment.
497 NOTES
499 EXAMPLE
501 BUGS
502 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
503 monitor object.
505 SEE ALSO
506 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleRightMonitor,
507 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
509 INTERNALS
511 *****************************************************************************************/
513 /*****************************************************************************************
515 NAME
516 MA_MiddleRightMonitor
518 SYNOPSIS
519 [.SG], Object *
521 LOCATION
522 MONITORCLASS
524 FUNCTION
525 Get a pointer to a monitor placed in right direction relative to
526 the current one.
528 This attribute is used to describe relative placement of monitors in user's
529 physical environment.
531 NOTES
533 EXAMPLE
535 BUGS
536 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
537 monitor object.
539 SEE ALSO
540 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
541 MA_BottomLeftMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
543 INTERNALS
545 *****************************************************************************************/
547 /*****************************************************************************************
549 NAME
550 MA_BottomLeftMonitor
552 SYNOPSIS
553 [.SG], Object *
555 LOCATION
556 MONITORCLASS
558 FUNCTION
559 Get a pointer to a monitor placed in bottom-left diagonal direction relative to
560 the current one.
562 This attribute is used to describe relative placement of monitors in user's
563 physical environment.
565 NOTES
567 EXAMPLE
569 BUGS
570 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
571 monitor object.
573 SEE ALSO
574 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
575 MA_MiddleRightMonitor, MA_BottomMiddleMonitor, MA_BottomRightMonitor
577 INTERNALS
579 *****************************************************************************************/
581 /*****************************************************************************************
583 NAME
584 MA_BottomMiddleMonitor
586 SYNOPSIS
587 [.SG], Object *
589 LOCATION
590 MONITORCLASS
592 FUNCTION
593 Get a pointer to a monitor placed in bottom direction relative to the current one.
595 This attribute is used to describe relative placement of monitors in user's
596 physical environment.
598 NOTES
600 EXAMPLE
602 BUGS
603 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
604 monitor object.
606 SEE ALSO
607 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
608 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomRightMonitor
610 INTERNALS
612 *****************************************************************************************/
614 /*****************************************************************************************
616 NAME
617 MA_BottomRightMonitor
619 SYNOPSIS
620 [.SG], Object *
622 LOCATION
623 MONITORCLASS
625 FUNCTION
626 Get a pointer to a monitor placed in bottom-right diagonal direction relative to
627 the current one.
629 This attribute is used to describe relative placement of monitors in user's
630 physical environment.
632 NOTES
634 EXAMPLE
636 BUGS
637 In MorphOS up to v2.5 this attribute returns monitor ID, not a pointer to a
638 monitor object.
640 SEE ALSO
641 MA_TopLeftMonitor, MA_TopMiddleMonitor, MA_TopRightMonior, MA_MiddleLeftMonitor,
642 MA_MiddleRightMonitor, MA_BottomLeftMonitor, MA_BottomMiddleMonitor
644 INTERNALS
646 *****************************************************************************************/
648 /*****************************************************************************************
650 NAME
651 MA_GammaControl
653 SYNOPSIS
654 [..G], BOOL
656 LOCATION
657 MONITORCLASS
659 FUNCTION
660 Query if the display driver supports gamma control
662 NOTES
664 EXAMPLE
666 BUGS
668 SEE ALSO
669 MM_GetDefaultGammaTables, MM_SetDefaultGammaTables
671 INTERNALS
673 *****************************************************************************************/
675 /*****************************************************************************************
677 NAME
678 MA_PointerType
680 SYNOPSIS
681 [..G], ULONG
683 LOCATION
684 MONITORCLASS
686 FUNCTION
687 Query supported mouse pointer sprite formats.
689 The returned value is a combination of the following bit flags:
690 PointerType_3Plus1 - color 0 transparent, 1-3 visible (Amiga(tm) chipset sprite)
691 PointerType_2Plus1 - color 0 transparent, 1 unsefined (can be for example clear or
692 inverse), 2-3 visible
693 PointerType_ARGB - Direct color bitmap (hi-color or truecolor, possibly with alpha
694 channel
696 NOTES
698 EXAMPLE
700 BUGS
702 SEE ALSO
703 MM_GetPointerBounds
705 INTERNALS
707 *****************************************************************************************/
709 /*****************************************************************************************
711 NAME
712 MA_DriverName
714 SYNOPSIS
715 [..G], STRPTR
717 LOCATION
718 MONITORCLASS
720 FUNCTION
721 Query CyberGraphX driver name. It is the name which can be given to
722 cybergraphics.library/BestCModeIDTagList() as CYBRBIDTG_BoardName value.
724 NOTES
726 EXAMPLE
728 BUGS
730 SEE ALSO
731 MM_GetPointerBounds
733 INTERNALS
735 *****************************************************************************************/
737 /*****************************************************************************************
739 NAME
740 MA_MemoryClock
742 SYNOPSIS
743 [..G], ULONG
745 LOCATION
746 MONITORCLASS
748 FUNCTION
749 Query video card's memory clock in Hz. 0 is a valid value meaning 'unknown'.
751 NOTES
753 EXAMPLE
755 BUGS
757 SEE ALSO
758 MA_MemorySize
760 INTERNALS
762 *****************************************************************************************/
764 /*****************************************************************************************
766 NAME
767 MA_Windowed
769 SYNOPSIS
770 [..G], BOOL
772 LOCATION
773 MONITORCLASS
775 FUNCTION
776 Check if this monitor is a window on hosted OS desktop.
778 This means that the host OS is responsible for handling mouse input and display
779 activation. Monitors with this attribute set to TRUE should be ignored by
780 multi-display desktop configuration software.
782 These monitors should have no spatial links to other monitors. Activation of these
783 monitors is done by clicking on their windows on the host's desktop and is handled
784 by the driver itself.
786 NOTES
787 This attribute is AROS-specific, it does not exist in MorphOS.
789 EXAMPLE
791 BUGS
793 SEE ALSO
795 INTERNALS
797 *****************************************************************************************/
799 /***********************************************************************************/
801 IPTR MonitorClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
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 MonitorData *data = INST_DATA(cl, o);
897 struct TagItem *tag, *tstate;
899 tstate = msg->ops_AttrList;
900 while((tag = NextTagItem((const struct TagItem **)&tstate))) {
901 switch (tag->ti_Tag) {
902 case MA_TopLeftMonitor:
903 data->topleft = (Object *)tag->ti_Data;
904 break;
906 case MA_TopMiddleMonitor:
907 data->topmiddle = (Object *)tag->ti_Data;
908 break;
910 case MA_TopRightMonitor:
911 data->topright = (Object *)tag->ti_Data;
912 break;
914 case MA_MiddleLeftMonitor:
915 data->middleleft = (Object *)tag->ti_Data;
916 break;
918 case MA_MiddleRightMonitor:
919 data->middleright = (Object *)tag->ti_Data;
920 break;
922 case MA_BottomLeftMonitor:
923 data->bottomleft = (Object *)tag->ti_Data;
924 break;
926 case MA_BottomMiddleMonitor:
927 data->bottommiddle = (Object *)tag->ti_Data;
928 break;
930 case MA_BottomRightMonitor:
931 data->bottomright = (Object *)tag->ti_Data;
932 break;
934 case MA_PointerVisible:
935 HIDD_Gfx_SetCursorVisible(data->handle->gfxhidd, tag->ti_Data);
936 break;
939 return DoSuperMethodA(cl, o, (Msg)msg);
942 /***********************************************************************************/
944 #define Relink(nextAttr, prev, prevAttr, next) \
945 if (prev) \
946 SetAttrs(prev, nextAttr, next, TAG_DONE); \
947 if (next) \
948 SetAttrs(next, prevAttr, prev, TAG_DONE)
950 IPTR MonitorClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
952 struct MonitorData *data = INST_DATA(cl, o);
953 struct TagItem tags[] = {
954 {aHidd_Gfx_ActiveCallBack, 0},
955 {TAG_DONE , 0}
958 D(kprintf("MonitorClass: OM_DISPOSE\n"));
960 /* Disable activation callback */
961 OOP_SetAttrs(data->handle->gfxhidd, tags);
963 ObtainSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
964 Remove((struct Node *)data);
966 /* Remove this monitor from spatial links */
967 Relink(MA_BottomRightMonitor, data->topleft, MA_TopLeftMonitor, data->bottomright);
968 Relink(MA_BottomMiddleMonitor, data->topmiddle, MA_TopMiddleMonitor, data->bottommiddle);
969 Relink(MA_BottomLeftMonitor, data->topright, MA_TopRightMonitor, data->bottomleft);
970 Relink(MA_MiddleLeftMonitor, data->middleright, MA_MiddleRightMonitor, data->middleleft);
972 /* If an active monitor is being removed, we should activate another one */
973 if (GetPrivIBase(IntuitionBase)->ActiveMonitor == o)
974 ActivateMonitor((Object *)GetHead(&GetPrivIBase(IntuitionBase)->MonitorList), -1, -1, IntuitionBase);
976 ReleaseSemaphore(&GetPrivIBase(IntuitionBase)->MonitorListSem);
978 return DoSuperMethodA(cl, o, msg);
981 /************************************************************************************
983 NAME
984 MM_GetRootBitMap
986 SYNOPSIS
987 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, struct BitMap **Store);
989 DoMethodA(Object *obj, struct msGetRootBitMap *msg);
991 LOCATION
993 FUNCTION
994 This method is provided only for source code compatibility with MorphOS operating
995 system.
997 Under MorphOS this method returns a pointer to internal root bitmap of the
998 display driver corresponding to the specified pixelformat. Displayable bitmaps are
999 supposed to be created as friends of the root bitmap.
1001 In AROS displayable bitmaps need complete display mode information and not
1002 only pixelformat. So this method will never be implemented and will always return NULL
1003 pointer. In order to create a displayable RTG bitmap on AROS the user needs to supply
1004 a taglist with BMATags_DisplayID specification to AllocBitMap() function.
1006 INPUTS
1007 obj - A monitor object
1008 MethodID - MM_GetRootBitMap
1009 PixelFormat - A CyberGraphX pixelformat code to get root bitmap for
1010 Store - A storage where root bitmap pointer will be placed.
1012 RESULT
1013 Undefined.
1015 NOTES
1017 EXAMPLE
1019 BUGS
1021 SEE ALSO
1022 graphics.library/AllocBitMap()
1024 INTERNALS
1026 ************************************************************************************/
1028 IPTR MonitorClass__MM_GetRootBitMap(Class *cl, Object *obj, struct msGetRootBitMap *msg)
1030 *msg->Store = NULL;
1032 return 0;
1035 /************************************************************************************
1037 NAME
1038 MM_Query3DSupport
1040 SYNOPSIS
1041 DoMethod(Object *obj, ULONG MethodID, ULONG PixelFormat, ULONG *Store);
1043 DoMethodA(Object *obj, struct msQuery3DSupport *msg);
1045 LOCATION
1047 FUNCTION
1048 Ask the display driver for type of 3D support for the given pixelformat.
1050 Supplied storage will be filled with one of:
1051 MSQUERY3D_UNKNOWN - Unsupported pixelformat or some internal error
1052 MSQUERY3D_NODRIVER - There is no 3D support for the given pixelformat
1053 MSQUERY3D_SWDRIVER - A software 3D support is available for the given
1054 pixelformat
1055 MSQUERY3D_HWDRIVER - A hardware 3D support is available for the given
1056 pixelformat
1058 INPUTS
1059 obj - A monitor object to query
1060 MethodID - MM_Query3DSupport
1061 PixelFormat - A CyberGraphX pixelformat code
1062 Store - A pointer to a storage where return value will be placed
1064 RESULT
1065 Undefined.
1067 NOTES
1069 EXAMPLE
1071 BUGS
1073 SEE ALSO
1075 INTERNALS
1077 ************************************************************************************/
1079 IPTR MonitorClass__MM_Query3DSupport(Class *cl, Object *obj, struct msQuery3DSupport *msg)
1081 struct MonitorData *data = INST_DATA(cl, obj);
1082 OOP_Object *pf = data->pfobjects[msg->PixelFormat];
1084 if (pf) {
1085 if (HIDD_Gfx_QueryHardware3D(data->handle->gfxhidd, pf))
1086 *msg->Store = MSQUERY3D_HWDRIVER;
1087 else {
1088 IPTR depth;
1090 OOP_GetAttr(pf, aHidd_PixFmt_Depth, &depth);
1091 if (depth > 8)
1092 *msg->Store = MSQUERY3D_SWDRIVER;
1093 else
1094 *msg->Store = MSQUERY3D_NODRIVER;
1096 } else
1097 *msg->Store = MSQUERY3D_UNKNOWN;
1099 return *msg->Store;
1102 /************************************************************************************
1104 NAME
1105 MM_GetDefaultGammaTables
1107 SYNOPSIS
1108 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1110 DoMethodA(Object *obj, struct msGetDefaultGammaTables *msg);
1112 LOCATION
1114 FUNCTION
1115 Get default gamma correction tables for the monitor
1117 INPUTS
1118 obj - A monitor object to query
1119 MethodID - MM_GetDefaultGammaTables
1120 Red - A pointer to an array of 256 bytes where gamma correction data for
1121 red component will be placed. You may speciy a NULL pointer in order
1122 to ignore this component.
1123 Green - A pointer to an array of 256 bytes where gamma correction data for
1124 green component will be placed. You may speciy a NULL pointer in order
1125 to ignore this component.
1126 Blue - A pointer to an array of 256 bytes where gamma correction data for
1127 blue component will be placed. You may speciy a NULL pointer in order
1128 to ignore this component.
1130 RESULT
1131 Undefined.
1133 NOTES
1135 EXAMPLE
1137 BUGS
1139 SEE ALSO
1140 MM_SetDefaultGammaTables
1142 INTERNALS
1144 ************************************************************************************/
1146 IPTR MonitorClass__MM_GetDefaultGammaTables(Class *cl, Object *obj, struct msGetDefaultGammaTables *msg)
1148 struct MonitorData *data = INST_DATA(cl, obj);
1150 /* Currently we don't use per-screen gamma tables, so we just forward the request
1151 to the driver.
1152 If we implement per-screen gamma correction, we'll need more sophisticated
1153 management here */
1154 return HIDD_Gfx_GetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1157 /************************************************************************************
1159 NAME
1160 MM_GetDefaultPixelFormat
1162 SYNOPSIS
1163 DoMethod(Object *obj, ULONG MethodID, ULONG Depth, ULONG *Store);
1165 DoMethodA(Object *obj, struct msGetDefaultPixelFormat *msg);
1167 LOCATION
1169 FUNCTION
1170 Get driver's preferred pixelformat for specified bitmap depth.
1172 INPUTS
1173 obj - A monitor object
1174 MethodID - MM_GetDefaultPixelFormat
1175 Depth - Depth to ask about
1176 Store - A pointer to an ULONG location where CyberGraphX pixelformat
1177 number will be placed. -1 means unsupported depth.
1179 RESULT
1180 Undefined.
1182 NOTES
1184 EXAMPLE
1186 BUGS
1188 SEE ALSO
1190 INTERNALS
1192 ************************************************************************************/
1194 IPTR MonitorClass__MM_GetDefaultPixelFormat(Class *cl, Object *obj, struct msGetDefaultPixelFormat *msg)
1196 struct MonitorData *data = INST_DATA(cl, obj);
1197 ULONG i;
1199 for (i = 0; i < MONITOR_MAXPIXELFORMATS; i++) {
1200 if (data->pfobjects[i]) {
1201 IPTR depth;
1203 OOP_GetAttr(data->pfobjects[i], aHidd_PixFmt_Depth, &depth);
1204 if (depth == msg->Depth) {
1205 *msg->Store = i;
1206 break;
1211 if (i == MONITOR_MAXPIXELFORMATS)
1212 *msg->Store = -1;
1214 return *msg->Store;
1217 /************************************************************************************
1219 NAME
1220 MM_GetPointerBounds
1222 SYNOPSIS
1223 DoMethod(Object *obj, ULONG MethodID, ULONG PointerType, ULONG *Width, ULONG *Height);
1225 DoMethodA(Object *obj, struct msGetPointerBounds *msg);
1227 LOCATION
1228 monitorclass
1230 FUNCTION
1231 Get maximum allowed size of mouse pointer sprite.
1233 INPUTS
1234 obj - A monitor object
1235 MethodID - MM_GetPointerBounds
1236 PointerType - Pointer type (one of PointerType_...)
1237 Width - A pointer to an ULONG location where width will be placed.
1238 Height - A pointer to an ULONG location where height will be placed.
1240 RESULT
1241 FALSE is given pointer type is not supported, TRUE otherwise.
1243 NOTES
1244 Width and Height are considered undefined if the method returns FALSE.
1246 EXAMPLE
1248 BUGS
1250 SEE ALSO
1251 MA_PointerType
1253 INTERNALS
1255 ************************************************************************************/
1257 IPTR MonitorClass__MM_GetPointerBounds(Class *cl, Object *obj, struct msGetPointerBounds *msg)
1259 struct MonitorData *data = INST_DATA(cl, obj);
1261 return HIDD_Gfx_GetMaxSpriteSize(data->handle->gfxhidd, msg->PointerType, msg->Width, msg->Height);
1264 /************************************************************************************
1266 NAME
1267 MM_RunBlanker
1269 SYNOPSIS
1270 DoMethod(Object *obj, ULONG MethodID);
1272 DoMethodA(Object *obj, Msg *msg);
1274 LOCATION
1276 FUNCTION
1277 Starts screensaver on the monitor.
1279 At the moment AROS has no integrated screensaver support. The method is
1280 considered reserved and not implemented.
1282 INPUTS
1283 obj - A monitor object
1284 MethodID - MM_RunBlanker
1286 RESULT
1287 Undefined.
1289 NOTES
1291 EXAMPLE
1293 BUGS
1295 SEE ALSO
1296 MM_EnterPowerSaveMode, MM_ExitBlanker
1298 INTERNALS
1300 ************************************************************************************/
1302 IPTR MonitorClass__MM_RunBlanker(Class *cl, Object *obj, Msg *msg)
1304 /* We have no integrated screensaver support */
1306 return FALSE;
1309 /************************************************************************************
1311 NAME
1312 MM_EnterPowerSaveMode
1314 SYNOPSIS
1315 DoMethod(Object *obj, ULONG MethodID);
1317 DoMethodA(Object *obj, Msg *msg);
1319 LOCATION
1321 FUNCTION
1322 Starts power saving mode on the monitor.
1324 INPUTS
1325 obj - A monitor object
1326 MethodID - MM_EnterPowerSaveMode
1328 RESULT
1329 Undefined.
1331 NOTES
1333 EXAMPLE
1335 BUGS
1337 SEE ALSO
1338 MM_RunBlanker, MM_ExitBlanker
1340 INTERNALS
1341 Current implementation just immediately sets DMPS level to "Off" for the
1342 monitor.
1344 ************************************************************************************/
1346 IPTR MonitorClass__MM_EnterPowerSaveMode(Class *cl, Object *obj, Msg *msg)
1348 struct MonitorData *data = INST_DATA(cl, obj);
1349 struct TagItem tags[] =
1351 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_Off},
1352 {TAG_DONE , 0 }
1355 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1358 /************************************************************************************
1360 NAME
1361 MM_ExitBlanker
1363 SYNOPSIS
1364 DoMethod(Object *obj, ULONG MethodID);
1366 DoMethodA(Object *obj, Msg *msg);
1368 LOCATION
1370 FUNCTION
1371 Stops screensaver and/or power saving mode on the monitor.
1373 INPUTS
1374 obj - A monitor object
1375 MethodID - MM_ExitBlanker
1377 RESULT
1378 Undefined.
1380 NOTES
1382 EXAMPLE
1384 BUGS
1386 SEE ALSO
1387 MM_EnterPowerSaveMode, MM_RunBlanker
1389 INTERNALS
1391 ************************************************************************************/
1393 IPTR MonitorClass__MM_ExitBlanker(Class *cl, Object *obj, Msg *msg)
1395 struct MonitorData *data = INST_DATA(cl, obj);
1396 struct TagItem tags[] =
1398 {aHidd_Gfx_DPMSLevel, vHidd_Gfx_DPMSLevel_On},
1399 {TAG_DONE , 0 }
1402 return OOP_SetAttrs(data->handle->gfxhidd, tags);
1405 /************************************************************************************
1407 NAME
1408 MM_SetDefaultGammaTables
1410 SYNOPSIS
1411 DoMethod(Object *obj, ULONG MethodID, UBYTE *Red, UBYTE *Green, UBYTE *Blue);
1413 DoMethodA(Object *obj, struct msSetDefaultGammaTables *msg);
1415 LOCATION
1417 FUNCTION
1418 Set default gamma correction tables for the monitor
1420 INPUTS
1421 obj - A monitor object to query
1422 MethodID - MM_GetDefaultGammaTables
1423 Red - A pointer to an array of 256 bytes where gamma correction data for
1424 red component is placed. You may speciy a NULL pointer in order
1425 to ignore this component.
1426 Green - A pointer to an array of 256 bytes where gamma correction data for
1427 green component is placed. You may speciy a NULL pointer in order
1428 to ignore this component.
1429 Blue - A pointer to an array of 256 bytes where gamma correction data for
1430 blue component is placed. You may speciy a NULL pointer in order
1431 to ignore this component.
1433 RESULT
1434 Undefined.
1436 NOTES
1437 This method is AROS-specific.
1439 EXAMPLE
1441 BUGS
1443 SEE ALSO
1444 MM_GetDefaultGammaTables
1446 INTERNALS
1448 ************************************************************************************/
1450 IPTR MonitorClass__MM_SetDefaultGammaTables(Class *cl, Object *obj, struct msSetDefaultGammaTables *msg)
1452 struct MonitorData *data = INST_DATA(cl, obj);
1454 /* Currently we don't use per-screen gamma tables, so we just forward the request
1455 to the driver.
1456 If we implement per-screen gamma correction, we'll need more sophisticated
1457 management here */
1458 return HIDD_Gfx_SetGamma(data->handle->gfxhidd, msg->Red, msg->Green, msg->Blue);
1461 /************************************************************************************/
1463 ULONG MonitorClass__MM_GetCompositionFlags(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1465 struct MonitorData *data = INST_DATA(cl, obj);
1466 struct HIDD_ModeProperties modeprops;
1468 HIDD_Gfx_ModeProperties(data->handle->gfxhidd, msg->ModeID & (!data->handle->mask),
1469 &modeprops, sizeof(modeprops));
1470 return modeprops.CompositionFlags;
1473 /************************************************************************************/
1475 void MonitorClass__MM_SetPointerPos(Class *cl, Object *obj, struct msSetPointerPos *msg)
1477 struct MonitorData *data = INST_DATA(cl, obj);
1479 data->mouseX = msg->x;
1480 data->mouseY = msg->y;
1481 SetPointerPos(data, IntuitionBase);
1484 /************************************************************************************/
1486 BOOL MonitorClass__MM_CheckID(Class *cl, Object *obj, struct msGetCompositionFlags *msg)
1488 struct MonitorData *data = INST_DATA(cl, obj);
1490 return ((msg->ModeID & data->handle->mask) == data->handle->id);
1493 /************************************************************************************/
1495 BOOL MonitorClass__MM_SetPointerShape(Class *cl, Object *obj, struct msSetPointerShape *msg)
1497 struct MonitorData *data = INST_DATA(cl, obj);
1498 struct BitMap *bm;
1499 BOOL res;
1501 D(bug("[monitorclass] SetPointerShape(0x%p), old pointer 0x%p\n", msg->pointer, data->pointer));
1502 /* Don't do anything if already set */
1503 if (data->pointer == msg->pointer)
1504 return TRUE;
1506 bm = msg->pointer->sprite->es_BitMap;
1507 /* Currently we don't work with planar sprites */
1508 if (!(bm->Flags & BMF_SPECIALFMT))
1509 return FALSE;
1511 res = HIDD_Gfx_SetCursorShape(data->handle->gfxhidd, (OOP_Object *)bm->Planes[0], msg->pointer->xoffset, msg->pointer->yoffset);
1512 D(bug("[monitorclass] SetCursorShape() returned %d\n", res));
1513 if (res) {
1514 data->pointer = msg->pointer;
1515 /* This will fix up sprite position if hotspot changed */
1516 SetPointerPos(data, IntuitionBase);
1519 return res;