Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / intuition / request.c
bloba654d88ecf781a786161bcb47d62e26bbbead98d
1 /*
2 Copyright © 1995-2013, 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 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct RequestActionMsg msg;
63 DEBUG_REQUEST(dprintf("Request: requester 0x%lx window 0x%lx\n", requester, window));
65 SANITY_CHECKR(window,FALSE)
66 SANITY_CHECKR(requester,FALSE)
68 msg.window = window;
69 msg.requester = requester;
71 DoSyncAction((APTR)int_request, &msg.msg, IntuitionBase);
73 DEBUG_REQUEST(dprintf("Request: requester (layer 0x%lx) setup %d\n",requester->ReqLayer,msg.success));
75 return msg.success;
77 AROS_LIBFUNC_EXIT
78 } /* Request */
81 static VOID int_request(struct RequestActionMsg *msg,
82 struct IntuitionBase *IntuitionBase)
84 struct LayersBase *LayersBase = GetPrivIBase(IntuitionBase)->LayersBase;
85 struct Requester *requester = msg->requester;
86 struct Window *window = msg->window;
87 //ULONG layerflags = 0;
88 int left, top, right, bottom;
89 //LONG lock;
90 struct Gadget *gadgets;
91 int wleft = window->LeftEdge + window->BorderLeft;
92 int wtop = window->TopEdge + window->BorderTop;
93 int wright = window->LeftEdge + window->Width - window->BorderRight- 1;
94 int wbottom = window->TopEdge + window->Height - window->BorderBottom- 1;
96 if (requester->Flags & POINTREL)
98 if (requester == window->DMRequest)
100 left = window->LeftEdge + window->MouseX + requester->RelLeft;
101 top = window->TopEdge + window->MouseY + requester->RelTop;
102 if (left + requester->Width - 1 > wright)
103 left = wright - requester->Width + 1;
104 if (top + requester->Height - 1 > wbottom)
105 top = wbottom - requester->Height + 1;
107 else
109 left = (wleft + wright - requester->Width) >> 1;
110 top = (wtop + wbottom - requester->Height) >> 1;
111 left += requester->RelLeft;
112 top += requester->RelTop;
115 else
117 left = wleft + requester->LeftEdge;
118 top = wtop + requester->TopEdge;
121 if (left < wleft)
122 left = wleft;
123 else if (left > wright)
124 left = wright;
126 if (top < wtop)
127 top = wtop;
128 else if (top > wbottom)
129 top = wbottom;
131 right = left + requester->Width - 1;
132 bottom = top + requester->Height - 1;
134 if (right > wright)
135 right = wright;
137 if (bottom > wbottom)
138 bottom = wbottom;
140 requester->ReqLayer = NULL;
142 if ((right >= left) && (bottom >= top))
144 requester->ReqLayer = CreateUpfrontHookLayer(
145 &window->WScreen->LayerInfo
146 , window->WScreen->RastPort.BitMap
147 , left
148 , top
149 , right
150 , bottom
151 , (requester->Flags & SIMPLEREQ ? LAYERSIMPLE : LAYERSMART)
152 , LAYERS_NOBACKFILL
153 , NULL);
156 if (requester->ReqLayer)
158 requester->ReqLayer->Window = window;
159 requester->RWindow = window;
161 requester->LeftEdge = left - wleft;
162 requester->TopEdge = top - wtop;
164 gadgets = requester->ReqGadget;
165 requester->ReqGadget = NULL;
167 requester->OlderRequest = window->FirstRequest;
168 window->FirstRequest = requester;
169 ++window->ReqCount;
170 requester->Flags |= REQACTIVE;
172 AddGList(window, gadgets, 0, -1, requester);
174 render_requester(requester, IntuitionBase);
176 msg->success = TRUE;
178 else
180 msg->success = FALSE;