Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / request.c
blob18fd997972ab5282cfca15ec8233be529b4be4a5
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/layers.h>
8 #include "intuition_intern.h"
9 #include "inputhandler_actions.h"
11 struct RequestActionMsg
13 struct IntuiActionMsg msg;
14 struct Requester *requester;
15 struct Window *window;
16 BOOL success;
19 static VOID int_request(struct RequestActionMsg *msg,
20 struct IntuitionBase *IntuitionBase);
22 /*****************************************************************************
24 NAME */
25 #include <proto/intuition.h>
27 AROS_LH2(BOOL, Request,
29 /* SYNOPSIS */
30 AROS_LHA(struct Requester *, requester, A0),
31 AROS_LHA(struct Window * , window, A1),
33 /* LOCATION */
34 struct IntuitionBase *, IntuitionBase, 40, Intuition)
36 /* FUNCTION
37 Add a requester to specified window and display it.
39 INPUTS
40 requester - The requester to be displayed
41 window - The window to which the requester belongs
43 RESULT
44 TRUE if requester was opened successfully, FALSE else.
46 NOTES
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 EndRequest(), InitRequester()
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct RequestActionMsg msg;
65 DEBUG_REQUEST(dprintf("Request: requester 0x%lx window 0x%lx\n", requester, window));
67 SANITY_CHECKR(window,FALSE)
68 SANITY_CHECKR(requester,FALSE)
70 msg.window = window;
71 msg.requester = requester;
73 DoSyncAction((APTR)int_request, &msg.msg, IntuitionBase);
75 DEBUG_REQUEST(dprintf("Request: requester (layer 0x%lx) setup %d\n",requester->ReqLayer,msg.success));
77 return msg.success;
79 AROS_LIBFUNC_EXIT
80 } /* Request */
83 static VOID int_request(struct RequestActionMsg *msg,
84 struct IntuitionBase *IntuitionBase)
86 struct Requester *requester = msg->requester;
87 struct Window *window = msg->window;
88 //ULONG layerflags = 0;
89 int left, top, right, bottom;
90 //LONG lock;
91 struct Gadget *gadgets;
92 int wleft = window->LeftEdge + window->BorderLeft;
93 int wtop = window->TopEdge + window->BorderTop;
94 int wright = window->LeftEdge + window->Width - window->BorderRight- 1;
95 int wbottom = window->TopEdge + window->Height - window->BorderBottom- 1;
97 if (requester->Flags & POINTREL)
99 if (requester == window->DMRequest)
101 left = window->LeftEdge + window->MouseX + requester->RelLeft;
102 top = window->TopEdge + window->MouseY + requester->RelTop;
103 if (left + requester->Width - 1 > wright)
104 left = wright - requester->Width + 1;
105 if (top + requester->Height - 1 > wbottom)
106 top = wbottom - requester->Height + 1;
108 else
110 left = (wleft + wright - requester->Width) >> 1;
111 top = (wtop + wbottom - requester->Height) >> 1;
112 left += requester->RelLeft;
113 top += requester->RelTop;
116 else
118 left = wleft + requester->LeftEdge;
119 top = wtop + requester->TopEdge;
122 if (left < wleft)
123 left = wleft;
124 else if (left > wright)
125 left = wright;
127 if (top < wtop)
128 top = wtop;
129 else if (top > wbottom)
130 top = wbottom;
132 right = left + requester->Width - 1;
133 bottom = top + requester->Height - 1;
135 if (right > wright)
136 right = wright;
138 if (bottom > wbottom)
139 bottom = wbottom;
141 requester->ReqLayer = NULL;
143 if ((right >= left) && (bottom >= top))
145 requester->ReqLayer = CreateUpfrontHookLayer(
146 &window->WScreen->LayerInfo
147 , window->WScreen->RastPort.BitMap
148 , left
149 , top
150 , right
151 , bottom
152 , (requester->Flags & SIMPLEREQ ? LAYERSIMPLE : LAYERSMART)
153 , LAYERS_NOBACKFILL
154 , NULL);
157 if (requester->ReqLayer)
159 requester->ReqLayer->Window = window;
160 requester->RWindow = window;
162 requester->LeftEdge = left - wleft;
163 requester->TopEdge = top - wtop;
165 gadgets = requester->ReqGadget;
166 requester->ReqGadget = NULL;
168 requester->OlderRequest = window->FirstRequest;
169 window->FirstRequest = requester;
170 ++window->ReqCount;
171 requester->Flags |= REQACTIVE;
173 AddGList(window, gadgets, 0, -1, requester);
175 render_requester(requester, IntuitionBase);
177 msg->success = TRUE;
179 else
181 msg->success = FALSE;