some fixes to accented characters
[tangerine.git] / rom / intuition / sysreqhandler_aros.c
blobe126942e155325f5fdc54269d7edeee5de07877f
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
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 /*****************************************************************************
18 NAME */
19 #include <proto/intuition.h>
20 #include <exec/types.h>
21 #include <intuition/intuition.h>
23 AROS_LH3(LONG, SysReqHandler,
25 /* SYNOPSIS */
26 AROS_LHA(struct Window *, window, A0),
27 AROS_LHA(ULONG *, IDCMPFlagsPtr, A1),
28 AROS_LHA(BOOL , WaitInput, D0),
30 /* LOCATION */
31 struct IntuitionBase *, IntuitionBase, 100, Intuition)
33 /* FUNCTION
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.
42 INPUTS
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
50 SysReqHandler().
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.
55 RESULT
56 -2, if the requester was not satisfied. Normally you want to call
57 this function at least until this function returns something
58 different than -2.
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.
63 NOTES
65 EXAMPLE
67 BUGS
68 Gadget placing is still untidy.
69 Does not support BuildSysRequest() requesters, yet.
71 SEE ALSO
72 BuildSysRequest(), BuildEasyRequestArgs()
74 INTERNALS
76 HISTORY
78 *****************************************************************************/
80 AROS_LIBFUNC_INIT
82 struct IntuiMessage *msg;
83 LONG result;
85 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: window 0x%lx IDCMPPtr 0x%lx WaitInput 0x%lx\n",
86 (ULONG) window,
87 (ULONG) IDCMPFlagsPtr,
88 (ULONG) WaitInput));
90 if (window == 0)
92 result = 0;
94 else if (window == (struct Window *)1)
96 result = 1;
98 else
100 result = -2;
102 if (WaitInput)
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));
109 switch (msg->Class)
111 /* we don't use VANILLA (filtered from useridcmp!) to get
112 all events we need */
113 case IDCMP_RAWKEY:
115 #define RKBUFLEN 1
117 struct InputEvent ie;
118 char rawbuffer[RKBUFLEN];
120 ie.ie_Class = IECLASS_RAWKEY;
121 ie.ie_SubClass = 0;
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)
134 result = 1;
136 else
138 result = 0;
142 if (ToUpper(rawbuffer[0]) == ToUpper(GetPrivIBase(IntuitionBase)->IControlPrefs.ic_ReqFalse))
144 result = 0;
148 break;
151 case IDCMP_GADGETUP:
152 result = ((struct Gadget *)msg->IAddress)->GadgetID;
153 break;
155 default:
156 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: unknown IDCMP\n"));
157 if (result == -2)
159 if (msg->Class & ((struct IntRequestUserData *)window->UserData)->IDCMP)
161 if (IDCMPFlagsPtr) *IDCMPFlagsPtr = msg->Class;
162 result = -1;
165 break;
167 ReplyMsg((struct Message *)msg);
169 } /* while ((msg = (struct IntuiMessage *)GetMsg(window->UserPort))) */
171 } /* real window */
173 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: Result 0x%lx\n",result));
175 return result;
177 AROS_LIBFUNC_EXIT
178 } /* SysReqHandler() */