2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/graphics.h>
8 #include <proto/timer.h>
9 #include <intuition/gadgetclass.h>
10 #include "intuition_intern.h"
11 #include "inputhandler.h"
12 #include "inputhandler_actions.h"
13 #include "inputhandler_support.h"
14 #include "boopsigadgets.h"
15 #include "boolgadgets.h"
16 #include "propgadgets.h"
17 #include "strgadgets.h"
20 #include "monitorclass_private.h"
21 #include <intuition/pointerclass.h>
23 struct ActivateWindowActionMsg
25 struct IntuiActionMsg msg
;
26 struct Window
*window
;
29 static VOID
int_activatewindow(struct ActivateWindowActionMsg
*msg
,
30 struct IntuitionBase
*IntuitionBase
);
32 /*****************************************************************************
35 #include <proto/intuition.h>
37 AROS_LH1(void, ActivateWindow
,
40 AROS_LHA(struct Window
*, window
, A0
),
43 struct IntuitionBase
*, IntuitionBase
, 75, Intuition
)
46 Activates the specified window. The window gets the focus
47 and all further input is sent to that window. If the window
48 requested it, it will get a IDCMP_ACTIVEWINDOW message.
51 window - The window to activate
57 If the user has an autopointer tool (sunmouse), the call will
58 succeed, but the tool will deactivate the window right after
59 this function has activated it. It is not a good idea to try to
60 prevent this by waiting for IDCMP_INACTIVEWINDOW and activating
61 the window again since that will produce an annoying flicker and
62 it will slow down the computer a lot.
69 ModifyIDCMP(), OpenWindow(), CloseWindow()
73 *****************************************************************************/
77 struct ActivateWindowActionMsg msg
;
79 DEBUG_ACTIVATEWINDOW(dprintf("ActivateWindow: Window 0x%lx\n",
83 DoASyncAction((APTR
)int_activatewindow
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
87 } /* ActivateWindow */
89 /* This is called on the input.device's context */
91 static VOID
int_activatewindow(struct ActivateWindowActionMsg
*msg
,
92 struct IntuitionBase
*IntuitionBase
)
94 struct IIHData
*iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
96 /* On the Amiga ActivateWindow is delayed if there
97 is an active gadget (altough this does not seem
98 to be true for string gadgets). We just ignore
99 ActivateWindow in such a case. */
101 struct Window
*window
= msg
->window
;
103 struct Window
*oldactive
;
104 Object
*pointer
= NULL
;
105 struct IntScreen
*scr
= NULL
;
106 struct InputEvent
*ie
;
108 if (!ResourceExisting(window
, RESOURCE_WINDOW
, IntuitionBase
)) return;
109 // if (window->Flags & WFLG_TOOLBOX) return;
111 if ((!iihdata
->ActiveGadget
) ||
112 (iihdata
->ActiveGadget
&& ((iihdata
->ActiveGadget
->GadgetType
& GTYP_SYSTYPEMASK
) == GTYP_SDEPTH
)))
115 lock
= LockIBase(0UL);
117 if (window
->Flags
& WFLG_TOOLBOX
) oldactive
= NULL
; else oldactive
= IntuitionBase
->ActiveWindow
;
118 if ((window
->Flags
& WFLG_TOOLBOX
) == 0) IntuitionBase
->ActiveWindow
= window
;
120 DEBUG_ACTIVATEWINDOW(dprintf("IntActivateWindow: Window 0x%lx OldActive 0x%lx\n",
123 if (oldactive
!= window
)
125 GetPrivIBase(IntuitionBase
)->PointerDelay
= 0;
129 ih_fire_intuimessage(oldactive
,
130 IDCMP_INACTIVEWINDOW
,
135 scr
= GetPrivScreen(oldactive
->WScreen
);
136 scr
->Screen
.Title
= scr
->Screen
.DefaultTitle
;
142 Tasks are allowed to modify window->Flags, for example
143 set/clear WFLG_RMBTRAP. It is not certain that every
144 compiler on every machine produces an atomic instruction.
146 /* FIXME: check that window->Flags is atomically set everywhere */
147 AROS_ATOMIC_OR(window
->Flags
, WFLG_WINDOWACTIVE
);
149 pointer
= IW(window
)->pointer
;
150 if (IW(window
)->busy
)
151 pointer
= GetPrivIBase(IntuitionBase
)->BusyPointer
;
153 scr
= GetPrivScreen(window
->WScreen
);
154 if (window
->ScreenTitle
)
156 scr
->Screen
.Title
= window
->ScreenTitle
;
160 scr
->Screen
.Title
= scr
->Screen
.DefaultTitle
;
164 /* now set the ActiveScreen! */
170 old
= IntuitionBase
->ActiveScreen
;
172 if (old
&& (old
!= (struct Screen
*)scr
))
175 /* this avoids mouse "jump" effect */
176 /* .. but causes setting wrong coordinates - sonic
177 scr->Screen.MouseX = old->MouseX;
178 scr->Screen.MouseY = old->MouseY;*/
180 win
= scr
->Screen
.FirstWindow
;
184 UpdateMouseCoords(win
);
185 win
= win
->NextWindow
;
189 IntuitionBase
->ActiveScreen
= (struct Screen
*)scr
;
195 struct SharedPointer
*shared_pointer
;
198 pointer
= GetPrivIBase(IntuitionBase
)->DefaultPointer
;
200 GetAttr(POINTERA_SharedPointer
, pointer
, (IPTR
*)&shared_pointer
);
202 DEBUG_POINTER(dprintf("ActivateWindow: scr 0x%lx pointer 0x%lx sprite 0x%lx\n",
203 scr
, pointer
, shared_pointer
->sprite
));
205 if (DoMethod(scr
->IMonitorNode
, MM_SetPointerShape
, shared_pointer
))
207 ObtainSharedPointer(shared_pointer
, IntuitionBase
);
208 ReleaseSharedPointer(scr
->Pointer
, IntuitionBase
);
209 scr
->Pointer
= shared_pointer
;
212 window
->XOffset
= shared_pointer
->xoffset
;
213 window
->YOffset
= shared_pointer
->yoffset
;
218 DEBUG_POINTER(dprintf("ActivateWindow: can't set pointer.\n"));
225 if (oldactive
&& oldactive
!= window
)
227 AROS_ATOMIC_AND(oldactive
->Flags
, ~WFLG_WINDOWACTIVE
);
229 int_refreshwindowframe(oldactive
, REFRESHGAD_BORDER
, 0, IntuitionBase
);
230 if (!window
|| oldactive
->WScreen
!= window
->WScreen
)
231 RenderScreenBar(oldactive
->WScreen
, FALSE
, IntuitionBase
);
235 if (window
&& oldactive
!= window
)
237 int_refreshwindowframe(window
, REFRESHGAD_BORDER
, 0, IntuitionBase
);
238 RenderScreenBar(window
->WScreen
, FALSE
, IntuitionBase
);
241 #ifdef TIMEVALWINDOWACTIVATION
244 GetSysTime(&IW(window
)->activationtime
);
248 if ((ie
= AllocInputEvent(iihdata
)))
250 ie
->ie_Class
= IECLASS_EVENT
;
251 ie
->ie_Code
= IECODE_NEWACTIVE
;
252 ie
->ie_EventAddress
= window
;
253 CurrentTime(&ie
->ie_TimeStamp
.tv_secs
, &ie
->ie_TimeStamp
.tv_micro
);
258 if ((window
->Flags
& WFLG_TOOLBOX
) == 0)
259 ih_fire_intuimessage(window
,
268 int_refreshwindowframe(window
, REFRESHGAD_BORDER
, 0, IntuitionBase
);
273 if (window
&& window
->UserPort
)
275 struct Task
*apptask
= window
->UserPort
->mp_SigTask
;
277 if (apptask
&& (!apptask
->tc_SigWait
) && (apptask
->tc_State
== TS_WAIT
))
280 //give some visual feedback to the user
282 IW(window
)->specialflags
|= SPFLAG_IAMDEAD
;
284 int_refreshwindowframe(window
,REFRESHGAD_TOPBORDER
,0,IntuitionBase
);
289 IW(window
)->specialflags
&= ~SPFLAG_IAMDEAD
;