tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / intuition / sendintuimessage.c
blob21b564cd3158db5bdd274393ee27d09526ef0162
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/timer.h>
8 #include "intuition_intern.h"
10 #define DEBUG_SENDINTUIMESSAGE(x) ;
11 /*****i***********************************************************************
13 NAME */
14 #include <proto/intuition.h>
16 AROS_LH2(void, SendIntuiMessage,
18 /* SYNOPSIS */
19 AROS_LHA(struct Window *, window, A0),
20 AROS_LHA(struct IntuiMessage *, imsg, A1),
22 /* LOCATION */
23 struct IntuitionBase *, IntuitionBase, 151, Intuition)
25 /* FUNCTION
26 Private: send an IntuiMessage to an Intuition window
28 INPUTS
29 window - The window to which the IntuiMessage shall be sent
30 imsg - The IntuiMessage to send, which must have been allocated with
31 AllocIntuiMessage.
33 RESULT
34 None.
36 NOTES
37 The caller of this function should first check himself
38 whether window->UserPort is NULL. And in this case do not
39 call this function at all.
41 If inside this function the window->UserPort turns out to
42 be NULL, then what happens is, that the IntuiMessage is
43 immediately ReplyMessage()ed in here, just like if this was
44 done by the app whose window was supposed to get the
45 IntuiMessage.
47 The protection with Forbid() is necessary, because of the
48 way shared window userports are handled, when one of this
49 windows is closed, where there is also just a protection with
50 Forbid() when stripping those IntuiMessages from the port
51 which belong to the window which is going to be closed.
53 This function does not check whether the window to which
54 the IntuiMessage is supposed to be sent, really wants to
55 get the IDCMP in question, that is, whether the corresponding
56 flag in window->IDCMPFLags is set.
58 This private function is also present in MorphOS v50.
60 EXAMPLE
62 BUGS
64 SEE ALSO
66 INTERNALS
68 *****************************************************************************/
70 AROS_LIBFUNC_INIT
72 ASSERT_VALID_PTR(window);
73 ASSERT_VALID_PTR(imsg);
75 struct Library *TimerBase = GetPrivIBase(IntuitionBase)->TimerBase;
77 DEBUG_SENDINTUIMESSAGE(dprintf("SendIntuiMessage: Window 0x%lx Port 0x%lx Msg 0x%lx\n",
78 window, window->UserPort, imsg));
80 SANITY_CHECK(window)
81 SANITY_CHECK(imsg)
83 Forbid();
85 #ifdef __MORPHOS__
86 if (window->UserPort)
88 struct Task *apptask = window->UserPort->mp_SigTask;
90 if (apptask && (!apptask->tc_SigWait) && (apptask->tc_State == TS_WAIT))
92 //task is DEAD!
93 imsg->IDCMPWindow = 0;
94 imsg->Code = 0;
95 imsg->Qualifier = 0;
96 ReplyMsg(&imsg->ExecMessage);
98 if (IW(window)->messagecache)
100 IW(window)->messagecache->IDCMPWindow = 0;
101 IW(window)->messagecache->Code = 0;
102 IW(window)->messagecache->Qualifier = 0;
103 ReplyMsg(&IW(window)->messagecache->ExecMessage);
104 IW(window)->messagecache = 0;
106 Permit();
108 //give some visual feedback to the user
109 IW(window)->specialflags |= SPFLAG_IAMDEAD;
111 int_refreshwindowframe(window,REFRESHGAD_TOPBORDER,0,IntuitionBase);
113 return;
115 else
117 IW(window)->specialflags &= ~SPFLAG_IAMDEAD;
120 #endif
122 if (imsg->Qualifier & IEQUALIFIER_REPEAT)
124 IW(window)->num_repeatevents++;
127 #if USE_IDCMPUPDATE_MESSAGECACHE
128 if (imsg->Class == IDCMP_IDCMPUPDATE)
130 if (IW(window)->num_idcmpupdate && !IW(window)->messagecache)
132 kprintf("======= setting messagecache\n");
133 IW(window)->messagecache = imsg;
134 Permit();
135 return;
138 //reduce number of messages if possible (prop updates only!)
139 if (IW(window)->num_idcmpupdate && IW(window)->messagecache)
141 if (imsg->Code == IW(window)->messagecache->Code && imsg->Qualifier == IEQUALIFIER_REPEAT)
143 IW(window)->messagecache->MouseX = imsg->MouseX;
144 IW(window)->messagecache->MouseY = imsg->MouseY;
145 IW(window)->messagecache->Seconds = imsg->Seconds;
146 IW(window)->messagecache->Micros = imsg->Micros;
147 imsg->IDCMPWindow = 0;
148 imsg->Code = 0;
149 imsg->Qualifier = 0;
150 ReplyMsg(&imsg->ExecMessage);
151 Permit();
152 return;
156 IW(window)->num_idcmpupdate++;
158 #endif
160 Forbid();
161 GetSysTime(&((struct IntWindow *)(window))->lastmsgsent);
162 Permit();
164 if (window->UserPort)
166 if (imsg->Class == IDCMP_INTUITICKS)
168 window->Flags |= WFLG_WINDOWTICKED;
170 DEBUG_SENDINTUIMESSAGE(dprintf("SendIntuiMessage: Class 0x%lx Code 0x%lx Qual 0x%lx Mouse %d,%d IAddress 0x%lx\n", imsg->Class, imsg->Code, imsg->Qualifier, imsg->MouseX, imsg->MouseY, imsg->IAddress));
172 PutMsg(window->UserPort, &imsg->ExecMessage);
174 /* Help sucky programs... (die DigiBooster, die!) */
175 window->MessageKey = imsg;
177 else
179 ReplyMsg(&imsg->ExecMessage);
182 Permit();
184 AROS_LIBFUNC_EXIT