~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to docs/gpm.tex

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%
2
 
%   $Id: gpm.tex,v 1.2 2003/03/16 15:22:18 peter Exp $
3
 
%   This file is part of the FPC documentation.
4
 
%   Copyright (C) 1997, by Michael Van Canneyt
5
 
%
6
 
%   The FPC documentation is free text; you can redistribute it and/or
7
 
%   modify it under the terms of the GNU Library General Public License as
8
 
%   published by the Free Software Foundation; either version 2 of the
9
 
%   License, or (at your option) any later version.
10
 
%
11
 
%   The FPC Documentation is distributed in the hope that it will be useful,
12
 
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
%   Library General Public License for more details.
15
 
%
16
 
%   You should have received a copy of the GNU Library General Public
17
 
%   License along with the FPC documentation; see the file COPYING.LIB.  If not,
18
 
%   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
%   Boston, MA 02111-1307, USA. 
20
 
%
21
 
\chapter{The GPM unit}
22
 
\FPCexampledir{gpmex}
23
 
\section{Introduction}
24
 
The \file{GPM} unit implements an interface to file{libgpm}, the console
25
 
program for mouse handling. This unit was created by Peter Vreman, and 
26
 
is only available on \linux.
27
 
 
28
 
When this unit is used, your program is linked to the C libraries, so
29
 
you must take care of the C library version. Also, it will only work with
30
 
version 1.17 or higher of the \file{libgpm} library.
31
 
 
32
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
 
% Constants, types and variables
34
 
\section{Constants, types and variables}
35
 
\subsection{constants}
36
 
The following constants are used to denote filenames used by the library:
37
 
\begin{verbatim}
38
 
_PATH_VARRUN = '/var/run/';
39
 
_PATH_DEV    = '/dev/';
40
 
GPM_NODE_DIR = _PATH_VARRUN;
41
 
GPM_NODE_DIR_MODE = 0775;
42
 
GPM_NODE_PID  = '/var/run/gpm.pid';
43
 
GPM_NODE_DEV  = '/dev/gpmctl';
44
 
GPM_NODE_CTL  = GPM_NODE_DEV;
45
 
GPM_NODE_FIFO = '/dev/gpmdata';
46
 
\end{verbatim}
47
 
The following constants denote the buttons on the mouse:
48
 
\begin{verbatim}
49
 
GPM_B_LEFT   = 4;
50
 
GPM_B_MIDDLE = 2;
51
 
GPM_B_RIGHT  = 1;
52
 
\end{verbatim}
53
 
The following constants define events:
54
 
\begin{verbatim}
55
 
GPM_MOVE = 1;      
56
 
GPM_DRAG = 2;
57
 
GPM_DOWN = 4;
58
 
GPM_UP = 8;
59
 
GPM_SINGLE = 16;
60
 
GPM_DOUBLE = 32;
61
 
GPM_TRIPLE = 64;
62
 
GPM_MFLAG = 128;
63
 
GPM_HARD = 256;
64
 
GPM_ENTER = 512;
65
 
GPM_LEAVE = 1024;
66
 
\end{verbatim}
67
 
The following constants are used in defining margins:
68
 
\begin{verbatim}
69
 
GPM_TOP = 1;
70
 
GPM_BOT = 2;
71
 
GPM_LFT = 4;
72
 
GPM_RGT = 8;
73
 
\end{verbatim}
74
 
 
75
 
% Types
76
 
\subsection{Types}
77
 
The following general types are defined:
78
 
\begin{verbatim}
79
 
  TGpmEtype = longint;
80
 
  TGpmMargin = longint;
81
 
\end{verbatim}
82
 
The following type describes an event; it is passed in many of the gpm
83
 
functions.
84
 
\begin{verbatim}
85
 
PGpmEvent = ^TGpmEvent;
86
 
TGpmEvent = record
87
 
  buttons : byte;
88
 
  modifiers : byte;
89
 
  vc : word;
90
 
  dx : word;
91
 
  dy : word;
92
 
  x : word;
93
 
  y : word;
94
 
  EventType : TGpmEType;
95
 
  clicks : longint;
96
 
  margin : TGpmMargin;
97
 
end;
98
 
TGpmHandler=function(var event:TGpmEvent;clientdata:pointer):longint;cdecl;
99
 
\end{verbatim}
100
 
The following types are used in connecting to the \file{gpm} server:
101
 
\begin{verbatim}
102
 
PGpmConnect = ^TGpmConnect;
103
 
TGpmConnect = record
104
 
  eventMask : word;
105
 
  defaultMask : word;
106
 
  minMod : word;
107
 
  maxMod : word;
108
 
  pid : longint;
109
 
  vc : longint;
110
 
end;
111
 
\end{verbatim}
112
 
The following type is used to define {\em regions of interest}
113
 
\begin{verbatim}
114
 
PGpmRoi = ^TGpmRoi;
115
 
TGpmRoi = record
116
 
  xMin : integer;
117
 
  xMax : integer;
118
 
  yMin : integer;
119
 
  yMax : integer;
120
 
  minMod : word;
121
 
  maxMod : word;
122
 
  eventMask : word;
123
 
  owned : word;
124
 
  handler : TGpmHandler;
125
 
  clientdata : pointer;
126
 
  prev : PGpmRoi;
127
 
  next : PGpmRoi;
128
 
end;
129
 
\end{verbatim}
130
 
 
131
 
% Variables
132
 
\subsection{Variables}
133
 
The following variables are imported from the \var{gpm} library
134
 
\begin{verbatim}
135
 
gpm_flag           : longint;cvar;external;
136
 
gpm_fd             : longint;cvar;external;
137
 
gpm_hflag          : longint;cvar;external;
138
 
gpm_morekeys       : Longbool;cvar;external;
139
 
gpm_zerobased      : Longbool;cvar;external;
140
 
gpm_visiblepointer : Longbool;cvar;external;
141
 
gpm_mx             : longint;cvar;external;
142
 
gpm_my             : longint;cvar;external;
143
 
gpm_timeout        : TTimeVal;cvar;external;
144
 
_gpm_buf           : array[0..0] of char;cvar;external;
145
 
_gpm_arg           : ^word;cvar;external;
146
 
gpm_handler        : TGpmHandler;cvar;external;
147
 
gpm_data           : pointer;cvar;external;
148
 
gpm_roi_handler    : TGpmHandler;cvar;external;
149
 
gpm_roi_data       : pointer;cvar;external;
150
 
gpm_roi            : PGpmRoi;cvar;external;
151
 
gpm_current_roi    : PGpmRoi;cvar;external;
152
 
gpm_consolefd      : longint;cvar;external;
153
 
Gpm_HandleRoi      : TGpmHandler;cvar;external;
154
 
\end{verbatim}
155
 
 
156
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
 
% Functions and procedures
158
 
\section{Functions and procedures}
159
 
 
160
 
\begin{functionl}{Gpm\_AnyDouble}{GpmAnyDouble}
161
 
\Declaration
162
 
function Gpm\_AnyDouble(EventType : longint) : boolean;
163
 
\Description
164
 
\var{Gpm\_AnyDouble} returns \var{True} if \var{EventType} contains
165
 
the \var{GPM\_DOUBLE} flag, \var{False} otherwise.
166
 
\Errors
167
 
None.
168
 
\SeeAlso
169
 
\seefl{Gpm\_StrictSingle}{GpmStrictSingle},
170
 
\seefl{Gpm\_AnySingle}{GpmAnySingle},
171
 
\seefl{Gpm\_StrictDouble}{GpmStrictDouble},
172
 
\seefl{Gpm\_StrictTriple}{GpmStrictTriple},
173
 
\seefl{Gpm\_AnyTriple}{GpmAnyTriple}
174
 
\end{functionl}
175
 
 
176
 
\begin{functionl}{Gpm\_AnySingle}{GpmAnySingle}
177
 
\Declaration
178
 
function Gpm\_AnySingle(EventType : longint) : boolean;
179
 
\Description
180
 
\var{Gpm\_AnySingle} returns \var{True} if \var{EventType} contains
181
 
the \var{GPM\_SINGLE} flag, \var{False} otherwise. 
182
 
\Errors
183
 
\SeeAlso
184
 
\seefl{Gpm\_StrictSingle}{GpmStrictSingle},
185
 
\seefl{Gpm\_AnyDoubmle}{GpmAnyDouble},
186
 
\seefl{Gpm\_StrictDouble}{GpmStrictDouble},
187
 
\seefl{Gpm\_StrictTriple}{GpmStrictTriple},
188
 
\seefl{Gpm\_AnyTriple}{GpmAnyTriple}
189
 
\end{functionl}
190
 
 
191
 
\begin{functionl}{Gpm\_AnyTriple}{GpmAnyTriple}
192
 
\Declaration
193
 
function Gpm\_AnyTriple(EventType : longint) : boolean;
194
 
\Description
195
 
\Errors
196
 
\SeeAlso
197
 
\seefl{Gpm\_StrictSingle}{GpmStrictSingle},
198
 
\seefl{Gpm\_AnyDoubmle}{GpmAnyDouble},
199
 
\seefl{Gpm\_StrictDouble}{GpmStrictDouble},
200
 
\seefl{Gpm\_StrictTriple}{GpmStrictTriple},
201
 
\seefl{Gpm\_AnySingle}{GpmAnySingle}
202
 
\end{functionl}
203
 
 
204
 
\begin{functionl}{Gpm\_Close}{GpmClose}
205
 
\Declaration
206
 
function Gpm\_Close:longint;cdecl;external;
207
 
\Description
208
 
\var{Gpm\_Close} closes the current connection, and pops the connection
209
 
stack; this means that the previous connection becomes active again.
210
 
 
211
 
The function returns -1 if the current connection is not the last one,
212
 
and it returns 0 if the current connection is the last one.
213
 
\Errors
214
 
None.
215
 
\SeeAlso
216
 
\seefl{Gpm\_Open}{GpmOpen}
217
 
\end{functionl}
218
 
 
219
 
for an example, see \seefl{Gpm\_GetEvent}{GpmGetEvent}.
220
 
 
221
 
\begin{functionl}{Gpm\_FitValues}{GpmFitValues}
222
 
\Declaration
223
 
function Gpm\_FitValues(var x,y:longint):longint;cdecl;external;
224
 
\Description
225
 
\var{Gpm\_fitValues} changes \var{x} and \var{y} so they fit in the visible
226
 
screen. The actual mouse pointer is not affected by this function.
227
 
\Errors
228
 
None.
229
 
\SeeAlso
230
 
\seefl{Gpm\_FitValuesM}{GpmFitValuesM},
231
 
\end{functionl}
232
 
 
233
 
\begin{functionl}{Gpm\_FitValuesM}{GpmFitValuesM}
234
 
\Declaration
235
 
function Gpm\_FitValuesM(var x,y:longint; margin:longint):longint;cdecl;external;
236
 
\Description
237
 
\var{Gpm\_FitValuesM} chnages \var{x} and \var{y} so they fit in the margin
238
 
indicated by \var{margin}. If \var{margin} is -1, then the values are fitted
239
 
to the screen. The actual mouse pointer is not affected by this function.
240
 
\Errors
241
 
None.
242
 
\SeeAlso
243
 
\seefl{Gpm\_FitValues}{GpmFitValues},
244
 
\end{functionl}
245
 
 
246
 
\begin{functionl}{Gpm\_GetEvent}{GpmGetEvent}
247
 
\Declaration
248
 
function Gpm\_GetEvent(var Event:TGpmEvent):longint;cdecl;external;
249
 
\Description
250
 
\var{Gpm\_GetEvent} Reads an event from the file descriptor \var{gpm\_fd}.
251
 
This file is only for internal use and should never be called by a client
252
 
application. 
253
 
 
254
 
It returns 1 on succes, and -1 on failue.
255
 
\Errors
256
 
On error, -1 is returned. 
257
 
\SeeAlso
258
 
seefl{Gpm\_GetSnapshot}{GpmGetSnapshot}
259
 
\end{functionl}
260
 
 
261
 
\FPCexample{gpmex}
262
 
 
263
 
\begin{functionl}{Gpm\_GetLibVersion}{GpmGetLibVersion}
264
 
\Declaration
265
 
function Gpm\_GetLibVersion(var where:longint):pchar;cdecl;external;
266
 
\Description
267
 
\var{Gpm\_GetLibVersion} returns a pointer to a version string, and returns
268
 
in \var{where} an integer representing the version. The version string
269
 
represents the version of the gpm library.
270
 
 
271
 
The return value is a pchar, which should not be dealloacted, i.e. it is not
272
 
on the heap.
273
 
\Errors
274
 
None.
275
 
\SeeAlso
276
 
\seefl{Gpm\_GetServerVersion}{GpmGetServerVersion}
277
 
\end{functionl}
278
 
 
279
 
\begin{functionl}{Gpm\_GetServerVersion}{GpmGetServerVersion}
280
 
\Declaration
281
 
function Gpm\_GetServerVersion(var where:longint):pchar;cdecl;external;
282
 
\Description
283
 
\var{Gpm\_GetServerVersion} returns a pointer to a version string, and 
284
 
returns in \var{where} an integer representing the version. The version string
285
 
represents the version of the gpm server program.
286
 
 
287
 
The return value is a pchar, which should not be dealloacted, i.e. it is not
288
 
on the heap.
289
 
\Errors
290
 
If the gpm program is not present, then the function returns \var{Nil}
291
 
\SeeAlso
292
 
\seefl{Gpm\_GetLibVersion}{GpmGetLibVersion}
293
 
\end{functionl}
294
 
 
295
 
\begin{functionl}{Gpm\_GetSnapshot}{GpmGetSnapshot}
296
 
\Declaration
297
 
function Gpm\_GetSnapshot(var Event:TGpmEvent):longint;cdecl;external;
298
 
\Description
299
 
\var{Gpm\_GetSnapshot} returns the picture that the server has of the 
300
 
current situation in \var{Event}. 
301
 
This call will not read the current situation from the mouse file
302
 
descriptor, but returns a buffered version.
303
 
The meaning of the fields is as follows:
304
 
\begin{description}
305
 
\item[x,y] current position of the cursor.
306
 
\item[dx,dy] size of the window.
307
 
\item[vc] number of te virtual console.
308
 
\item[modifiers] keyboard shift state.
309
 
\item[buttons] buttons which are currently pressed.
310
 
\item[clicks] number of clicks (0,1 or 2).
311
 
\end{description}
312
 
The function returns the number of mouse buttons, or -1 if this information
313
 
is not available.
314
 
\Errors
315
 
None.
316
 
\SeeAlso
317
 
\seefl{Gpm\_GetEvent}{GpmGetEvent}
318
 
\end{functionl}
319
 
 
320
 
\begin{functionl}{Gpm\_LowerRoi}{GpmLowerRoi}
321
 
\Declaration
322
 
function Gpm\_LowerRoi(which:PGpmRoi; after:PGpmRoi):PGpmRoi;cdecl;external;
323
 
\Description
324
 
\var{Gpm\_LowerRoi} lowers the region of interest \var{which} after
325
 
\var{after}. If \var{after} is \var{Nil}, the region of interest is moved to
326
 
the bottom of the stack.
327
 
 
328
 
The return value is the new top of the region-of-interest stack.
329
 
\Errors
330
 
None.
331
 
\SeeAlso
332
 
\seefl{Gpm\_RaiseRoi}{GpmRaiseRoi},
333
 
\seefl{Gpm\_PopRoi}{GpmPopRoi},
334
 
\seefl{Gpm\_PushRoi}{GpmPopRoi} 
335
 
\end{functionl}
336
 
 
337
 
\begin{functionl}{Gpm\_Open}{GpmOpen}
338
 
\Declaration
339
 
function Gpm\_Open(var Conn:TGpmConnect; Flag:longint):longint;cdecl;external;
340
 
\Description
341
 
\var{Gpm\_Open} opens a new connection to the mouse server. The connection
342
 
is described by the fields of the \var{conn} record:
343
 
\begin{description}
344
 
\item[EventMask] A bitmask of the events the program wants to receive.
345
 
\item[DefaultMask] A bitmask to tell the library which events get their
346
 
default treatment (text selection).
347
 
\item[minMod] the minimum amount of modifiers needed by the program.
348
 
\item[maxMod] the maximum amount of modifiers needed by the program.
349
 
\end{description}
350
 
if \var{Flag} is 0, then the application only receives events that come from
351
 
its own terminal device. If it is negative it will receive all events. If
352
 
the value is positive then it is considered a console number to which to
353
 
connect.
354
 
 
355
 
The return value is -1 on error, or the file descriptor used to communicate
356
 
with the client. Under an X-Term the return value is -2.
357
 
\Errors
358
 
On Error, the return value is -1.
359
 
\SeeAlso
360
 
\seefl{Gpm\_Open}{GpmOpen}
361
 
\end{functionl}
362
 
 
363
 
for an example, see \seefl{Gpm\_GetEvent}{GpmGetEvent}.
364
 
 
365
 
\begin{functionl}{Gpm\_PopRoi}{GpmPopRoi}
366
 
\Declaration
367
 
function Gpm\_PopRoi(which:PGpmRoi):PGpmRoi;cdecl;external;
368
 
\Description
369
 
\var{Gpm\_PopRoi} pops the topmost region of interest from the stack.
370
 
It returns the next element on the stack, or \var{Nil} if the current 
371
 
element was the last one.
372
 
\Errors
373
 
None.
374
 
\SeeAlso
375
 
\seefl{Gpm\_RaiseRoi}{GpmRaiseRoi},
376
 
\seefl{Gpm\_LowerRoi}{GpmLowerRoi}, 
377
 
\seefl{Gpm\_PushRoi}{GpmPopRoi} 
378
 
\end{functionl}
379
 
 
380
 
\begin{functionl}{Gpm\_PushRoi}{GpmPushRoi}
381
 
\Declaration
382
 
function Gpm\_PushRoi(x1:longint; y1:longint; X2:longint; Y2:longint; mask:longint; fun:TGpmHandler; xtradata:pointer):PGpmRoi;cdecl;external;
383
 
\Description
384
 
\var{Gpm\_PushRoi} puts a new {\em region of interest} on the stack.
385
 
The region of interest is defined by a rectangle described by the corners
386
 
\var{(X1,Y1)} and \var{(X2,Y2)}. 
387
 
 
388
 
The \var{mask} describes which events the handler {fun} will handle;
389
 
\var{ExtraData} will be put in the \var{xtradata} field of the {TGPM\_Roi} 
390
 
record passed to the \var{fun} handler.
391
 
\Errors
392
 
None.
393
 
\SeeAlso
394
 
\seefl{Gpm\_RaiseRoi}{GpmRaiseRoi},
395
 
\seefl{Gpm\_PopRoi}{GpmPopRoi}, 
396
 
\seefl{Gpm\_LowerRoi}{GpmLowerRoi} 
397
 
\end{functionl}
398
 
 
399
 
\begin{functionl}{Gpm\_RaiseRoi}{GpmRaiseRoi}
400
 
\Declaration
401
 
function Gpm\_RaiseRoi(which:PGpmRoi; before:PGpmRoi):PGpmRoi;cdecl;external;
402
 
\Description
403
 
\var{Gpm\_RaiseRoi} raises the {\em region of interest} \var{which} till it
404
 
is on top of region \var{before}. If \var{before} is nil then the region is
405
 
put on top of the stack. The returned value is the top of the stack.
406
 
\Errors
407
 
None.
408
 
\SeeAlso
409
 
\seefl{Gpm\_PushRoi}{GpmPushRoi},
410
 
\seefl{Gpm\_PopRoi}{GpmPopRoi}, 
411
 
\seefl{Gpm\_LowerRoi}{GpmLowerRoi} 
412
 
\end{functionl}
413
 
 
414
 
\begin{functionl}{Gpm\_Repeat}{GpmRepeat}
415
 
\Declaration
416
 
function Gpm\_Repeat(millisec:longint):longint;cdecl;external;
417
 
\Description
418
 
\var{Gpm\_Repeat} returns 1 of no mouse event arrives in the next
419
 
\var{millisec} miiliseconds, it returns 0 otherwise.
420
 
\Errors
421
 
None.
422
 
\SeeAlso
423
 
\seefl{Gpm\_GetEvent}{GpmGetEvent}
424
 
\end{functionl}
425
 
 
426
 
\begin{functionl}{Gpm\_StrictDouble}{GpmStrictDouble}
427
 
\Declaration
428
 
function Gpm\_StrictDouble(EventType : longint) : boolean;
429
 
\Description
430
 
\var{Gpm\_StrictDouble} returns true if \var{EventType} contains only a 
431
 
doubleclick event, \var{False} otherwise.
432
 
\Errors
433
 
None.
434
 
\SeeAlso
435
 
\seefl{Gpm\_StrictSingle}{GpmStrictSingle},
436
 
\seefl{Gpm\_AnyTriple}{GpmAnyTriple},
437
 
\seefl{Gpm\_AnyDouble}{GpmAnyDouble},
438
 
\seefl{Gpm\_StrictTriple}{GpmStrictTriple},
439
 
\seefl{Gpm\_AnySingle}{GpmAnySingle}
440
 
\end{functionl}
441
 
 
442
 
\begin{functionl}{Gpm\_StrictSingle}{GpmStrictSingle}
443
 
\Declaration
444
 
function Gpm\_StrictSingle(EventType : longint) : boolean;
445
 
\Description
446
 
\var{Gpm\_StrictDouble} returns \var{True} if \var{EventType} contains only a 
447
 
singleclick event, \var{False} otherwise. 
448
 
\Errors
449
 
None.
450
 
\SeeAlso
451
 
\seefl{Gpm\_AnyTriple}{GpmAnyTriple},
452
 
\seefl{Gpm\_StrictDouble}{GpmStrictDouble},
453
 
\seefl{Gpm\_AnyDouble}{GpmAnyDouble}, 
454
 
\seefl{Gpm\_StrictTriple}{GpmStrictTriple},
455
 
\seefl{Gpm\_AnySingle}{GpmAnySingle}
456
 
\end{functionl}
457
 
 
458
 
\begin{functionl}{Gpm\_StrictTriple}{GpmStrictTriple}
459
 
\Declaration
460
 
function Gpm\_StrictTriple(EventType : longint) : boolean;
461
 
\Description
462
 
\var{Gpm\_StrictTriple} returns true if \var{EventType} contains only a
463
 
triple click event, \var{False} otherwise.
464
 
\Errors
465
 
None.
466
 
\SeeAlso
467
 
\seefl{Gpm\_AnyTriple}{GpmAnyTriple},
468
 
\seefl{Gpm\_StrictDouble}{GpmStrictDouble},
469
 
\seefl{Gpm\_AnyDouble}{GpmAnyDouble}, 
470
 
\seefl{Gpm\_StrictSingle}{GpmStrictSingle},
471
 
\seefl{Gpm\_AnySingle}{GpmAnySingle}
472
 
\end{functionl}