2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Internal monitor database functions
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
11 #include "intuition_intern.h"
12 #include "monitorclass_private.h"
15 * Find a monitorclass object corresponsing to a given monitor ID.
17 void *FindMonitorNode(ULONG id
, struct IntuitionBase
*IntuitionBase
)
22 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
24 for (n
= GetPrivIBase(IntuitionBase
)->MonitorList
.mlh_Head
; n
->mln_Succ
; n
= n
->mln_Succ
)
26 if (DoMethod((Object
*)n
, MM_CheckID
, id
))
33 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
38 static void *FindMonitorByName(const char *name
, struct IntuitionBase
*IntuitionBase
)
42 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
43 ret
= FindName((struct List
*)&GetPrivIBase(IntuitionBase
)->MonitorList
, name
);
44 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
50 * Find the best monitor node according to either modeid or name.
51 * From MorphOS comments it can be suggested that MorphOS has a concept of
52 * display drivers family, to which several drivers may belong.
53 * In AROS we don't have this concept. So, this function is very simple and just
54 * looks up the object by either name or modeid. 'class' argument is ignored.
56 void *FindBestMonitorNode(void *class, const char *name
, ULONG modeid
, struct IntuitionBase
*IntuitionBase
)
60 if (modeid
== INVALID_ID
)
62 ret
= FindMonitorByName(name
, IntuitionBase
);
66 ret
= FindMonitorNode(modeid
, IntuitionBase
);
73 * Find the best monitor with 3D capabilities. Our "best" criteria is a special index,
74 * actually showing how much hardware 3D modes we support.
75 * This is purely experimental. Perhaps heuristics in OpenScreen() could be done better,
76 * however currently we try to follow MorphOS way.
78 void *FindBest3dMonitor(void *family
, struct IntuitionBase
*IntuitionBase
)
85 ObtainSemaphoreShared(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
87 for (n
= GetPrivIBase(IntuitionBase
)->MonitorList
.mlh_Head
; n
->mln_Succ
; n
= n
->mln_Succ
)
89 idx
= DoMethod((Object
*)n
, MM_Calc3dCapability
);
98 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->MonitorListSem
);
104 * Find best matching mode ID for the given monitor.
105 * The idea is simple. Convert name to ID then use BestModeIDA().
107 ULONG
FindBestModeID(const char *name
, ULONG depth
, ULONG width
, ULONG height
, struct IntuitionBase
*IntuitionBase
)
109 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
110 Object
*obj
= FindMonitorByName(name
, IntuitionBase
);
114 struct TagItem tags
[] =
116 {BIDTAG_MonitorID
, 0 },
117 {BIDTAG_DesiredWidth
, width
},
118 {BIDTAG_DesiredHeight
, height
},
119 {BIDTAG_Depth
, depth
},
123 GetAttr(MA_MonitorID
, obj
, &tags
[0].ti_Data
);
124 return BestModeIDA(tags
);