forked from jackokring/rub
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathamismsg.inc
108 lines (90 loc) · 2.83 KB
/
amismsg.inc
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
{
System dependent system messages for AmigaOS/MorphOS
Copyright (c) 2008 by Karoly Balogh
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.
}
uses
video;
Const
SystemEventActive : Boolean = false;
var
lastxsize,lastysize : longint;
procedure InitSystemMsg;
begin
If SystemEventActive then
exit;
{ Code to enable size tracking should go here }
PendingSystemHead:=@PendingSystemEvent;
PendingSystemTail:=@PendingSystemEvent;
PendingSystemEvents:=0;
FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
Video.HasResizeWindow(LastXSize,LastYSize);
If LastXSize=0 then
LastXSize:=80;
If LastYSize=0 then
LastYSize:=25;
SystemEventActive:=true;
end;
procedure DoneSystemMsg;
begin
if not SystemEventActive then
exit;
{ Code to disable size tracking should go here }
SystemEventActive:=false;
end;
procedure GetSystemEvent(var SystemEvent: TSystemEvent);
begin
if PendingSystemEvents=0 then
PollSystemEvent(SystemEvent);
if PendingSystemEvents=0 then
exit;
SystemEvent:=PendingSystemHead^;
inc(PendingSystemHead);
if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
PendingSystemHead:=@PendingSystemEvent;
dec(PendingSystemEvents);
LastSystemEvent:=SystemEvent;
end;
function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
var width, height : longint;
begin
SystemEvent.typ:=SysNothing;
if not SystemEventActive then
exit(false);
if PendingSystemEvents>0 then
begin
SystemEvent:=PendingSystemHead^;
PollSystemEvent:=true;
end
else
begin
PollSystemEvent:=false;
if Video.HasCloseWindow then begin
SystemEvent.typ:=SysClose;
SystemEvent.CloseTyp:=0;
PutSystemEvent(SystemEvent);
PollSystemEvent:=true;
end else if Video.HasResizeWindow(width, height) then begin
if (width>0) and (height>0) and
((width<>lastxsize) or (height<>lastysize)) then begin
SystemEvent.typ:=SysResize;
SystemEvent.x:=width;
SystemEvent.y:=height;
PutSystemEvent(SystemEvent);
LastXSize:=width;
LastYSize:=height;
PollSystemEvent:=true;
end;
end;
end;
end;