Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / intuition / screenclass.c
blob3a58e72594a6484aaed9af5dc7d222e36d30ff5b
1 /*
2 Copyright © 2013-2014, 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 "intuition_customize.h"
25 #include "monitorclass_private.h"
27 /*i***************************************************************************
29 NAME
30 --background_screenclass--
32 LOCATION
33 screenclass
35 NOTES
36 In AROS screens are BOOPSI objects. It is possible to modify certain
37 properties of the screen by using the SetAttrs() and GetAttr()
38 functions. screenclass by itself is private to the system and does not
39 have a public ID. The user can't create objects of this class
40 manually. Screens are created and destroyed as usual, using
41 the OpenScreen() and CloseScreen() functions.
43 This class is fully compatible with MorphOS starting from v2.x.
45 *****************************************************************************/
47 IPTR ScreenClass__OM_DISPOSE(Class *cl, Object *o, Msg msg)
49 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
50 struct IntScreen *screen = INST_DATA(cl, o);
52 /* Free decoration objects */
53 DisposeObject(screen->WinDecorObj);
54 DisposeObject(screen->MenuDecorObj);
55 DisposeObject(screen->ScrDecorObj);
57 /* Free decoration buffer */
58 FreeMem((APTR)screen->DecorUserBuffer, screen->DecorUserBufferSize);
60 if ((screen->Decorator != ((struct IntIntuitionBase *)(IntuitionBase))->Decorator) &&
61 (screen->Decorator != NULL))
63 struct NewDecorator *nd = screen->Decorator;
65 ObtainSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
67 nd->nd_cnt--;
68 if (nd->nd_IntPattern == NULL)
71 * If no pattern is defined, we assume it was old default decorator
72 * which fell out of use. Unload it.
74 int_UnloadDecorator(nd, IntuitionBase);
77 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
80 return DoSuperMethodA(cl, o, msg);
83 static IPTR GetScreen(ULONG attrID, struct IntScreen *screen, struct IntuitionBase *IntuitionBase)
85 Object *mon;
87 GetAttr(attrID, screen->IMonitorNode, (IPTR *)&mon);
89 if (mon)
91 ULONG lock = LockIBase(0);
92 struct Screen *ret = FindFirstScreen(mon, IntuitionBase);
94 if (ret && ((ret->Flags & SCREENTYPE) == CUSTOMSCREEN))
96 /* We want only public screens */
97 ret = NULL;
100 UnlockIBase(lock);
102 return (IPTR)ret;
105 return 0;
108 /*i***************************************************************************
110 NAME
111 SA_Left
113 SYNOPSIS
114 [ISG], LONG
116 LOCATION
117 screenclass
119 FUNCTION
120 Position of left edge of the screen relative to top-left physical
121 display corner.
123 NOTES
125 EXAMPLE
127 BUGS
129 SEE ALSO
131 INTERNALS
133 *****************************************************************************/
135 /*i***************************************************************************
137 NAME
138 SA_Top
140 SYNOPSIS
141 [ISG], LONG
143 LOCATION
144 screenclass
146 FUNCTION
147 Position of top edge of the screen relative to top-left physical
148 display corner.
150 NOTES
152 EXAMPLE
154 BUGS
156 SEE ALSO
158 INTERNALS
160 *****************************************************************************/
161 /*i***************************************************************************
163 NAME
164 SA_Width
166 SYNOPSIS
167 [I.G], LONG
169 LOCATION
170 screenclass
172 FUNCTION
173 Width of the screen (not display) in pixels.
175 NOTES
177 EXAMPLE
179 BUGS
181 SEE ALSO
183 INTERNALS
185 *****************************************************************************/
187 /*i***************************************************************************
189 NAME
190 SA_Height
192 SYNOPSIS
193 [I.G], LONG
195 LOCATION
196 screenclass
198 FUNCTION
199 Height of the screen (not display) in pixels.
201 NOTES
203 EXAMPLE
205 BUGS
207 SEE ALSO
209 INTERNALS
211 *****************************************************************************/
213 /*i***************************************************************************
215 NAME
216 SA_Depth
218 SYNOPSIS
219 [I.G], LONG
221 LOCATION
222 screenclass
224 FUNCTION
225 Depth of the screen.
227 NOTES
228 This attribute returns the real depth; however, old structure fields,
229 for example screen->RastPort.BitMap->bm_Depth, in case of direct-color
230 screens will contain 8 for purposes of backwards compatibility.
232 EXAMPLE
234 BUGS
236 SEE ALSO
238 INTERNALS
240 *****************************************************************************/
242 /*i***************************************************************************
244 NAME
245 SA_PubName
247 SYNOPSIS
248 [I.G], STRPTR
250 LOCATION
251 screenclass
253 FUNCTION
254 Public screen name (system name, not human-readable title).
256 NOTES
258 EXAMPLE
260 BUGS
262 SEE ALSO
264 INTERNALS
266 *****************************************************************************/
268 /*i***************************************************************************
270 NAME
271 SA_DisplayID
273 SYNOPSIS
274 [I.G], LONG
276 LOCATION
277 screenclass
279 FUNCTION
280 Display mode ID of the screen.
282 NOTES
284 EXAMPLE
286 BUGS
288 SEE ALSO
290 INTERNALS
292 *****************************************************************************/
294 /*i***************************************************************************
296 NAME
297 SA_Behind
299 SYNOPSIS
300 [I.G], LONG
302 LOCATION
303 screenclass
305 FUNCTION
306 Supplying this attribute during screen creation (to OpenScreen() or
307 OpenScreenTagList() functions) causes this screen to be created and
308 opened behind all other screens.
310 Querying this attribute returns its initial value.
312 NOTES
314 EXAMPLE
316 BUGS
318 SEE ALSO
320 INTERNALS
322 *****************************************************************************/
324 /*i***************************************************************************
326 NAME
327 SA_MonitorName
329 SYNOPSIS
330 [I.G], LONG
332 LOCATION
333 screenclass
335 FUNCTION
336 Name of the monitorclass object (AKA display device name) to which
337 this screen belongs.
339 NOTES
341 EXAMPLE
343 BUGS
345 SEE ALSO
346 SA_MonitorObject
348 INTERNALS
350 *****************************************************************************/
352 /*i***************************************************************************
354 NAME
355 SA_MonitorObject
357 SYNOPSIS
358 [..G], Object *
360 LOCATION
361 screenclass
363 FUNCTION
364 Returns display device (monitorclass) object to which this screen
365 belongs.
367 NOTES
369 EXAMPLE
371 BUGS
373 SEE ALSO
374 SA_MonitorName
376 INTERNALS
378 *****************************************************************************/
380 /*i***************************************************************************
382 NAME
383 SA_TopLeftScreen
385 SYNOPSIS
386 [..G], struct Screen *
388 LOCATION
389 screenclass
391 FUNCTION
392 Get a pointer to a public screen displayed on a monitor placed in
393 top-left diagonal direction relative to this screen's one. If the
394 frontmost screen on the given monitor is not public, NULL will be
395 returned.
397 NOTES
398 AROS supports screen composition, so more than one screen is actually
399 displayed at any given time. In order to match MorphOS semantics this
400 attribute takes into account only the frontmost screen on the given
401 monitor.
403 EXAMPLE
405 BUGS
407 SEE ALSO
408 monitorclass/MA_TopLeftMonitor
410 INTERNALS
412 *****************************************************************************/
414 /*i***************************************************************************
416 NAME
417 SA_TopMiddleScreen
419 SYNOPSIS
420 [..G], struct Screen *
422 LOCATION
423 screenclass
425 FUNCTION
426 Get a pointer to a public screen displayed on a monitor placed in top
427 direction relative to this screen's one. If the frontmost screen on
428 the given monitor is not public, NULL will be returned.
430 NOTES
431 AROS supports screen composition, so more than one screen is actually
432 displayed at any given time. In order to match MorphOS semantics this
433 attribute takes into account only the frontmost screen on the given
434 monitor.
436 EXAMPLE
438 BUGS
440 SEE ALSO
441 monitorclass/MA_TopMiddleMonitor
443 INTERNALS
445 *****************************************************************************/
447 /*i***************************************************************************
449 NAME
450 SA_TopRightScreen
452 SYNOPSIS
453 [..G], struct Screen *
455 LOCATION
456 screenclass
458 FUNCTION
459 Get a pointer to a screen displayed on a monitor placed in top-right
460 diagonal direction relative to this screen's one. If the frontmost
461 screen on the given monitor is not public, NULL will be returned.
463 NOTES
464 AROS supports screen composition, so more than one screen is actually
465 displayed at any given time. In order to match MorphOS semantics this
466 attribute takes into account only the frontmost screen on the given
467 monitor.
469 EXAMPLE
471 BUGS
473 SEE ALSO
474 monitorclass/MA_TopRightMonitor
476 INTERNALS
478 *****************************************************************************/
480 /*i***************************************************************************
482 NAME
483 SA_MiddleLeftScreen
485 SYNOPSIS
486 [..G], struct Screen *
488 LOCATION
489 screenclass
491 FUNCTION
492 Get a pointer to a public screen displayed on a monitor placed in left
493 direction relative to this screen's one. If the frontmost screen on
494 the given monitor is not public, NULL will be returned.
496 NOTES
497 AROS supports screen composition, so more than one screen is actually
498 displayed at any given time. In order to match MorphOS semantics this
499 attribute takes into account only the frontmost screen on the given
500 monitor.
502 EXAMPLE
504 BUGS
506 SEE ALSO
507 monitorclass/MA_MiddleLeftMonitor
509 INTERNALS
511 *****************************************************************************/
513 /*i***************************************************************************
515 NAME
516 SA_MiddleRightScreen
518 SYNOPSIS
519 [..G], struct Screen *
521 LOCATION
522 screenclass
524 FUNCTION
525 Get a pointer to a public screen displayed on a monitor placed in left
526 direction relative to this screen's one. If the frontmost screen on
527 the given monitor is not public, NULL will be returned.
529 NOTES
530 AROS supports screen composition, so more than one screen is actually
531 displayed at any given time. In order to match MorphOS semantics this
532 attribute takes into account only the frontmost screen on the given
533 monitor.
535 EXAMPLE
537 BUGS
539 SEE ALSO
540 monitorclass/MA_MiddleRightMonitor
542 INTERNALS
544 *****************************************************************************/
546 /*i***************************************************************************
548 NAME
549 SA_BottomLeftScreen
551 SYNOPSIS
552 [..G], struct Screen *
554 LOCATION
555 screenclass
557 FUNCTION
558 Get a pointer to a public screen displayed on a monitor placed in
559 bottom-left diagonal direction relative to this screen's one. If the
560 frontmost screen on the given monitor is not public, NULL will be
561 returned.
563 NOTES
564 AROS supports screen composition, so more than one screen is actually
565 displayed at any given time. In order to match MorphOS semantics this
566 attribute takes into account only the frontmost screen on the given
567 monitor.
569 EXAMPLE
571 BUGS
573 SEE ALSO
574 monitorclass/MA_BottomLeftMonitor
576 INTERNALS
578 *****************************************************************************/
580 /*i***************************************************************************
582 NAME
583 SA_BottomMiddleScreen
585 SYNOPSIS
586 [..G], struct Screen *
588 LOCATION
589 screenclass
591 FUNCTION
592 Get a pointer to a public screen displayed on a monitor placed in
593 bottom direction relative to this screen's one. If the frontmost
594 screen on the given monitor is not public, NULL will be returned.
596 NOTES
597 AROS supports screen composition, so more than one screen is actually
598 displayed at any given time. In order to match MorphOS semantics this
599 attribute takes into account only the frontmost screen on the given
600 monitor.
602 EXAMPLE
604 BUGS
606 SEE ALSO
607 monitorclass/MA_BottomMiddleMonitor
609 INTERNALS
611 *****************************************************************************/
613 /*i***************************************************************************
615 NAME
616 SA_BottomRightScreen
618 SYNOPSIS
619 [..G], struct Screen *
621 LOCATION
622 screenclass
624 FUNCTION
625 Get a pointer to a screen displayed on a monitor placed in
626 bottom-right diagonal direction relative to this screen's one. If the
627 frontmost screen on the given monitor is not public, NULL will be
628 returned.
630 NOTES
631 AROS supports screen composition, so more than one screen is actually
632 displayed at any given time. In order to match MorphOS semantics this
633 attribute takes into account only the frontmost screen on the given
634 monitor.
636 EXAMPLE
638 BUGS
640 SEE ALSO
641 monitorclass/MA_BottomRightMonitor
643 INTERNALS
645 *****************************************************************************/
647 /*i***************************************************************************
649 NAME
650 SA_StopBlanker
652 SYNOPSIS
653 [S..], BOOL
655 LOCATION
656 screenclass
658 FUNCTION
659 This attribute is currently reserved and exists only for source
660 compatibility with MorphOS.
662 NOTES
664 EXAMPLE
666 BUGS
668 SEE ALSO
670 INTERNALS
672 *****************************************************************************/
674 /*i***************************************************************************
676 NAME
677 SA_ShowPointer
679 SYNOPSIS
680 [ISG], BOOL
682 LOCATION
683 screenclass
685 FUNCTION
686 Setting this attribute to FALSE makes mouse pointer invisible on your
687 custom screen. The default value is TRUE. Setting this attribute on
688 public screens is ignored.
690 NOTES
692 EXAMPLE
694 BUGS
696 SEE ALSO
698 INTERNALS
700 *****************************************************************************/
702 /*i***************************************************************************
704 NAME
705 SA_GammaControl
707 SYNOPSIS
708 [I..], BOOL
710 LOCATION
711 screenclass
713 FUNCTION
714 Setting this attribute to TRUE enables use of the SA_GammaRed,
715 SA_GammaBlue and SA_GammaGreen attributes to supply a custom gamma
716 correction table for your screen.
718 NOTES
719 Since in AROS more than one screen can be visible simultaneously, the
720 current display gamma correction table is determined by the frontmost
721 screen on that display.
723 EXAMPLE
725 BUGS
727 SEE ALSO
729 INTERNALS
731 *****************************************************************************/
733 IPTR ScreenClass__OM_GET(Class *cl, Object *o, struct opGet *msg)
735 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
736 struct Library *OOPBase = GetPrivIBase(IntuitionBase)->OOPBase;
737 OOP_AttrBase HiddBitMapAttrBase = GetPrivIBase(IntuitionBase)->HiddAttrBase;
738 OOP_AttrBase HiddPixFmtAttrBase = GetPrivIBase(IntuitionBase)->HiddPixFmtAttrBase;
739 struct IntScreen *screen = INST_DATA(cl, o);
741 switch (msg->opg_AttrID)
743 case SA_Left:
744 *msg->opg_Storage = screen->Screen.LeftEdge;
745 break;
747 case SA_Top:
748 *msg->opg_Storage = screen->Screen.TopEdge;
749 break;
751 case SA_Width:
752 *msg->opg_Storage = screen->Screen.Width;
753 break;
755 case SA_Height:
756 *msg->opg_Storage = screen->Screen.Height;
757 break;
759 case SA_Depth:
760 *msg->opg_Storage = screen->realdepth;
761 break;
763 case SA_PubName:
764 *msg->opg_Storage = (IPTR)screen->pubScrNode->psn_Node.ln_Name;
765 break;
767 case SA_DisplayID:
768 *msg->opg_Storage = screen->ModeID;
769 break;
771 case SA_Behind:
772 *msg->opg_Storage = (screen->Screen.Flags & SCREENBEHIND) ? TRUE : FALSE;
773 break;
775 case SA_Displayed:
776 *msg->opg_Storage = screen->GammaControl.Active;
777 break;
779 case SA_MonitorName:
780 return GetAttr(MA_MonitorName, screen->IMonitorNode, msg->opg_Storage);
782 case SA_MonitorObject:
783 *msg->opg_Storage = (IPTR)screen->IMonitorNode;
784 break;
786 case SA_TopLeftScreen:
787 *msg->opg_Storage = GetScreen(MA_TopLeftMonitor, screen, IntuitionBase);
788 break;
790 case SA_TopMiddleScreen:
791 *msg->opg_Storage = GetScreen(MA_TopMiddleMonitor, screen, IntuitionBase);
792 break;
794 case SA_TopRightScreen:
795 *msg->opg_Storage = GetScreen(MA_TopRightMonitor, screen, IntuitionBase);
796 break;
798 case SA_MiddleLeftScreen:
799 *msg->opg_Storage = GetScreen(MA_MiddleLeftMonitor, screen, IntuitionBase);
800 break;
802 case SA_MiddleRightScreen:
803 *msg->opg_Storage = GetScreen(MA_MiddleRightMonitor, screen, IntuitionBase);
804 break;
806 case SA_BottomLeftScreen:
807 *msg->opg_Storage = GetScreen(MA_BottomLeftMonitor, screen, IntuitionBase);
808 break;
810 case SA_BottomMiddleScreen:
811 *msg->opg_Storage = GetScreen(MA_BottomMiddleMonitor, screen, IntuitionBase);
812 break;
814 case SA_BottomRightScreen:
815 *msg->opg_Storage = GetScreen(MA_BottomRightMonitor, screen, IntuitionBase);
816 break;
818 case SA_ShowPointer:
819 *msg->opg_Storage = screen->ShowPointer;
820 break;
822 case SA_GammaRed:
823 *msg->opg_Storage = (IPTR)screen->GammaControl.GammaTableR;
824 break;
826 case SA_GammaBlue:
827 *msg->opg_Storage = (IPTR)screen->GammaControl.GammaTableB;
828 break;
830 case SA_GammaGreen:
831 *msg->opg_Storage = (IPTR)screen->GammaControl.GammaTableG;
832 break;
834 case SA_DisplayWidth:
835 *msg->opg_Storage = screen->Screen.ViewPort.DWidth;
836 break;
838 case SA_DisplayHeight:
839 *msg->opg_Storage = screen->Screen.ViewPort.DHeight;
840 break;
842 case SA_PixelFormat:
843 if (IS_HIDD_BM(screen->Screen.RastPort.BitMap))
845 OOP_Object *pixfmt;
847 OOP_GetAttr(HIDD_BM_OBJ(screen->Screen.RastPort.BitMap), aHidd_BitMap_PixFmt, (IPTR *)&pixfmt);
848 OOP_GetAttr(pixfmt, aHidd_PixFmt_CgxPixFmt, msg->opg_Storage);
850 else
852 *msg->opg_Storage = -1;
854 break;
856 case SA_ScreenbarTextYPos:
857 *msg->opg_Storage = screen->Screen.BarVBorder + screen->Screen.BarLayer->rp->TxBaseline;
858 break;
860 case SA_ScreenbarTextPen:
861 *msg->opg_Storage = screen->Pens[BARDETAILPEN];
862 break;
864 case SA_ScreenbarTextFont:
865 *msg->opg_Storage = (IPTR)screen->Screen.BarLayer->rp->Font;
866 break;
868 case SA_CompositingFlags:
869 *msg->opg_Storage = (IPTR)(screen->SpecialFlags >> 8);
870 break;
872 case SA_AlphaPreCompositingHook:
873 *msg->opg_Storage = (IPTR)screen->preAlphaCompHook;
874 break;
876 case SA_OpacitySupport: /* These are reserved in AROS */
877 case SA_SourceAlphaSupport:
878 case SA_ScreenbarSignal:
879 case SA_CompositingLayers:
880 *msg->opg_Storage = 0;
881 break;
883 default:
884 return FALSE;
887 return TRUE;
890 IPTR ScreenClass__OM_SET(Class *cl, Object *o, struct opSet *msg)
892 struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData;
893 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
894 struct IntScreen *screen = INST_DATA(cl, o);
895 struct TagItem *tstate = msg->ops_AttrList;
896 struct TagItem *tag;
897 BOOL showpointer = screen->ShowPointer;
898 BOOL movescreen = FALSE;
899 BOOL gammaset = FALSE;
901 while((tag = NextTagItem(&tstate)))
903 switch (tag->ti_Tag)
905 case SA_Left:
906 if (screen->SpecialFlags & SF_Draggable)
908 screen->Screen.LeftEdge = tag->ti_Data;
909 movescreen = TRUE;
911 break;
913 case SA_Top:
914 if (screen->SpecialFlags & SF_Draggable)
916 screen->Screen.TopEdge = tag->ti_Data;
917 movescreen = TRUE;
919 break;
921 case SA_ShowPointer:
922 showpointer = tag->ti_Data;
923 break;
925 case SA_GammaRed:
926 if (screen->GammaControl.UseGammaControl)
928 screen->GammaControl.GammaTableR = (UBYTE *)tag->ti_Data;
929 gammaset = TRUE;
931 break;
933 case SA_GammaBlue:
934 if (screen->GammaControl.UseGammaControl)
936 screen->GammaControl.GammaTableB = (UBYTE *)tag->ti_Data;
937 gammaset = TRUE;
939 break;
941 case SA_GammaGreen:
942 if (screen->GammaControl.UseGammaControl)
944 screen->GammaControl.GammaTableG = (UBYTE *)tag->ti_Data;
945 gammaset = TRUE;
947 break;
949 case SA_AlphaPreCompositingHook:
951 screen->preAlphaCompHook = (struct Hook *)tag->ti_Data;
953 break;
957 if (movescreen)
960 * Move the screen to (0, 0) relative of current position.
961 * LeftEdge/TopEdge have been already updated.
963 ScreenPosition(&screen->Screen, SPOS_RELATIVE, 0, 0, 0, 0);
966 if (showpointer != screen->ShowPointer)
968 screen->ShowPointer = showpointer;
969 /* TODO: Actually implement this */
972 if (gammaset)
975 * Update gamma table on the monitor.
976 * The monitorclass takes care itself about whether this screen
977 * currently controlls gamma table.
979 DoMethod((Object *)screen->IMonitorNode, MM_SetScreenGamma, &GetPrivScreen(screen)->GammaControl, FALSE);
982 return 0;