-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglutDestroyWindow.c
131 lines (115 loc) · 3.54 KB
/
glutDestroyWindow.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* Amiga GLUT graphics library toolkit
* Version: 1.1
* Copyright (C) 1998 Jarno van der Linden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* glutDestroyWindow.c
*
* Version 1.0 27 Jun 1998
* by Jarno van der Linden
*
*/
#ifdef WARPOS
#pragma pack(push,2)
#endif
extern struct ExecBase *SysBase;
#include <stdlib.h>
#ifndef WARPOS
#include <inline/intuition.h>
#include <inline/graphics.h>
#include <inline/exec.h>
#include <inline/layers.h>
#include <inline/gadtools.h>
#else
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/layers.h>
#include <proto/gadtools.h>
#pragma pack(pop)
#endif
#include "glutstuff.h"
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) {
Remove(&msg->ExecMessage.mn_Node);
ReplyMsg((struct Message *)msg);
}
msg = (struct IntuiMessage *)succ;
}
}
void CloseWindowSafely(struct GlutWindow *win)
{
if (win && win->window) {
Forbid();
StripIntuiMessages(win->window->UserPort, win->window);
if (!glutstuff.GameMode) { /* if in gamemode somethings closed, it MUST be the GameMode-window */
win->window->UserPort = NULL;
ModifyIDCMP(win->window, 0L);
}
Permit();
#ifdef USE_CLIP_LAYER_
if (win->clipreg) {
win->clipreg = InstallClipRegion(win->window->WLayer, win->clipreg);
DisposeRegion(win->clipreg);
win->clipreg = NULL;
}
#endif
CloseWindow(win->window);
}
}
void glutDestroyWindow(int win)
{
struct GlutWindow *actWindow;
/* link out */
if ((actWindow = stuffGetWin(win))) {
struct Menu *menu;
struct nnode *act;
stuffLinkOutWin(actWindow);
if (actWindow->window)
ClearMenuStrip(actWindow->window);
if ((menu = actWindow->menu)) {
while (menu) {
FreeMenus(menu->FirstItem); /* TODO: cast */
menu->FirstItem = NULL;
menu = menu->NextMenu;
}
FreeMenus(actWindow->menu);
}
while ((act = nGetTail(&actWindow->WindowTimers))) {
nRemove(&actWindow->WindowTimers, act);
FreeVecPooled(glutPool, (ULONG *)act); /* remove something out of the list, so we can't use nGetNext() safely */
}
while ((act = nGetTail(&actWindow->SubWindows)))
glutDestroyWindow(((struct GlutWindow *)act)->WinID); /* remove something out of the list, so we can't use nGetNext() safely */
if (actWindow->vi)
FreeVisualInfo(actWindow->vi);
if (actWindow->context)
amigaMesaDestroyContext(actWindow->context);
if (actWindow->window)
CloseWindowSafely(actWindow);
FreeVecPooled(glutPool, (ULONG *)actWindow);
}
else
DEBUGOUT(1, "somethings wrong in glutDestroyWindow(%d)\n", win);
}