2 Copyright © 1995-2007, 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 <proto/keymap.h>
10 #include "intuition_intern.h"
11 #include "intuition_customizesupport.h"
12 #include "requesters.h"
16 #define DEBUG_SYSREQHANDLER(x) ;
18 /*****************************************************************************
21 #include <proto/intuition.h>
22 #include <exec/types.h>
23 #include <intuition/intuition.h>
25 AROS_LH3(LONG
, SysReqHandler
,
28 AROS_LHA(struct Window
*, window
, A0
),
29 AROS_LHA(ULONG
*, IDCMPFlagsPtr
, A1
),
30 AROS_LHA(BOOL
, WaitInput
, D0
),
33 struct IntuitionBase
*, IntuitionBase
, 100, Intuition
)
36 Handles a requester, which was opened with BuildSysRequest() or
37 BuildEasyRequestArgs(). When this function is called all outstanding
38 IDCMP requests are processed. If an IDCMP request that would close
39 a normal EasyRequestArgs() is encountered, SysReqHandler() returns
40 with a return code equally to the return code EasyRequestArgs()
41 would have returned. You may call this function in synchronous or
42 asynchronous mode, by setting the WaitInput parameter.
45 Window - The window pointer returned by either BuildSysRequest() or
46 BuildEasyRequestArgs().
47 IDCMPFlagsPtr - Pointer to a ULONG to store the IDCMP flag that was
48 received by the window. This will be set if you
49 provided additional IDCMP flags to BuildSysRequest() or
50 BuildEasyRequest(). You may set this to NULL. You must
51 initialize the pointed to ULONG every time you call
53 WaitInput - Set this to TRUE, if you want this function to wait for
54 the next IDCMP request, if there is none at the moment
55 the function is called.
58 -2, if the requester was not satisfied. Normally you want to call
59 this function at least until this function returns something
61 -1, if one of the IDCMP flags of idcmpPTR was set.
62 0, if the rightmost button was clicked or an error occured.
63 n, if the n-th button from the left was clicked.
70 Gadget placing is still untidy.
71 Does not support BuildSysRequest() requesters, yet.
74 BuildSysRequest(), BuildEasyRequestArgs()
80 *****************************************************************************/
85 struct IntuiMessage
*msg
;
86 struct IntRequestUserData
*udata
= (struct IntRequestUserData
*)window
->UserData
;
88 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: window 0x%lx IDCMPPtr 0x%lx WaitInput 0x%lx\n",
90 (ULONG
) IDCMPFlagsPtr
,
97 else if (window
== (struct Window
*)1)
107 WaitPort(window
->UserPort
);
109 while ((msg
= (struct IntuiMessage
*)GetMsg(window
->UserPort
)))
111 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: msg 0x%lx class 0x%lx\n", (ULONG
) msg
, msg
->Class
));
114 /* we don't use VANILLA (filtered from useridcmp!) to get
115 all events we need */
119 struct InputEvent ie
;
120 char rawbuffer
[RKBUFLEN
];
122 if (msg
->Code
& IECODE_UP_PREFIX
) break;
125 if (udata
->NumGadgets
> 1)
127 if (((msg
->Code
== 66) && (msg
->Qualifier
& (IEQUALIFIER_LSHIFT
| IEQUALIFIER_RSHIFT
))) ||
130 intrequest_hilightgadget(udata
,udata
->ActiveGad
,FALSE
,IntuitionBase
);
131 if (udata
->ActiveGad
> 0)
135 udata
->ActiveGad
= udata
->NumGadgets
- 1;
137 intrequest_hilightgadget(udata
,udata
->ActiveGad
,TRUE
,IntuitionBase
);
138 } else if ((msg
->Code
== 66) || (msg
->Code
== 78))
140 intrequest_hilightgadget(udata
,udata
->ActiveGad
,FALSE
,IntuitionBase
);
141 if (udata
->ActiveGad
< udata
->NumGadgets
- 1)
145 udata
->ActiveGad
= 0;
147 intrequest_hilightgadget(udata
,udata
->ActiveGad
,TRUE
,IntuitionBase
);
151 ie
.ie_Class
= IECLASS_RAWKEY
;
153 ie
.ie_Code
= msg
->Code
;
155 ie
.ie_EventAddress
= (APTR
*) *((ULONG
*)msg
->IAddress
);
157 if (KeymapBase
&& MapRawKey(&ie
,rawbuffer
,RKBUFLEN
,0))
159 if (rawbuffer
[0] == 13) //enter key
161 if (udata
->ActiveGad
!= udata
->NumGadgets
- 1)
163 result
= udata
->ActiveGad
+ 1;
169 if (rawbuffer
[0] == 27) //escape key
175 ie
.ie_Qualifier
= msg
->Qualifier
;
176 if (MatchHotkey(&ie
,IA_REQUESTERCANCEL
,IntuitionBase
)) result
= 0;
178 if (MatchHotkey(&ie
,IA_REQUESTEROK
,IntuitionBase
))
180 if (((struct IntRequestUserData
*)window
->UserData
)->NumGadgets
> 1)
191 result
= ((struct Gadget
*)msg
->IAddress
)->GadgetID
;
194 case IDCMP_REFRESHWINDOW
:
195 BeginRefresh(window
);
196 intrequest_drawrequester(udata
,IntuitionBase
);
197 EndRefresh(window
,TRUE
);
201 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: unknown IDCMP\n"));
205 ((struct IntRequestUserData
*)window
->UserData
)->IDCMP
)
208 *IDCMPFlagsPtr
= msg
->Class
;
214 ReplyMsg((struct Message
*)msg
);
216 } /* while ((msg = (struct IntuiMessage *)GetMsg(window->UserPort))) */
220 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: Result 0x%lx\n",result
));
224 } /* SysReqHandler() */