summaryrefslogtreecommitdiff
path: root/specs/recordlib.xml
blob: 08d3eb253cfe64402ecb0d4baf829d8cb621a652 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % defs SYSTEM "defs.ent"> %defs;
]>


<!-- lifted from troff+ms+XMan by doclifter -->
<book id="recordlib">

<bookinfo>
   <title>X Record Extension Library</title>
   <subtitle>X Consortium Standard</subtitle>
   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
   <releaseinfo>Version 1.13</releaseinfo>
   <authorgroup>
      <author>
         <firstname>Martha</firstname><surname>Zimet</surname>
         <affiliation><orgname>Network Computing Devices, Inc.</orgname></affiliation>
      </author>
      <editor>
         <firstname>Stephen</firstname><surname>Gildea</surname>
         <affiliation><orgname>X Consortium</orgname></affiliation>
      </editor>
   </authorgroup>
   <copyright><year>1994</year><holder>Network Computing Devices, Inc.</holder></copyright>

<legalnotice>
<para>
Permission to use, copy, modify, distribute, and sell this
documentation for any purpose is hereby granted without fee,
provided that the above copyright notice and this permission
notice appear in all copies.  Network Computing Devices, Inc.
makes no representations about the suitability for any purpose
of the information in this document.  This documentation is
provided "as is" without express or implied warranty.
</para>
</legalnotice>

<legalnotice>
<para role="multiLicensing">Copyright © 1995 X Consortium</para>
<para>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the &ldquo;Software&rdquo;), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
</para>
<para>THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
</para>
<para>
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from the
X Consortium.
</para>
<para>X Window System is a trademark of The Open Group.</para>
</legalnotice>
</bookinfo>

<chapter id='Record_Extension_Overview'>
<title>Record Extension Overview</title>
<para>
The purpose of this extension is to support the recording and reporting of
all core X protocol and arbitrary X extension protocol. This first section
gives an overview of the Record extension. The following sections describe
how to use the Record extension library.
</para>

<sect1 id='Synchronous_Playback'>
<title>Synchronous Playback</title>
<para>
Environment information is generally provided to an X-based playback
mechanism, which might use the XTest extension to synthesize input
events. This synchronization information defines the X state prior to
event synthesis (for example, location of the cursor, window locations
and sizes, installed colormap, window manager running, and so on) and
the consequences that occur after the playback mechanism synthesizes
the event. If the user moves the mouse into the icon window and presses
and releases a mouse button, the device events
<function>MotionNotify</function>, <function>ButtonPress</function>,
and <function>ButtonRelease</function> are generated by the X server.
Because X follows an
event-driven model, there are consequences that follow from the user
actions, or device events, that are in the form of X protocol. As a result
of the previous user actions, the client could generate requests such as
<function>ImageText8</function> and <function>PolyLine</function> to the
X server, or the X server could send non-device events such as
<function>Expose</function> and <function>MapNotify</function> to the
client window. Both the
requests and non-device events that result from user actions are known
as consequences, which can be used as a synchronization, or control point,
during playback. That is, the playback mechanism does not generate a specific
synthesized event until its matching synchronization condition occurs
(for example, the window is mapped or unmapped, the cursor changes, a text
string displays, and so on)
</para>
<para>
Because it cannot be predicted what synchronization information is required
during playback, the Record extension makes no assumptions about the intended
use of the recorded data. Facilities exist to record any core X protocol or
X extension protocol. Therefore, Record does not enforce a specific
synchronization methodology.
</para>
</sect1>

<sect1 id='Design_Approach'>
<title>Design Approach</title>
<para>
The design approach of the extension is to record core X protocol and
arbitrary X extension protocol entirely within the X server itself. When
the extension has been requested to record specific protocol by one or more
recording clients, the protocol data is formatted and returned to the
recording clients. The extension provides a mechanism for capturing all
events, including input device events that do not go to any clients.
</para>
</sect1>

<sect1 id='Record_Clients'>
<title>Record Clients</title>
<para>
The recommended communication model for a Record application is to open two
connections to the server—one connection for recording control and one
connection for reading recorded protocol data.
</para>
<para>
Information about recording (for example, what clients to record, what
protocol to record for each client, and so on) is stored in resources
called record contexts (type <function>XRecordContext</function>). Most
Record extension functions take a record context as an argument. Although
in theory it is possible to share record contexts between applications,
it is expected that applications will use their own context when performing
recording operations.
</para>
<para>
A client that wishes to record X protocol does so through the library
functions defined in
<xref linkend='Library_Extension_Requests' xrefstyle='select: title'/>
A typical sequence of requests that a client would make is as follows:
</para>
<itemizedlist>
  <listitem>
    <para>
<xref linkend='XRecordQueryVersion' xrefstyle='select: title'/>
    </para>
    <para>
query the extension protocol version.
    </para>
</listitem>
<listitem>
    <para>
<xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
    </para>
    <para>
request that the server create a record context for access by this client,
and express interest in clients and protocol to be recorded. This request
returns an <function>XRecord-Context</function>, which is an XID that is
used by most other extension requests to identify the specified context.
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
    </para>
    <para>
begin the recording and reporting of protocol data.
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
    </para>
    <para>
end the recording and reporting of protocol data.
    </para>
  </listitem>
  <listitem>
    <para>
<xref linkend='XRecordFreeContext' xrefstyle='select: title'/>
    </para>
    <para>
free the record context.
    </para>
  </listitem>
</itemizedlist>

<para>
The header for this library is
&lt;<function>X11/extensions/record.h</function>&gt;. All identifiers defined
in the interface are supplied by this header and are prefixed with "XRecord".
The <function>Xtst</function> library contains the
<function>XRecord</function> functions.
</para>

</sect1>
</chapter>

<chapter id='Common_Arguments'>
<title>Common Arguments</title>
<para>
The Record extension functions <xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
 and <xref linkend='XRecordRegisterClients' xrefstyle='select: title'/> allow applications to
specify the following:
</para>
<itemizedlist>
  <listitem>
    <para>
Individual clients or sets of clients to record
    </para>
  </listitem>
  <listitem>
    <para>
Ranges of core X protocol and X extension protocol to record for each client
    </para>
  </listitem>
</itemizedlist>
<para>
Protocol in the ranges specified by the recording client will be recorded
by the server. The device_events protocol type can be specified by a
recording client although it may not be sent to a recorded client. The
device_events type differs from delivered_events, which also can be
specified by a recording client; delivered_events are actually delivered to
one or more clients. These event types are discussed in
<xref linkend='Protocol_Ranges' xrefstyle='select: title'/>
</para>


<para>
The Record extension functions <xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
 and <xref linkend='XRecordRegisterClients' xrefstyle='select: title'/> have the common arguments
datum_flags, clients, and ranges, which specify whether server time
and/or client sequence number should precede protocol elements, the
clients or client set to record, and the protocol ranges to record,
respectively. These are discussed in the following sections.
</para>

<sect1 id='Datum_Flags'>
<title>Datum Flags</title>
<para>
The datum_flags argument is a set of flags OR’ed together to specify options
for the record context.  Specify zero to disable all the options.
</para>

<para>
The <function>XRecordFromServerTime</function> flag specifies that
<function>XRecordInterceptData</function> structures with a category of
<function>XRecordFromServer</function> will have a server_time field specific to each
protocol element.
</para>

<para>
The <function>XRecordFromClientTime</function> flag specifies that
<function>XRecordInterceptData</function> structures with a category of
<function>XRecordFromClient</function> will have a server_time field specific
to each protocol element.
</para>

<para>
The <function>XRecordFromClientSequence</function> flag specifies that
<function>XRecordInterceptData</function> structures with a category of
<function>XRecordFromClient</function> or
<function>XRecordClientDied</function> will have a valid client_seq field.
</para>
</sect1>

<sect1 id='Selecting_Clients'>
<title>Selecting Clients</title>

<para>
The clients argument is a pointer to an array of
<function>XRecordClientSpec</function>.
<function>XRecordClientSpec</function> is an integral type that holds a
resource ID, a client resource ID base, or one of the client set constants
defined below.
</para>
<para>
Duplicate elements in the array are ignored by the functions, and if any
element in the array is not valid, a
<function>BadMatch</function>
error results. A resource ID references the client that created that
resource. The client set may be one of the following constants:
<function>XRecordCurrentClients</function>,
<function>XRecordFutureClients</function>, or
<function>XRecordAllClients</function>.
</para>
<para>
If the element in the array identifies a particular client, protocol
specified by the ranges argument will be recorded by the server. The
recorded protocol data will not be returned to the recording client until
the record context has been enabled. This is described in
<xref linkend='Data_Transfer' xrefstyle='select: title'/>
</para>
<para>
If the element is <function>XRecordCurrentClients</function>, the protocol
ranges specified by the ranges argument, except for device_events, are
associated with each current client connection. If the element is
<function>XRecordFutureClients</function>, the
protocol ranges specified by the ranges argument are associated with each new
client connection. If the element is
<function>XRecordAllClients</function>,
the protocol ranges specified by the ranges argument are associated with
each current client connection and with each new client connection.
When the context is enabled, the data connection is unregistered if it
was registered. If the context is enabled,
<function>XRecordCurrentClients</function> and
<function>XRecordAllClients</function>
silently exclude the recording data connection. It is an error to explicitly
register the data connection.
</para>
</sect1>
<sect1 id='Protocol_Ranges'>
<title>Protocol Ranges</title>

<para>
The functions <xref linkend='XRecordCreateContext' xrefstyle='select: title'/> and
<xref linkend='XRecordRegisterClients' xrefstyle='select: title'/> have another common argument,
ranges, which is an array of pointers to <function>XRecordRange</function>
structures. Each structure contains ranges of numeric values for each of
the protocol types that can be specified and recorded individually by the
Record extension. An <function>XRecordRange</function> structure must be
allocated by the Record library using the
<function>XRecordAllocRange</function> function.
</para>
<para>
The <function>XRecordRange</function> typedef is a structure with the
following members:
</para>

<literallayout remap='Ds'>
XRecordRange:
     XRecordRange8 core_requests     /* core X requests */
     XRecordRange8 core_replies      /* core X replies */
     XRecordExtRange ext_requests    /* extension requests */
     XRecordExtRange ext_replies     /* extension replies */
     XRecordRange8 delivered_events  /* delivered core and ext events */
     XRecordRange8 device_events     /* all core and ext device events */
     XRecordRange8 errors            /* core X and X ext errors */
     Bool client_started             /* connection setup reply from server */
     Bool client_died                /* notification of client disconnect */
</literallayout>

<para>
The types used in
<function>XRecordRange</function>
members are defined as follows.  The
<function>XRecordRange8</function>
typedef is a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordRange8:
     unsigned char first
     unsigned char last
</literallayout>

<para>
The
<function>XRecordRange16</function>
typedef is a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordRange16:
     unsigned short first
     unsigned short last
</literallayout>

<para>
The
<function>XRecordExtRange</function>
typedef is a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordExtRange:
     XRecordRange8  ext_major
     XRecordRange16 ext_minor
</literallayout>

<para>
If any of the values specified in
<function>XRecordRange</function>
is invalid, a
<function>BadValue</function>
error results.
</para>

<para>
The core_requests member specifies the range of core X protocol
requests to record.  Core X protocol requests with a major opcode
that is between first and last, inclusive, will be
recorded.  A
<function>BadValue</function>
error results if the value of first is greater than the value of last.
If the values of both first and last are zero, no core
X protocol requests will be recorded.
</para>

<para>
The core_replies member specifies the range of replies resulting
from core X protocol requests to record.  Replies that result from
core X protocol requests with a major opcode between first
and last, inclusive, will be recorded.  A
<function>BadValue</function>
error results if the value of first is greater than the value of last.
If the values of both first and last are zero, no core X protocol
replies will be recorded.
</para>

<para>
The ext_requests member specifies the range of X extension
requests to record.  X extension requests with a major opcode
between ext_major.first and ext_major.last, and with a
minor opcode
between ext_minor.first and ext_minor.last, inclusive, will be
recorded.  A
<function>BadValue</function>
error results
if the value of ext_major.first is greater than the value of
ext_major.last or if the value of ext_minor.first is
greater than the value of ext_minor.last.  If the values of both
ext_major.first
and ext_major.last are zero,
no X extension requests will be recorded.
</para>

<para>
The ext_replies member specifies the range of replies resulting
from X extension requests to record.  Replies that result from an X
extension request with a major opcode between
ext_major.first and
ext_major.last, and a minor opcode that is between
ext_minor.first and ext_minor.last will be recorded.  A
<function>BadValue</function>
error results
if the value of ext_major.first is greater than the value of
ext_major.last or if the value of ext_minor.first is greater than
the value of ext_minor.last.  If the values of both
ext_major.first and ext_major.last are zero, no X extension
replies will be recorded.
</para>

<para>
The delivered_events member specifies the range of both core
X events and X extension events to record.  These events are
delivered to at least one client.  Core X events and X extension events
with a code value between first and last inclusive will be recorded.  A
<function>BadValue</function>
error results if the value of first is greater than the value of last.
If the values of first and last are zero, no events will be recorded.
</para>

<para>
The device_events member specifies the range of both core X device
events and X extension device events to record.  These events may or
may not be delivered to a client.  Core X device events and X extension
device events with a code value between first and last inclusive that
are not delivered to any clients will be recorded.  A
<function>BadValue</function>
error results if the value of first is greater than the value of last.  A
<function>BadValue</function>
error results if first is less than two or last is less than two, except
that if first and last are zero, no events will be recorded.
</para>

<para>
The errors member specifies the range of both core X errors and X
extension errors to record.  Core X errors and X extension errors with
a code value between first and last inclusive will be
recorded.  A
<function>BadValue</function>
error results if the value of first is greater than the value of last.
If the values of first and last are zero, no errors will be recorded.
</para>

<para>
A value of
<function>True</function>
for the client_started member specifies the
connection setup reply from the server to new clients.  If
<function>False</function>
the connection setup reply is not specified by this
<function>XRecordRange</function>
</para>

<para>
A value of
<function>True</function>
for the client_died member specifies
notification when a client disconnects.  If
<function>False</function>
notification when a client disconnects is not specified by this
<function>XRecordRange</function>
</para>
</sect1>
</chapter>

<chapter id='Library_Extension_Requests'>
<title>Library Extension Requests</title>

<para>
Recording operations are accessed by programs through the use of
new protocol requests.  The following functions are provided as extensions
to Xlib.  An Xlib error results if
an extension request is made to an X server that does not support the
Record extension.  Note that any of the extension protocol requests may generate
<function>BadAlloc</function>
or
<function>BadLength</function>
errors.
</para>

<sect1 id='Query_Extension_Version'>
<title>Query Extension Version</title>

<para>
An application uses the
<xref linkend='XRecordQueryVersion' xrefstyle='select: title'/>
function to determine
the version of the Record extension protocol supported by an X server.
</para>

<funcsynopsis id='XRecordQueryVersion'>
<funcprototype>
  <funcdef>Status <function>XRecordQueryVersion</function></funcdef>
    <paramdef>Display <parameter> *display</parameter></paramdef>
    <paramdef>int <parameter> cmajor_return</parameter></paramdef>
    <paramdef>int <parameter> cminor_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Returns the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>cmajor_return</emphasis></term>
    <listitem><para>Returns the extension protocol major version in use.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>cminor_return</emphasis></term>
    <listitem><para>Returns the extension protocol minor version in use.</para></listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XRecordQueryVersion' xrefstyle='select: title'/>
function returns the major and minor protocol version numbers supported by
the server.
<xref linkend='XRecordQueryVersion' xrefstyle='select: title'/>
returns nonzero (success) only if the returned version numbers are
common to both the library and the server; otherwise, it returns zero.
</para>
</sect1>

<sect1 id='Create_and_Modify_Context'>
<title>Create and Modify Context</title>

<para>
An application uses the
<xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
function to create a record context.  At the time the record context is
created by the recording client, the clients to be recorded and the
protocol to record for each client may be specified.
</para>

<funcsynopsis id='XRecordCreateContext'>
<funcprototype>
  <funcdef>XRecordContext <function>XRecordCreateContext</function></funcdef>
    <paramdef>Display <parameter> *display</parameter></paramdef>
    <paramdef>int <parameter> datum_flags</parameter></paramdef>
    <paramdef>XRecordClientSpec <parameter> *clients</parameter></paramdef>
    <paramdef>int <parameter> nclients</parameter></paramdef>
    <paramdef>XRecordRange <parameter> *ranges</parameter></paramdef>
    <paramdef>int <parameter> nranges</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Returns the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>datum_flags</emphasis></term>
    <listitem><para>Specifies whether detailed time or sequence info should be sent.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>clients</emphasis></term>
    <listitem><para>Specifies the clients to record.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>nclients</emphasis></term>
    <listitem><para>Specifies the number of clients.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>ranges</emphasis></term>
    <listitem><para>Specifies the protocol ranges to record.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>nranges</emphasis></term>
    <listitem><para>Specifies the number of protocol ranges.</para></listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
function creates a record context and returns an
<function>XRecordContext</function>
which is then used in the other Record library calls.  This request is
typically executed by the recording client over its control connection to
the X server.  The datum_flags specifies whether server time and/or client
sequence number should precede protocol elements recorded by context (
<xref linkend='Datum_Flags' xrefstyle='select: title'/>
).  When a clients element identifies a particular client, the client is added
to the context and the protocol to record for that client is set to the
union of all ranges.  When a clients element is
<function>XRecordCurrentClients</function>
<function>XRecordFutureClients</function>
or
<function>XRecordAllClients</function>
the actions described in
<xref linkend='Selecting_Clients' xrefstyle='select: title'/>
are performed.
</para>

<para>
<xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
returns zero if the request failed.
<xref linkend='XRecordCreateContext' xrefstyle='select: title'/>
can generate
<function>BadIDChoice</function>
<function>BadMatch</function>
and
<function>BadValue</function>
errors.
</para>

<para>The ranges argument is an
<function>XRecordRange</function>
array, that is, an array
of pointers.  The structures the elements point to shall be allocated
by calling
<function>XRecordAllocRange</function></para>

<literallayout remap='FD'>
XRecordRange *
XRecordAllocRange(void)
</literallayout> <!-- remap='FN' -->

<para>
The
<function>XRecordAllocRange</function>
function
allocates and returns an
<function>XRecordRange</function>
structure.
The structure is initialized to specify no protocol.
The function returns NULL if the structure allocation fails.
The application can free the structure by calling
<olink targetdoc='libX11' targetptr='XFree'><function>XFree</function></olink>
</para>

<sect2 id='Additions'>
<title>Additions</title>

<para>
An application uses the
<xref linkend='XRecordRegisterClients' xrefstyle='select: title'/>
function to modify a previously created
record context, by adding clients or modifying the recorded protocol,
typically over its control connection to the X server.
</para>

<funcsynopsis id='XRecordRegisterClients'>
<funcprototype>
  <funcdef>Status <function>XRecordRegisterClients</function></funcdef>
    <paramdef>Display <parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext <parameter> context</parameter></paramdef>
    <paramdef>int <parameter> datum_flags</parameter></paramdef>
    <paramdef>XRecordClientSpec <parameter> *clients</parameter></paramdef>
    <paramdef>int <parameter> nclients</parameter></paramdef>
    <paramdef>XRecordRange <parameter> *ranges</parameter></paramdef>
    <paramdef>int <parameter> nranges</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Returns the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to modify.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>datum_flags</emphasis></term>
    <listitem><para>Specifies whether detailed time or sequence info should be sent.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>clients</emphasis></term>
    <listitem><para>Specifies the clients to record.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>nclients</emphasis></term>
    <listitem><para>Specifies the number of clients.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>ranges</emphasis></term>
    <listitem><para>Specifies the protocol ranges to record.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>nranges</emphasis></term>
    <listitem><para>Specifies the number of protocol ranges.</para></listitem>
  </varlistentry>
</variablelist>

<para>
The datum_flags specifies whether server time and/or client sequence number
should precede protocol elements for all clients recorded by context (See
<xref linkend='Datum_Flags' xrefstyle='select: title'/>
).  When a clients element identifies a particular client and the client is
not yet targeted for recording in the given context, the client is added
to the set of clients to record, and the protocol to record for that client
is set to the union of all ranges.  When the client is
already targeted for recording, the protocol to record for that client
is set to the union of all ranges.  When the element is
<function>XRecordCurrentClients</function>
<function>XRecordFutureClients</function>
or
<function>XRecordAllClients</function>
the actions described in
<xref linkend='Selecting_Clients' xrefstyle='select: title'/>
are performed.
</para>

<para>
<xref linkend='XRecordRegisterClients' xrefstyle='select: title'/>
returns zero if the request failed; otherwise, it
returns nonzero.
</para>

<para>
<xref linkend='XRecordRegisterClients' xrefstyle='select: title'/>
can generate
<function>XRecordBadContext</function>
<function>BadMatch</function>
and
<function>BadValue</function>
errors.
</para>
</sect2>

<sect2 id='Deletions'>
<title>Deletions</title>

<para>
An application uses the
<function>XRecordUnregisterClients</function>
function to delete clients from a previously created
record context, typically over its control connection to the X server.
</para>

<funcsynopsis id='XRecordUnRegisterClients'>
<funcprototype>
  <funcdef>Status <function>XRecordUnRegisterClients</function></funcdef>
    <paramdef>Display <parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext <parameter> context</parameter></paramdef>
    <paramdef>XRecordClientSpec <parameter> *clients</parameter></paramdef>
    <paramdef>int <parameter> nclients</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Returns the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to modify.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>clients</emphasis></term>
    <listitem><para>Specifies the clients to stop recording.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>nclients</emphasis></term>
    <listitem><para>Specifies the number of clients.</para></listitem>
  </varlistentry>
</variablelist>

<para>
When an element in clients identifies a particular client, and the
specified client is already targeted for recording in the given
context, the client and the set of protocol to record for that
client are deleted from the context.  If the specified client is not
targeted for recording, then no action is performed.
</para>

<para>
When the element is
<function>XRecordCurrentClients</function>
all clients currently targeted for recording in context and their
corresponding sets of protocol to record are deleted from context.
</para>

<para>
When the item is
<function>XRecordFutureClients</function>
any future client connections will not automatically be targeted for
recording in context.
</para>

<para>
When the element is
<function>XRecordAllClients</function>
all clients currently targeted for recording in context and their
corresponding sets of protocol to record are deleted from context.
Any future client connections will not automatically be targeted
for recording in context.
</para>

<para>
<function>XRecordUnregisterClients</function>
returns zero if the request failed; otherwise, it returns nonzero.
</para>

<para>
<function>XRecordUnregisterClients</function>
can generate
<function>XRecordBadContext</function>
<function>BadMatch</function>
and
<function>BadValue</function>
errors.</para>
</sect2>
</sect1>

<sect1 id='Query_Context_State'>
<title>Query Context State</title>

<para>
An application uses the
<xref linkend='XRecordGetContext' xrefstyle='select: title'/>
function to query the current state of a record context, typically over
its control connection to the X server.
</para>

<funcsynopsis id='XRecordGetContext'>
<funcprototype>
  <funcdef>Status <function>XRecordGetContext</function></funcdef>
    <paramdef>Display <parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext <parameter> context</parameter></paramdef>
    <paramdef>XRecordState <parameter> **state_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to query.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>state_return</emphasis></term>
    <listitem><para>Specifies the address of a variable into which
the function stores a pointer to the current state of the record context.
    </para></listitem>
  </varlistentry>
</variablelist>

<para>
The
<function>XRecordState</function>
typedef returned by
<xref linkend='XRecordGetContext' xrefstyle='select: title'/>
is a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordState:
     Bool              enabled
     int               datum_flags
     unsigned long     nclients
     XRecordClientInfo **client_info
</literallayout>

<para>
The enabled member is set to the state of data transfer and is
<function>True</function>
when the recording client has asked that recorded data be sent;
otherwise it is
<function>False</function>
The datum_flags member is set to the value of these flags for this context.
The nclients member is set to the number of
<function>XRecordClientInfo</function>
structures returned.  The client_info member is an array of pointers to
<function>XRecordClientInfo</function>
structures that contain the protocol to record for each targeted client.  The
<function>XRecordClientInfo</function>
typedef is a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordClientInfo:
     XRecordClientSpec client
     unsigned long nranges
     XRecordRange **ranges
</literallayout>

<para>
The client member either identifies a client targeted for recording
or is set to
<function>XRecordFutureClients</function>
to describe how future clients will be automatically targeted for recording.
The nranges member is set to the number of protocol
ranges to be recorded for the specified client.  The ranges member
is an array of pointers to
<function>XRecordRange</function>
structures, which specify the protocol ranges to record.
</para>

<para>
<xref linkend='XRecordGetContext' xrefstyle='select: title'/>
returns zero if the request failed; otherwise, it returns nonzero.
The context argument must specify a valid
<function>XRecordContext</function>
or a
<function>XRecordBadContext</function>
error results.
</para>

<para>
Recording clients should use the
<xref linkend='XRecordFreeState' xrefstyle='select: title'/>
function to free the state data returned by
<xref linkend='XRecordGetContext' xrefstyle='select: title'/>
</para>

<funcsynopsis id='XRecordFreeState'>
<funcprototype>
  <funcdef>void <function>XRecordFreeState</function></funcdef>
    <paramdef>XRecordState <parameter> *state</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>state</emphasis></term>
    <listitem><para>Specifies the structure that is to be freed.</para></listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XRecordFreeState' xrefstyle='select: title'/>
frees the data pointed to by state.  If the argument does not match an
<function>XRecordState</function>
pointer returned from a successful call to
<xref linkend='XRecordGetContext' xrefstyle='select: title'/>
or if
<xref linkend='XRecordFreeState' xrefstyle='select: title'/>
has already been called with it, the behavior is undefined.
</para>
</sect1>

<sect1 id='Data_Transfer'>
<title>Data Transfer</title>

<para>
An application uses the
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
and
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
functions to change the state of data transfer
between the X server and the recording client.  These functions allow
the application to start recording and reporting of protocol data
and to stop recording and reporting of protocol data, respectively.
</para>

<sect2 id='Enable_Context'>
<title>Enable Context</title>

<para>
To direct the X server to record and report protocol, a program uses
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
typically over its data connection to the X
server.  The reporting of recorded protocol back to the recording client
is handled by the following data structures and procedure definitions.
Each recorded protocol element is reported to the recording client through an
<function>XRecordInterceptData</function>
typedef, a structure with the following members:
</para>

<literallayout remap='Ds'>
XRecordInterceptData:
     XID              id_base
     Time             server_time
     unsigned long    client_seq
     int              category
     Bool             client_swapped
     unsigned char    *data
     unsigned long    data_len
</literallayout>

<para>
The id_base member is set to the resource identifier base sent to the
client in the connection setup reply and therefore identifies the client
being recorded, except when the recorded protocol data is a device
event that may have not been delivered to a client.  In this case,
id_base is set to zero.  The server_time member
is set to the time of the server when the protocol was recorded.
It is the time that was attached to this protocol element in the reply,
if so specified by datum_flags,
or else the time from the header of the reply that contained
this protocol element.
The client_seq member is the sequence number of the recorded
client's most recent request processed by the server at the time this
protocol element was recorded, if this information were included in the
recorded data; otherwise client_seq is 0.
The category member is set to one of the following values:
<function>XRecordStartOfData</function>
<function>XRecordFromServer</function>
<function>XRecordFromClient</function>
<function>XRecordClientStarted</function>
<function>XRecordClientDied</function>
or
<function>XRecordEndOfData</function>
<function>XRecordStartOfData</function>
is immediately sent as the first reply to confirm that the context is enabled.
<function>XRecordFromClient</function>
indicates the protocol
data is from the recorded client to the server (requests).
<function>XRecordFromServer</function>
indicates the protocol data is from the server to the recorded client
(replies, errors, events, or device events).
<function>XRecordClientStarted</function>
indicates that the protocol data is the connection setup reply from the server.
<function>XRecordClientDied</function>
indicates that the recorded client has closed its connection
to the X server; there is no protocol data.
<function>XRecordEndOfData</function>
indicates that the context has been disabled and that
this is the last datum.  It does not correspond to any protocol or
state change in a recorded client.  There is no protocol data.
</para>

<para>
The client_swapped member is set to
<function>True</function>
if the byte order of the client being recorded is swapped relative to
the recording client; otherwise, it is set to
<function>False</function>
All recorded protocol data is returned in the byte order of the recorded
client.  Therefore, recording clients are responsible for all byte swapping,
if required.  Device events are in the byte order of the recording client.
For replies of category
<function>XRecordStartOfData</function>
and
<function>XRecordEndOfData</function>
client_swapped is set according
to the byte order of the server relative to the recording client.
</para>

<para>
The data member contains the actual recorded protocol data.
When category is set to
<function>XRecordStartOfData</function>
<function>XRecordClientDied</function>
or
<function>XRecordEndOfData</function>
no protocol data are contained in data.
</para>


<!--  copied exactly from the protocol document -->
<para>
For the core X events
<function>KeyPress</function>
<function>KeyRelease</function>
<function>ButtonPress</function>
and
<function>ButtonRelease</function>,
the fields of a device event that contain
valid information are time and detail.  For the core X event
<function>MotionNotify</function>
the fields of a device event that contain valid information are time, root,
root-x and root-y.
The time field refers to the time the event was generated by the device.
</para>

<para>For the extension input device events
<function>DeviceKeyPress</function>
<function>DeviceKeyRelease</function>
<function>DeviceButtonPress</function>
and
<function>DeviceButtonRelease</function>
the fields of a device event that contain valid information are
device, time, and detail.  For
<function>DeviceMotionNotify</function>
the valid device event fields are device and time.
For the extension input device events
<function>ProximityIn</function>
and
<function>ProximityOut</function>
the fields of a device event that contain valid
information are device and time.  For the extension input device event
<function>DeviceValuator</function>
the fields of a device event that contain valid information are
device, num_valuators, first_valuator, and valuators.
The time field refers to the time the event was generated by the device.
</para>


<para>
The data_len member is set to the length of the actual recorded protocol
data in 4-byte units.
</para>

<para>
When the context has been enabled, protocol data the recording client has
previously expressed interest in is recorded and returned to the
recording client via multiple replies.  Because the X server batches
the recorded data, more than one protocol element may be contained
in the same reply packet.  When a reply is received, a procedure of type
<function>XRecordInterceptProc</function>
is called for each protocol element in the reply.
</para>

<funcsynopsis id='XRecordInterceptProc'>
<funcprototype>
  <funcdef>typedef void <function>(*XRecordInterceptProc)</function></funcdef>
    <paramdef>XPointer<parameter> closure</parameter></paramdef>
    <paramdef>XRecordInterceptData<parameter> *recorded_data</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>closure</emphasis></term>
    <listitem><para>Pointer that was passed in when the context was enabled.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>recorded_data</emphasis></term>
    <listitem><para>A protocol element recorded by the server extension.</para></listitem>
  </varlistentry>
</variablelist>

<para>
This callback may use the control display connection (or any display
connection other than the data connection).
</para>

<para>
Recording clients should use the
<xref linkend='XRecordFreeData' xrefstyle='select: title'/>
function to free the
<function>XRecordInterceptData</function>
structure.
</para>

<funcsynopsis id='XRecordEnableContext'>
<funcprototype>
  <funcdef>Status <function>XRecordEnableContext</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext<parameter> context</parameter></paramdef>
    <paramdef>XRecordInterceptProc<parameter> callback</parameter></paramdef>
    <paramdef>XPointer<parameter> closure</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to enable.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>callback</emphasis></term>
    <listitem><para>Specifies the function to be called for each protocol element received.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>closure</emphasis></term>
    <listitem><para>Specifies data passed to callback.</para></listitem>
  </varlistentry>
</variablelist>


<para>
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
enables data transfer between the recording client and
the X server.  All core and extension protocol received from or sent to
targeted clients that the recording client has expressed
interest in will be recorded and reported to the recording client.
</para>

<para>
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
returns zero if the request failed; otherwise, it
returns nonzero.  The context argument must specify a valid
<function>XRecordContext</function>
or a
<function>XRecordBadContext</function>
error results.  The error
<function>BadMatch</function>
results when data transfer is already enabled on the given context.
</para>
</sect2>

<sect2 id='Enable_Context_Asynchronously'>
<title>Enable Context Asynchronously</title>

<para>Because
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
does not return until
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
is executed on the control connection, a nonblocking interface in
addition to
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
is provided.  This interface also
enables data transfer; however, it does not block.
</para>

<para>
This interface is defined as follows:
</para>

<funcsynopsis id='XRecordEnableContextAsync'>
<funcprototype>
  <funcdef>Status <function>XRecordEnableContextAsync</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext<parameter> context</parameter></paramdef>
    <paramdef>XRecordInterceptProc<parameter> callback</parameter></paramdef>
    <paramdef>XPointer<parameter> closure</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to enable.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>callback</emphasis></term>
    <listitem><para>Specifies the function to be called for each protocol element received.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>closure</emphasis></term>
    <listitem><para>Specifies data passed to callback.</para></listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XRecordEnableContextAsync' xrefstyle='select: title'/>
enables data transfer between the recording
client and the X server just as
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
does.  Unlike
<xref linkend='XRecordEnableContext' xrefstyle='select: title'/>
it does not wait for the context to be disabled
before returning;
<xref linkend='XRecordEnableContextAsync' xrefstyle='select: title'/>
returns as soon as the
<function>XRecordStartOfData</function>
reply has been received and processed.
</para>

<para>
<xref linkend='XRecordEnableContextAsync' xrefstyle='select: title'/>
returns zero if it could not allocate the
necessary memory and nonzero if it sent the request successfully to
the server.  The context argument must specify a valid
<function>XRecordContext</function>
or a
<function>XRecordBadContext</function>
error results.  The error
<function>BadMatch</function>
results when data transfer is already enabled.
</para>

<para>
Each time it reads data from the server connection, Xlib will check
for incoming replies and call <emphasis remap='I'>callback</emphasis>
as necessary.  The application may direct Xlib explicitly to check
for Record data with the
<xref linkend='XRecordProcessReplies' xrefstyle='select: title'/>
function.
</para>

<funcsynopsis id='XRecordProcessReplies'>
<funcprototype>
  <funcdef>void <function>XRecordProcessReplies</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
</variablelist>

<para>
<xref linkend='XRecordProcessReplies' xrefstyle='select: title'/>
will check for any replies that have not yet
been processed by the application.  The asynchronous callback will be called
as appropriate.
<xref linkend='XRecordProcessReplies' xrefstyle='select: title'/>
returns when all immediately
available replies have been processed.  It does not block.
</para>

<para>To free the data passed to the
<function>XRecordInterceptProc</function>
callback, use
<xref linkend='XRecordFreeData' xrefstyle='select: title'/></para>

<funcsynopsis id='XRecordFreeData'>
<funcprototype>
  <funcdef>void <function>XRecordFreeData</function></funcdef>
    <paramdef>XRecordInterceptData<parameter> *data</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>data</emphasis></term>
    <listitem><para>Specifies the structure that is to be freed.</para></listitem>
  </varlistentry>
</variablelist>


<para>
<xref linkend='XRecordFreeData' xrefstyle='select: title'/>
frees the data pointed to by data.  If the argument does not match an
<function>XRecordInterceptData</function>
pointer earlier passed to an
<function>XRecordInterceptProc</function>
callback or if
<xref linkend='XRecordFreeData' xrefstyle='select: title'/>
has already been called with it, the behavior is undefined.
</para>
</sect2>

<sect2 id='Disable_Context'>
<title>Disable Context</title>

<para>
To direct the X server to halt the reporting of recorded protocol, the
program executes
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
typically over its control connection to the X server.
</para>

<funcsynopsis id='XRecordDisableContext'>
<funcprototype>
  <funcdef>Status <function>XRecordDisableContext</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext<parameter> context</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to disable.</para></listitem>
  </varlistentry>
</variablelist>


<para>
The
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
function disables context, stopping all recording over its data connection.
Any complete protocol elements for context that were buffered in the
server will be sent to the recording client rather than being discarded.
If a program attempts to disable an
<function>XRecordContext</function>
that has not been enabled, no action will take place.
</para>

<para>
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
returns zero if the request failed; otherwise, it
returns nonzero.  The context argument must specify a valid
<function>XRecordContext</function>
or an
<function>XRecordBadContext</function>
error results.
</para>
</sect2>
</sect1>

<sect1 id='ID_Base_Mask'>
<title>ID Base Mask</title>

<para>
To determine the mask the server uses for the client ID base, use
<xref linkend='XRecordIdBaseMask' xrefstyle='select: title'/></para>

<funcsynopsis id='XRecordIdBaseMask'>
<funcprototype>
  <funcdef>XID <function>XRecordIdBaseMask</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XRecordIdBaseMask' xrefstyle='select: title'/>
function returns the resource ID mask passed to the client by the
server at connection setup.
</para>

</sect1>

<sect1 id='Free_Context'>
<title>Free Context</title>

<para>
Before terminating, the program should request that the server
free the record context.  This is done with the
<xref linkend='XRecordFreeContext' xrefstyle='select: title'/>
function, typically over the record client's control connection
to the X server.
</para>

<funcsynopsis id='XRecordFreeContext'>
<funcprototype>
  <funcdef>Status <function>XRecordFreeContext</function></funcdef>
    <paramdef>Display<parameter> *display</parameter></paramdef>
    <paramdef>XRecordContext<parameter> context</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist remap='IP'>
  <varlistentry>
    <term><emphasis remap='I'>display</emphasis></term>
    <listitem><para>Specifies the connection to the X server.</para></listitem>
  </varlistentry>
  <varlistentry>
    <term><emphasis remap='I'>context</emphasis></term>
    <listitem><para>Specifies the record context to free.</para></listitem>
  </varlistentry>
</variablelist>

<para>
The
<xref linkend='XRecordFreeContext' xrefstyle='select: title'/>
function frees the given context for the
requesting client.  Freeing a record context releases the clients
targeted for recording and their respective protocol ranges to
record.  If protocol data is being reported to the recording client,
generally over the data connection to the X server, the reporting
ceases as if
<xref linkend='XRecordDisableContext' xrefstyle='select: title'/>
had been called on the given context.  When a program terminates
without freeing its record context, the X server will automatically
free that context on behalf of the client.
</para>

<para>
<xref linkend='XRecordFreeContext' xrefstyle='select: title'/>
returns zero if the request failed; otherwise,it
returns nonzero.  The context argument must specify a valid
<function>XRecordContext</function>
or a
<function>XRecordBadContext</function>
error results.
</para>

</sect1>
</chapter>
</book>