amismsg.inc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. System dependent system messages for AmigaOS/MorphOS
  3. Copyright (c) 2008 by Karoly Balogh
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Library General Public License for more details.
  10. You should have received a copy of the GNU Library General Public
  11. License along with this library; if not, write to the Free
  12. Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  13. MA 02110-1301, USA.
  14. }
  15. uses
  16. video;
  17. Const
  18. SystemEventActive : Boolean = false;
  19. var
  20. lastxsize,lastysize : longint;
  21. procedure InitSystemMsg;
  22. begin
  23. If SystemEventActive then
  24. exit;
  25. { Code to enable size tracking should go here }
  26. PendingSystemHead:=@PendingSystemEvent;
  27. PendingSystemTail:=@PendingSystemEvent;
  28. PendingSystemEvents:=0;
  29. FillChar(LastSystemEvent,sizeof(TSystemEvent),0);
  30. Video.HasResizeWindow(LastXSize,LastYSize);
  31. If LastXSize=0 then
  32. LastXSize:=80;
  33. If LastYSize=0 then
  34. LastYSize:=25;
  35. SystemEventActive:=true;
  36. end;
  37. procedure DoneSystemMsg;
  38. begin
  39. if not SystemEventActive then
  40. exit;
  41. { Code to disable size tracking should go here }
  42. SystemEventActive:=false;
  43. end;
  44. procedure GetSystemEvent(var SystemEvent: TSystemEvent);
  45. begin
  46. if PendingSystemEvents=0 then
  47. PollSystemEvent(SystemEvent);
  48. if PendingSystemEvents=0 then
  49. exit;
  50. SystemEvent:=PendingSystemHead^;
  51. inc(PendingSystemHead);
  52. if longint(PendingSystemHead)=longint(@PendingSystemEvent)+sizeof(PendingSystemEvent) then
  53. PendingSystemHead:=@PendingSystemEvent;
  54. dec(PendingSystemEvents);
  55. LastSystemEvent:=SystemEvent;
  56. end;
  57. function PollSystemEvent(var SystemEvent: TSystemEvent):boolean;
  58. var width, height : longint;
  59. begin
  60. SystemEvent.typ:=SysNothing;
  61. if not SystemEventActive then
  62. exit(false);
  63. if PendingSystemEvents>0 then
  64. begin
  65. SystemEvent:=PendingSystemHead^;
  66. PollSystemEvent:=true;
  67. end
  68. else
  69. begin
  70. PollSystemEvent:=false;
  71. if Video.HasCloseWindow then begin
  72. SystemEvent.typ:=SysClose;
  73. SystemEvent.CloseTyp:=0;
  74. PutSystemEvent(SystemEvent);
  75. PollSystemEvent:=true;
  76. end else if Video.HasResizeWindow(width, height) then begin
  77. if (width>0) and (height>0) and
  78. ((width<>lastxsize) or (height<>lastysize)) then begin
  79. SystemEvent.typ:=SysResize;
  80. SystemEvent.x:=width;
  81. SystemEvent.y:=height;
  82. PutSystemEvent(SystemEvent);
  83. LastXSize:=width;
  84. LastYSize:=height;
  85. PollSystemEvent:=true;
  86. end;
  87. end else if Video.HasActiveWindow then begin
  88. SystemEvent.typ:=SysSetFocus;
  89. PutSystemEvent(SystemEvent);
  90. PollSystemEvent:=true;
  91. end else if Video.HasInactiveWindow then begin
  92. SystemEvent.typ:=SysReleaseFocus;
  93. PutSystemEvent(SystemEvent);
  94. PollSystemEvent:=true;
  95. end;
  96. end;
  97. end;