2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/exec.h>
8 #include <intuition/iprefs.h>
9 #include <intuition/pointerclass.h>
11 #include "intuition_intern.h"
12 #include <proto/intuition.h>
14 /*****************************************************************************
17 AROS_LH3(ULONG
, SetIPrefs
,
20 AROS_LHA(APTR
, data
, A0
),
21 AROS_LHA(ULONG
, length
, D0
),
22 AROS_LHA(ULONG
, type
, D1
),
25 struct IntuitionBase
*, IntuitionBase
, 96, Intuition
)
32 Depending on the operation
35 This function is currently considered private
47 *****************************************************************************/
52 ULONG lock
= LockIBase(0);
54 DEBUG_SETIPREFS(bug("SetIPrefs: data %p length %lu type %lu\n", data
, length
, type
));
58 case IPREFS_TYPE_ICONTROL
:
59 DEBUG_SETIPREFS(bug("SetIPrefs: IPREFS_TYPE_ICONTROL\n"));
60 if (length
> sizeof(struct IIControlPrefs
))
61 length
= sizeof(struct IIControlPrefs
);
62 CopyMem(data
, &GetPrivIBase(IntuitionBase
)->IControlPrefs
, length
);
64 DEBUG_SETIPREFS(bug("SetIPrefs: Drag modes: 0x%04lX\n", GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_VDragModes
[0]));
68 case IPREFS_TYPE_SCREENMODE
:
70 struct IScreenModePrefs old_prefs
;
72 DEBUG_SETIPREFS(bug("SetIPrefs: IP_SCREENMODE\n"));
73 if (length
> sizeof(struct IScreenModePrefs
))
74 length
= sizeof(struct IScreenModePrefs
);
76 if (memcmp(&GetPrivIBase(IntuitionBase
)->ScreenModePrefs
, data
,
77 sizeof(struct IScreenModePrefs
)) == 0)
80 old_prefs
= GetPrivIBase(IntuitionBase
)->ScreenModePrefs
;
81 GetPrivIBase(IntuitionBase
)->ScreenModePrefs
= *(struct IScreenModePrefs
*)data
;
83 if (GetPrivIBase(IntuitionBase
)->WorkBench
)
85 BOOL
try = TRUE
, closed
;
89 while (try && !(closed
= CloseWorkBench()))
91 struct EasyStruct es
=
93 sizeof(struct EasyStruct
),
96 "Intuition is attempting to reset the screen,\n"
97 "please close all windows except Wanderer's ones.",
101 try = EasyRequestArgs(NULL
, &es
, NULL
, NULL
) == 1;
105 /* FIXME: handle the error condition if OpenWorkBench() fails */
106 /* What to do if OpenWorkBench() fails? Try until it succeeds?
107 Try for a finite amount of times? Don't try and do nothing
113 GetPrivIBase(IntuitionBase
)->ScreenModePrefs
= old_prefs
;
125 case IPREFS_TYPE_POINTER
:
126 DEBUG_SETIPREFS(bug("SetIPrefs: IP_POINTER\n"));
128 struct IPointerPrefs
*fp
= data
;
129 struct TagItem pointertags
[] = {
130 {POINTERA_BitMap
, (IPTR
)fp
->BitMap
},
131 {POINTERA_XOffset
, fp
->XOffset
},
132 {POINTERA_YOffset
, fp
->YOffset
},
136 Object
*pointer
= NewObjectA(
137 GetPrivIBase(IntuitionBase
)->pointerclass
,
141 Object
**oldptr
= fp
->Which
?
142 &GetPrivIBase(IntuitionBase
)->BusyPointer
:
143 &GetPrivIBase(IntuitionBase
)->DefaultPointer
;
145 InstallPointer(IntuitionBase
, fp
->Which
, oldptr
, pointer
);
149 case IPREFS_TYPE_OLD_PALETTE
:
150 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDPALETTE\n"));
152 struct ColorSpec
*pp
= data
;
153 struct Color32
*p
= GetPrivIBase(IntuitionBase
)->Colors
;
154 BOOL update_pointer
= FALSE
;
155 struct Preferences
*ActivePrefs
= GetPrivIBase(IntuitionBase
)->ActivePreferences
;
157 DEBUG_SETIPREFS(bug("SetIPrefs: Intuition Color32 Table 0x%p\n", p
));
159 while (pp
->ColorIndex
!= -1)
161 DEBUG_SETIPREFS(bug("SetIPrefs: Index %ld Red 0x%04lX Green 0x%04lX Blue 0x%04lX\n",
162 pp
->ColorIndex
, pp
->Red
, pp
->Green
, pp
->Blue
));
163 if (pp
->ColorIndex
< COLORTABLEENTRIES
)
165 p
[pp
->ColorIndex
].red
= (pp
->Red
<<16)|pp
->Red
;
166 p
[pp
->ColorIndex
].green
= (pp
->Green
<<16)|pp
->Green
;
167 p
[pp
->ColorIndex
].blue
= (pp
->Blue
<<16)|pp
->Blue
;
169 /* Update oldstyle preferences */
175 if (pp
->ColorIndex
< 4) {
177 cols
= &ActivePrefs
->color0
;
178 } else if (pp
->ColorIndex
>= 8 && pp
->ColorIndex
<= 10) {
180 cols
=&ActivePrefs
->color17
;
181 update_pointer
= TRUE
;
185 cols
[pp
->ColorIndex
- baseindex
] = ((pp
->Red
>> 4) & 0xf00) | ((pp
->Green
>> 8) & 0x0f0) | (pp
->Blue
>> 12);
187 DEBUG_SETIPREFS(bug("SetIPrefs: Set Color32 %ld Red 0x%lx Green 0x%lx Blue 0x%lx\n",
188 (LONG
) pp
->ColorIndex
,
189 p
[pp
->ColorIndex
].red
,
190 p
[pp
->ColorIndex
].green
,
191 p
[pp
->ColorIndex
].blue
));
196 if (update_pointer
) {
197 DEBUG_SETIPREFS(bug("[SetIPrefs] Updating pointer colors\n"));
198 SetPointerColors(IntuitionBase
);
203 case IPREFS_TYPE_POINTER_ALPHA
:
204 GetPrivIBase(IntuitionBase
)->PointerAlpha
= *(UWORD
*)data
;
208 DEBUG_SETIPREFS(bug("SetIPrefs: Unknown Prefs Type\n"));
215 DEBUG_SETIPREFS(bug("SetIPrefs: Result 0x%lx\n",Result
));