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>
9 #include <proto/utility.h>
11 #include "intuition_intern.h"
14 #define DEBUG_SYSREQHANDLER(x) ;
16 /*****************************************************************************
19 #include <proto/intuition.h>
20 #include <exec/types.h>
21 #include <intuition/intuition.h>
23 AROS_LH3(LONG
, SysReqHandler
,
26 AROS_LHA(struct Window
*, window
, A0
),
27 AROS_LHA(ULONG
*, IDCMPFlagsPtr
, A1
),
28 AROS_LHA(BOOL
, WaitInput
, D0
),
31 struct IntuitionBase
*, IntuitionBase
, 100, Intuition
)
34 Handles a requester, which was opened with BuildSysRequest() or
35 BuildEasyRequestArgs(). When this function is called all outstanding
36 IDCMP requests are processed. If an IDCMP request that would close
37 a normal EasyRequestArgs() is encountered, SysReqHandler() returns
38 with a return code equally to the return code EasyRequestArgs()
39 would have returned. You may call this function in synchronous or
40 asynchronous mode, by setting the WaitInput parameter.
43 Window - The window pointer returned by either BuildSysRequest() or
44 BuildEasyRequestArgs().
45 IDCMPFlagsPtr - Pointer to a ULONG to store the IDCMP flag that was
46 received by the window. This will be set if you
47 provided additional IDCMP flags to BuildSysRequest() or
48 BuildEasyRequest(). You may set this to NULL. You must
49 initialize the pointed to ULONG every time you call
51 WaitInput - Set this to TRUE, if you want this function to wait for
52 the next IDCMP request, if there is none at the moment
53 the function is called.
56 -2, if the requester was not satisfied. Normally you want to call
57 this function at least until this function returns something
59 -1, if one of the IDCMP flags of idcmpPTR was set.
60 0, if the rightmost button was clicked or an error occured.
61 n, if the n-th button from the left was clicked.
68 Gadget placing is still untidy.
69 Does not support BuildSysRequest() requesters, yet.
72 BuildSysRequest(), BuildEasyRequestArgs()
78 *****************************************************************************/
82 struct IntuiMessage
*msg
;
85 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: window 0x%lx IDCMPPtr 0x%lx WaitInput 0x%lx\n",
87 (ULONG
) IDCMPFlagsPtr
,
94 else if (window
== (struct Window
*)1)
104 WaitPort(window
->UserPort
);
106 while ((msg
= (struct IntuiMessage
*)GetMsg(window
->UserPort
)))
108 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: msg 0x%lx class 0x%lx\n", (ULONG
) msg
, msg
->Class
));
111 /* we don't use VANILLA (filtered from useridcmp!) to get
112 all events we need */
117 struct InputEvent ie
;
118 char rawbuffer
[RKBUFLEN
];
120 ie
.ie_Class
= IECLASS_RAWKEY
;
122 ie
.ie_Code
= msg
->Code
;
123 ie
.ie_Qualifier
= NULL
;
124 ie
.ie_EventAddress
= (APTR
*) *((ULONG
*)msg
->IAddress
);
126 if (KeymapBase
&& MapRawKey(&ie
,rawbuffer
,RKBUFLEN
,0))
128 if (msg
->Qualifier
& IEQUALIFIER_LCOMMAND
)
130 if (ToUpper(rawbuffer
[0]) == ToUpper(GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_ReqTrue
))
132 if (((struct IntRequestUserData
*)window
->UserData
)->NumGadgets
> 1)
142 if (ToUpper(rawbuffer
[0]) == ToUpper(GetPrivIBase(IntuitionBase
)->IControlPrefs
.ic_ReqFalse
))
152 result
= ((struct Gadget
*)msg
->IAddress
)->GadgetID
;
156 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: unknown IDCMP\n"));
159 if (msg
->Class
& ((struct IntRequestUserData
*)window
->UserData
)->IDCMP
)
161 if (IDCMPFlagsPtr
) *IDCMPFlagsPtr
= msg
->Class
;
167 ReplyMsg((struct Message
*)msg
);
169 } /* while ((msg = (struct IntuiMessage *)GetMsg(window->UserPort))) */
173 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: Result 0x%lx\n",result
));
178 } /* SysReqHandler() */