-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helpers.c
58 lines (44 loc) · 1.44 KB
/
Helpers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -------------------------------------------------
Helpers.c (29.10.2014) Marcus Gerards
Utility and debug functions for WinZoom
*/
#include "app.h"
#include "local.h"
#ifndef __amigaos4__
VOID StripIntuiMessages(struct MsgPort *mp, struct Window *win)
{
struct IntuiMessage *msg;
struct Node *succ;
msg = (struct IntuiMessage *)mp->mp_MsgList.lh_Head;
while (succ = msg->ExecMessage.mn_Node.ln_Succ) {
if (msg->IDCMPWindow == win)
{
/* Intuition is about to free this message.
Make sure that we have politely sent it back.
*/
Remove((struct Node *) msg);
ReplyMsg((struct Message *) msg);
}
msg = (struct IntuiMessage *)succ;
}
}
#endif
VOID CloseWindowSafely(struct Window *win)
{
if (win->UserPort) {
/* we forbid here to keep out of race conditions with Intuition */
Forbid();
/* send back any messages for this window that have not yet been
** processed
*/
StripIntuiMessages(win->UserPort, win);
/* clear UserPort so Intuition will not free it */
win->UserPort = NULL;
/* tell Intuition to stop sending more messages */
ModifyIDCMP(win, 0L);
/* turn multitasking back on */
Permit();
}
/* Now it's safe to really close the window */
CloseWindow(win);
}