~bennabiy/+junk/python-xlib

« back to all changes in this revision

Viewing changes to .pc/remove-debugging-output.patch/Xlib/ext/randr.py

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura, Ramkumar Ramachandra, Andrew Shadura
  • Date: 2015-08-13 08:14:19 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150813081419-hdefinnghp2iydkx
Tags: 0.14+20091101-3
[ Ramkumar Ramachandra ]
* Remove useless debugging output (Closes: #565996)

[ Andrew Shadura ]
* Switch to 3.0 (quilt) format.
* Rename patches.
* Use debhelper 9 in its short form.
* Use pybuild.
* Bump Standards-Version.
* Don't build or install PostScript documentation and info files.
* Use system-provided texi2html instead of a shipped version
  (Closes: #795057).
* Update debian/copyright (Closes: #795057).
* Don't install Makefile or texi2html with the documentation.
* Set executable bit for examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Xlib.ext.randr -- RandR extension module
 
2
#
 
3
#    Copyright (C) 2006 Mike Meyer <mwm@mired.org>
 
4
#
 
5
#    This program is free software; you can redistribute it and/or modify
 
6
#    it under the terms of the GNU General Public License as published by
 
7
#    the Free Software Foundation; either version 2 of the License, or
 
8
#    (at your option) any later version.
 
9
#
 
10
#    This program is distributed in the hope that it will be useful,
 
11
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#    GNU General Public License for more details.
 
14
#
 
15
#    You should have received a copy of the GNU General Public License
 
16
#    along with this program; if not, write to the Free Software
 
17
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
 
 
20
 
 
21
"""RandR - provide access to the RandR extension information.
 
22
 
 
23
This implementation is based off version 1.3 of the XRandR protocol, and may
 
24
not be compatible with other versions.
 
25
 
 
26
Version 1.2 of the protocol is documented at:
 
27
http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
 
28
 
 
29
"""
 
30
 
 
31
 
 
32
from Xlib import X
 
33
from Xlib.protocol import rq, structs
 
34
 
 
35
extname = 'RANDR'
 
36
 
 
37
 
 
38
# Event codes #
 
39
RRScreenChangeNotify        = 0
 
40
 
 
41
# V1.2 additions
 
42
RRNotify                    = 1
 
43
 
 
44
# RRNotify Subcodes
 
45
RRNotify_CrtcChange         = 0
 
46
RRNotify_OutputChange       = 1
 
47
RRNotify_OutputProperty     = 2
 
48
 
 
49
 
 
50
# Event selection bits #
 
51
RRScreenChangeNotifyMask    = (1 << 0)
 
52
 
 
53
# V1.2 additions
 
54
RRCrtcChangeNotifyMask      = (1 << 1)
 
55
RROutputChangeNotifyMask    = (1 << 2)
 
56
RROutputPropertyNotifyMask  = (1 << 3)
 
57
 
 
58
 
 
59
# Constants #
 
60
SetConfigSuccess            = 0
 
61
SetConfigInvalidConfigTime  = 1
 
62
SetConfigInvalidTime        = 2
 
63
SetConfigFailed             = 3
 
64
 
 
65
# used in the rotation field; rotation and reflection in 0.1 proto.
 
66
Rotate_0                    = 1
 
67
Rotate_90                   = 2
 
68
Rotate_180                  = 4
 
69
Rotate_270                  = 8
 
70
 
 
71
# new in 1.0 protocol, to allow reflection of screen
 
72
Reflect_X                   = 16
 
73
Reflect_Y                   = 32
 
74
 
 
75
# new in 1.2 protocol
 
76
HSyncPositive               = 0x00000001
 
77
HSyncNegative               = 0x00000002
 
78
VSyncPositive               = 0x00000004
 
79
VSyncNegative               = 0x00000008
 
80
Interlace                   = 0x00000010
 
81
DoubleScan                  = 0x00000020
 
82
CSync                       = 0x00000040
 
83
CSyncPositive               = 0x00000080
 
84
CSyncNegative               = 0x00000100
 
85
HSkewPresent                = 0x00000200
 
86
BCast                       = 0x00000400
 
87
PixelMultiplex              = 0x00000800
 
88
DoubleClock                 = 0x00001000
 
89
ClockDivideBy2              = 0x00002000
 
90
 
 
91
# event types?
 
92
Connected                   = 0
 
93
Disconnected                = 1
 
94
UnknownConnection           = 2
 
95
 
 
96
# Conventional RandR output properties
 
97
PROPERTY_RANDR_EDID         = "EDID"
 
98
PROPERTY_SIGNAL_FORMAT      = "SignalFormat"
 
99
PROPERTY_SIGNAL_PROPERTIES  = "SignalProperties"
 
100
PROPERTY_CONNECTOR_TYPE     = "ConnectorType"
 
101
PROPERTY_CONNECTOR_NUMBER   = "ConnectorNumber"
 
102
PROPERTY_COMPATIBILITY_LIST = "CompatibilityList"
 
103
PROPERTY_CLONE_LIST         = "CloneList"
 
104
 
 
105
# subpixel order - TODO: These constants are part of the RENDER extension and
 
106
# should be moved there if/when that extension is added to python-xlib.
 
107
SubPixelUnknown             = 0
 
108
SubPixelHorizontalRGB       = 1
 
109
SubPixelHorizontalBGR       = 2
 
110
SubPixelVerticalRGB         = 3
 
111
SubPixelVerticalBGR         = 4
 
112
SubPixelNone                = 5
 
113
 
 
114
 
 
115
# Error Codes #
 
116
BadRROutput                 = 0
 
117
BadRRCrtc                   = 1
 
118
BadRRMode                   = 2
 
119
 
 
120
 
 
121
# Data Structures #
 
122
 
 
123
RandR_ScreenSizes = rq.Struct(
 
124
        rq.Card16('width_in_pixels'),
 
125
        rq.Card16('height_in_pixels'),
 
126
        rq.Card16('width_in_millimeters'),
 
127
        rq.Card16('height_in_millimeters'),
 
128
        )
 
129
 
 
130
 
 
131
RandR_ModeInfo = rq.Struct(
 
132
        rq.Card32('id'),
 
133
        rq.Card16('width'),
 
134
        rq.Card16('height'),
 
135
        rq.Card32('dot_clock'),
 
136
        rq.Card16('h_sync_start'),
 
137
        rq.Card16('h_sync_end'),
 
138
        rq.Card16('h_total'),
 
139
        rq.Card16('h_skew'),
 
140
        rq.Card16('v_sync_start'),
 
141
        rq.Card16('v_sync_end'),
 
142
        rq.Card16('v_total'),
 
143
        rq.Card16('name_length'),
 
144
        rq.Card32('flags'),
 
145
        )
 
146
 
 
147
RandR_Rates = rq.Struct(
 
148
        rq.LengthOf('rates', 2),
 
149
        rq.List('rates', rq.Card16Obj)
 
150
        )
 
151
 
 
152
# TODO: This struct is part of the RENDER extension and should be moved there
 
153
# if/when that extension is added to python-xlib.
 
154
Render_Transform = rq.Struct(
 
155
        rq.Card32('matrix11'), #FIXME: All of these are listed as FIXED in the protocol header.
 
156
        rq.Card32('matrix12'),
 
157
        rq.Card32('matrix13'),
 
158
        rq.Card32('matrix21'),
 
159
        rq.Card32('matrix22'),
 
160
        rq.Card32('matrix23'),
 
161
        rq.Card32('matrix31'),
 
162
        rq.Card32('matrix32'),
 
163
        rq.Card32('matrix33'),
 
164
        )
 
165
 
 
166
 
 
167
# Requests #
 
168
 
 
169
class QueryVersion(rq.ReplyRequest):
 
170
    _request = rq.Struct(
 
171
        rq.Card8('opcode'),
 
172
        rq.Opcode(0),
 
173
        rq.RequestLength(),
 
174
        rq.Card32('major_version'),
 
175
        rq.Card32('minor_version'),
 
176
        )
 
177
    _reply = rq.Struct(
 
178
        rq.ReplyCode(),
 
179
        rq.Pad(1),
 
180
        rq.Card16('sequence_number'),
 
181
        rq.ReplyLength(),
 
182
        rq.Card32('major_version'),
 
183
        rq.Card32('minor_version'),
 
184
        rq.Pad(16),
 
185
        )
 
186
 
 
187
def query_version(self):
 
188
    """Get the current version of the RandR extension.
 
189
 
 
190
    """
 
191
    return QueryVersion(
 
192
        display=self.display,
 
193
        opcode=self.display.get_extension_major(extname),
 
194
        major_version=1,
 
195
        minor_version=3,
 
196
        )
 
197
 
 
198
 
 
199
class _1_0SetScreenConfig(rq.ReplyRequest):
 
200
    _request = rq.Struct(
 
201
        rq.Card8('opcode'),
 
202
        rq.Opcode(2),
 
203
        rq.RequestLength(),
 
204
        rq.Drawable('drawable'),
 
205
        rq.Card32('timestamp'),
 
206
        rq.Card32('config_timestamp'),
 
207
        rq.Card16('size_id'),
 
208
        rq.Card16('rotation'),
 
209
        )
 
210
    _reply = rq.Struct(
 
211
        rq.ReplyCode(),
 
212
        rq.Card8('status'),
 
213
        rq.Card16('sequence_number'),
 
214
        rq.ReplyLength(),
 
215
        rq.Card32('new_timestamp'),
 
216
        rq.Card32('new_config_timestamp'),
 
217
        rq.Window('root'),
 
218
        rq.Card16('subpixel_order'),
 
219
        rq.Pad(10),
 
220
        )
 
221
 
 
222
def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime):
 
223
    """Sets the screen to the specified size and rotation.
 
224
 
 
225
    """
 
226
    return _1_0SetScreenConfig(
 
227
        display=self.display,
 
228
        opcode=self.display.get_extension_major(extname),
 
229
        drawable=self,
 
230
        timestamp=timestamp,
 
231
        config_timestamp=config_timestamp,
 
232
        size_id=size_id,
 
233
        rotation=rotation,
 
234
        )
 
235
 
 
236
 
 
237
class SetScreenConfig(rq.ReplyRequest):
 
238
    _request = rq.Struct(
 
239
        rq.Card8('opcode'),
 
240
        rq.Opcode(2),
 
241
        rq.RequestLength(),
 
242
        rq.Drawable('drawable'),
 
243
        rq.Card32('timestamp'),
 
244
        rq.Card32('config_timestamp'),
 
245
        rq.Card16('size_id'),
 
246
        rq.Card16('rotation'),
 
247
        rq.Card16('rate'), # added in version 1.1
 
248
        rq.Pad(2),
 
249
        )
 
250
    _reply = rq.Struct(
 
251
        rq.ReplyCode(),
 
252
        rq.Card8('status'),
 
253
        rq.Card16('sequence_number'),
 
254
        rq.ReplyLength(),
 
255
        rq.Card32('new_timestamp'),
 
256
        rq.Card32('new_config_timestamp'),
 
257
        rq.Window('root'),
 
258
        rq.Card16('subpixel_order'),
 
259
        rq.Pad(10),
 
260
        )
 
261
 
 
262
def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime):
 
263
    """Sets the screen to the specified size, rate, rotation and reflection.
 
264
 
 
265
    rate can be 0 to have the server select an appropriate rate.
 
266
 
 
267
    """
 
268
    return SetScreenConfig(
 
269
        display=self.display,
 
270
        opcode=self.display.get_extension_major(extname),
 
271
        drawable=self,
 
272
        timestamp=timestamp,
 
273
        config_timestamp=config_timestamp,
 
274
        size_id=size_id,
 
275
        rotation=rotation,
 
276
        rate=rate,
 
277
        )
 
278
 
 
279
 
 
280
class SelectInput(rq.Request):
 
281
    _request = rq.Struct(
 
282
        rq.Card8('opcode'),
 
283
        rq.Opcode(4),
 
284
        rq.RequestLength(),
 
285
        rq.Window('window'),
 
286
        rq.Card16('mask'),
 
287
        rq.Pad(2),
 
288
        )
 
289
 
 
290
def select_input(self, mask):
 
291
    return SelectInput(
 
292
        display=self.display,
 
293
        opcode=self.display.get_extension_major(extname),
 
294
        window=self,
 
295
        mask=mask,
 
296
        )
 
297
 
 
298
 
 
299
class GetScreenInfo(rq.ReplyRequest):
 
300
    _request = rq.Struct(
 
301
        rq.Card8('opcode'),
 
302
        rq.Opcode(5),
 
303
        rq.RequestLength(),
 
304
        rq.Window('window'),
 
305
        )
 
306
    _reply = rq.Struct(
 
307
        rq.ReplyCode(),
 
308
        rq.Card8('set_of_rotations'),
 
309
        rq.Card16('sequence_number'),
 
310
        rq.ReplyLength(),
 
311
        rq.Window('root'),
 
312
        rq.Card32('timestamp'),
 
313
        rq.Card32('config_timestamp'),
 
314
        rq.LengthOf('sizes', 2),
 
315
        rq.Card16('size_id'),
 
316
        rq.Card16('rotation'),
 
317
        rq.Card16('rate'), # added in version 1.1
 
318
        rq.Card16('n_rate_ents'), # XCB's protocol description disagrees with the X headers on this; ignoring.
 
319
        rq.Pad(2),
 
320
        rq.List('sizes', RandR_ScreenSizes),
 
321
        #rq.List('rates', RandR_Rates) #FIXME: Why does uncommenting this cause an error?
 
322
        )
 
323
 
 
324
def get_screen_info(self):
 
325
    """Retrieve information about the current and available configurations for
 
326
    the screen associated with this window.
 
327
 
 
328
    """
 
329
    return GetScreenInfo(
 
330
        display=self.display,
 
331
        opcode=self.display.get_extension_major(extname),
 
332
        window=self,
 
333
        )
 
334
 
 
335
 
 
336
# version 1.2
 
337
 
 
338
class GetScreenSizeRange(rq.ReplyRequest):
 
339
    _request = rq.Struct(
 
340
        rq.Card8('opcode'),
 
341
        rq.Opcode(6),
 
342
        rq.RequestLength(),
 
343
        rq.Window('window'),
 
344
        )
 
345
    _reply = rq.Struct(
 
346
        rq.ReplyCode(),
 
347
        rq.Pad(1),
 
348
        rq.Card16('sequence_number'),
 
349
        rq.ReplyLength(),
 
350
        rq.Card16('min_width'),
 
351
        rq.Card16('min_height'),
 
352
        rq.Card16('max_width'),
 
353
        rq.Card16('max_height'),
 
354
        rq.Pad(16),
 
355
        )
 
356
 
 
357
def get_screen_size_range(self):
 
358
    """Retrieve the range of possible screen sizes. The screen may be set to
 
359
        any size within this range.
 
360
 
 
361
    """
 
362
    return GetScreenSizeRange(
 
363
        display=self.display,
 
364
        opcode=self.display.get_extension_major(extname),
 
365
        window=self,
 
366
        )
 
367
 
 
368
 
 
369
class SetScreenSize(rq.Request):
 
370
    _request = rq.Struct(
 
371
        rq.Card8('opcode'),
 
372
        rq.Opcode(7),
 
373
        rq.RequestLength(),
 
374
        rq.Window('window'),
 
375
        rq.Card16('width'),
 
376
        rq.Card16('height'),
 
377
        rq.Card32('width_in_millimeters'),
 
378
        rq.Card32('height_in_millimeters'),
 
379
        )
 
380
 
 
381
def set_screen_size(self, width, height, width_in_millimeters=None, height_in_millimeters=None):
 
382
    return SetScreenSize(
 
383
        display=self.display,
 
384
        opcode=self.display.get_extension_major(extname),
 
385
        window=self,
 
386
        width=width,
 
387
        height=height,
 
388
        width_in_millimeters=width_in_millimeters,
 
389
        height_in_millimeters=height_in_millimeters,
 
390
        )
 
391
 
 
392
 
 
393
class GetScreenResources(rq.ReplyRequest):
 
394
    _request = rq.Struct(
 
395
        rq.Card8('opcode'),
 
396
        rq.Opcode(8),
 
397
        rq.RequestLength(),
 
398
        rq.Window('window'),
 
399
        )
 
400
    _reply = rq.Struct(
 
401
        rq.ReplyCode(),
 
402
        rq.Pad(1),
 
403
        rq.Card16('sequence_number'),
 
404
        rq.ReplyLength(),
 
405
        rq.Card32('timestamp'),
 
406
        rq.Card32('config_timestamp'),
 
407
        rq.LengthOf('crtcs', 2),
 
408
        rq.LengthOf('outputs', 2),
 
409
        rq.LengthOf('modes', 2),
 
410
        rq.LengthOf('mode_names', 2),
 
411
        rq.Pad(8),
 
412
        rq.List('crtcs', rq.Card32Obj),
 
413
        rq.List('outputs', rq.Card32Obj),
 
414
        rq.List('modes', RandR_ModeInfo),
 
415
        rq.String8('mode_names'),
 
416
        )
 
417
 
 
418
def get_screen_resources(self):
 
419
    return GetScreenResources(
 
420
        display=self.display,
 
421
        opcode=self.display.get_extension_major(extname),
 
422
        window=self,
 
423
        )
 
424
 
 
425
 
 
426
class GetOutputInfo(rq.ReplyRequest):
 
427
    _request = rq.Struct(
 
428
        rq.Card8('opcode'),
 
429
        rq.Opcode(9),
 
430
        rq.RequestLength(),
 
431
        rq.Card32('output'),
 
432
        rq.Card32('config_timestamp'),
 
433
        )
 
434
    _reply = rq.Struct(
 
435
        rq.ReplyCode(),
 
436
        rq.Card8('status'),
 
437
        rq.Card16('sequence_number'),
 
438
        rq.ReplyLength(),
 
439
        rq.Card32('timestamp'),
 
440
        rq.Card32('crtc'),
 
441
        rq.Card32('mm_width'),
 
442
        rq.Card32('mm_height'),
 
443
        rq.Card8('connection'),
 
444
        rq.Card8('subpixel_order'),
 
445
        rq.LengthOf('crtcs', 2),
 
446
        rq.LengthOf('modes', 2),
 
447
        rq.LengthOf('preferred', 2),
 
448
        rq.LengthOf('clones', 2),
 
449
        rq.LengthOf('name', 2),
 
450
        rq.List('crtcs', rq.Card32Obj),
 
451
        rq.List('modes', rq.Card32Obj),
 
452
        rq.List('preferred', rq.Card32Obj),
 
453
        rq.List('clones', rq.Card32Obj),
 
454
        rq.String8('name'),
 
455
        )
 
456
 
 
457
def get_output_info(self, output, config_timestamp):
 
458
    return GetOutputInfo(
 
459
        display=self.display,
 
460
        opcode=self.display.get_extension_major(extname),
 
461
        output=output,
 
462
        config_timestamp=config_timestamp,
 
463
        )
 
464
 
 
465
 
 
466
class ListOutputProperties(rq.ReplyRequest):
 
467
    _request = rq.Struct(
 
468
        rq.Card8('opcode'),
 
469
        rq.Opcode(10),
 
470
        rq.RequestLength(),
 
471
        rq.Card32('output'),
 
472
        )
 
473
    _reply = rq.Struct(
 
474
        rq.ReplyCode(),
 
475
        rq.Pad(1),
 
476
        rq.Card16('sequence_number'),
 
477
        rq.ReplyLength(),
 
478
        rq.LengthOf('atoms', 2),
 
479
        rq.Pad(22),
 
480
        rq.List('atoms', rq.Card32Obj),
 
481
        )
 
482
 
 
483
def list_output_properties(self, output):
 
484
    return ListOutputProperties (
 
485
        display=self.display,
 
486
        opcode=self.display.get_extension_major(extname),
 
487
        output=output,
 
488
        )
 
489
 
 
490
 
 
491
class QueryOutputProperty(rq.ReplyRequest):
 
492
    _request = rq.Struct(
 
493
        rq.Card8('opcode'),
 
494
        rq.Opcode(11),
 
495
        rq.RequestLength(),
 
496
        rq.Card32('output'),
 
497
        rq.Card32('property'),
 
498
        )
 
499
    _reply = rq.Struct(
 
500
        rq.ReplyCode(),
 
501
        rq.Pad(1),
 
502
        rq.Card16('sequence_number'),
 
503
        rq.ReplyLength(),
 
504
        rq.Bool('pending'),
 
505
        rq.Bool('range'),
 
506
        rq.Bool('immutable'),
 
507
        rq.Pad(21),
 
508
        rq.List('valid_values', rq.Card32Obj),
 
509
        )
 
510
 
 
511
def query_output_property(self, output, property):
 
512
    return QueryOutputProperty (
 
513
        display=self.display,
 
514
        opcode=self.display.get_extension_major(extname),
 
515
        output=output,
 
516
        property=property,
 
517
        )
 
518
 
 
519
 
 
520
class ConfigureOutputProperty (rq.Request):
 
521
    _request = rq.Struct(
 
522
        rq.Card8('opcode'),
 
523
        rq.Opcode(12),
 
524
        rq.RequestLength(),
 
525
        rq.Card32('output'),
 
526
        rq.Card32('property'),
 
527
        rq.Bool('pending'),
 
528
        rq.Bool('range'),
 
529
        rq.Pad(2),
 
530
        rq.List('valid_values', rq.Card32Obj),
 
531
        )
 
532
 
 
533
def configure_output_property (self, output, property):
 
534
    return ConfigureOutputProperty (
 
535
        display=self.display,
 
536
        opcode=self.display.get_extension_major(extname),
 
537
        output=output,
 
538
        property=property,
 
539
        )
 
540
 
 
541
 
 
542
class ChangeOutputProperty(rq.Request):
 
543
    _request = rq.Struct(
 
544
        rq.Card8('opcode'),
 
545
        rq.Opcode(13),
 
546
        rq.RequestLength(),
 
547
        rq.Card32('output'),
 
548
        rq.Card32('property'),
 
549
        rq.Card32('type'),
 
550
        rq.Format('value', 1),
 
551
        rq.Card8('mode'),
 
552
        rq.Pad(2),
 
553
        rq.LengthOf('value', 4),
 
554
        rq.List('value', rq.Card8Obj),
 
555
        )
 
556
 
 
557
def change_output_property(self, output, property, type, format, mode, nUnits):
 
558
    return ChangeOutputProperty(
 
559
        display=self.display,
 
560
        opcode=self.display.get_extension_major(extname),
 
561
        output=output,
 
562
        property=property,
 
563
        type=type,
 
564
        format=format,
 
565
        mode=mode,
 
566
        nUnits=nUnits,
 
567
        )
 
568
 
 
569
 
 
570
class DeleteOutputProperty(rq.Request):
 
571
    _request = rq.Struct(
 
572
        rq.Card8('opcode'),
 
573
        rq.Opcode(14),
 
574
        rq.RequestLength(),
 
575
        rq.Card32('output'),
 
576
        rq.Card32('property'),
 
577
        )
 
578
 
 
579
def delete_output_property(self, output, property):
 
580
    return DeleteOutputProperty(
 
581
        display=self.display,
 
582
        opcode=self.display.get_extension_major(extname),
 
583
        output=output,
 
584
        property=property,
 
585
        )
 
586
 
 
587
 
 
588
class GetOutputProperty(rq.ReplyRequest):
 
589
    _request = rq.Struct(
 
590
        rq.Card8('opcode'),
 
591
        rq.Opcode(15),
 
592
        rq.RequestLength(),
 
593
        rq.Card32('output'),
 
594
        rq.Card32('property'),
 
595
        rq.Card32('type'),
 
596
        rq.Card32('long_offset'),
 
597
        rq.Card32('long_length'),
 
598
        rq.Bool('delete'),
 
599
        rq.Bool('pending'),
 
600
        rq.Pad(2),
 
601
        )
 
602
    _reply = rq.Struct(
 
603
        rq.ReplyCode(),
 
604
        rq.Format('value', 1),
 
605
        rq.Card16('sequence_number'),
 
606
        rq.ReplyLength(),
 
607
        rq.Card32('property_type'),
 
608
        rq.Card32('bytes_after'),
 
609
        rq.LengthOf('value', 4),
 
610
        rq.Pad(12),
 
611
        rq.List('value', rq.Card8Obj),
 
612
        )
 
613
 
 
614
def get_output_property(self, output, property, type, longOffset, longLength):
 
615
    return GetOutputProperty(
 
616
        display=self.display,
 
617
        opcode=self.display.get_extension_major(extname),
 
618
        output=output,
 
619
        property=property,
 
620
        type=type,
 
621
        longOffset=longOffset,
 
622
        longLength=longLength,
 
623
        )
 
624
 
 
625
 
 
626
class CreateMode(rq.ReplyRequest):
 
627
    _request = rq.Struct(
 
628
        rq.Card8('opcode'),
 
629
        rq.Opcode(16),
 
630
        rq.RequestLength(),
 
631
        rq.Window('window'),
 
632
        rq.Object('mode', RandR_ModeInfo),
 
633
        rq.String8('name'),
 
634
        )
 
635
    _reply = rq.Struct(
 
636
        rq.ReplyCode(),
 
637
        rq.Pad(1),
 
638
        rq.Card16('sequence_number'),
 
639
        rq.ReplyLength(),
 
640
        rq.Card32('mode'),
 
641
        rq.Pad(20),
 
642
        )
 
643
 
 
644
def create_mode(self):
 
645
    return CreateMode (
 
646
        display=self.display,
 
647
        opcode=self.display.get_extension_major(extname),
 
648
        window=self,
 
649
        )
 
650
 
 
651
 
 
652
class DestroyMode(rq.Request):
 
653
    _request = rq.Struct(
 
654
        rq.Card8('opcode'),
 
655
        rq.Opcode(17),
 
656
        rq.RequestLength(),
 
657
        rq.Card32('mode'),
 
658
        )
 
659
 
 
660
def destroy_mode(self, mode):
 
661
    return DestroyMode(
 
662
        display=self.display,
 
663
        opcode=self.display.get_extension_major(extname),
 
664
        mode=mode,
 
665
        )
 
666
 
 
667
 
 
668
class AddOutputMode(rq.Request):
 
669
    _request = rq.Struct(
 
670
        rq.Card8('opcode'),
 
671
        rq.Opcode(18),
 
672
        rq.RequestLength(),
 
673
        rq.Card32('output'),
 
674
        rq.Card32('mode'),
 
675
        )
 
676
 
 
677
def add_output_mode(self):
 
678
    return AddOutputMode(
 
679
        display=self.display,
 
680
        opcode=self.display.get_extension_major(extname),
 
681
        output=output,
 
682
        mode=mode,
 
683
        )
 
684
 
 
685
 
 
686
class DeleteOutputMode(rq.Request):
 
687
    _request = rq.Struct(
 
688
        rq.Card8('opcode'),
 
689
        rq.Opcode(19),
 
690
        rq.RequestLength(),
 
691
        rq.Card32('output'),
 
692
        rq.Card32('mode'),
 
693
        )
 
694
 
 
695
def delete_output_mode(self):
 
696
    return DeleteOutputMode(
 
697
        display=self.display,
 
698
        opcode=self.display.get_extension_major(extname),
 
699
        output=output,
 
700
        mode=mode,
 
701
        )
 
702
 
 
703
 
 
704
class GetCrtcInfo(rq.ReplyRequest):
 
705
    _request = rq.Struct(
 
706
        rq.Card8('opcode'),
 
707
        rq.Opcode(20),
 
708
        rq.RequestLength(),
 
709
        rq.Card32('crtc'),
 
710
        rq.Card32('config_timestamp'),
 
711
        )
 
712
    _reply = rq.Struct(
 
713
        rq.ReplyCode(),
 
714
        rq.Card8('status'),
 
715
        rq.Card16('sequence_number'),
 
716
        rq.ReplyLength(),
 
717
        rq.Card32('timestamp'),
 
718
        rq.Card16('width'),
 
719
        rq.Card16('height'),
 
720
        rq.Card32('mode'),
 
721
        rq.Card16('rotation'),
 
722
        rq.Card16('possible_rotations'),
 
723
        rq.LengthOf('outputs', 2),
 
724
        rq.LengthOf('possible_outputs', 2),
 
725
        rq.List('outputs', rq.Card32Obj),
 
726
        rq.List('possible_outputs', rq.Card32Obj),
 
727
        )
 
728
 
 
729
def get_crtc_info(self, crtc, config_timestamp):
 
730
    return GetCrtcInfo (
 
731
        display=self.display,
 
732
        opcode=self.display.get_extension_major(extname),
 
733
        crtc=crtc,
 
734
        config_timestamp=config_timestamp,
 
735
        )
 
736
 
 
737
 
 
738
class SetCrtcConfig(rq.ReplyRequest):
 
739
    _request = rq.Struct(
 
740
        rq.Card8('opcode'),
 
741
        rq.Opcode(21),
 
742
        rq.RequestLength(),
 
743
        rq.Card32('crtc'),
 
744
        rq.Card32('timestamp'),
 
745
        rq.Card32('config_timestamp'),
 
746
        rq.Int16('x'),
 
747
        rq.Int16('y'),
 
748
        rq.Card32('mode'),
 
749
        rq.Card16('rotation'),
 
750
        rq.Pad(2),
 
751
        rq.List('outputs', rq.Card32Obj),
 
752
        )
 
753
    _reply = rq.Struct(
 
754
        rq.ReplyCode(),
 
755
        rq.Card8('status'),
 
756
        rq.Card16('sequence_number'),
 
757
        rq.ReplyLength(),
 
758
        rq.Card32('new_timestamp'),
 
759
        rq.Pad(20),
 
760
        )
 
761
 
 
762
def set_crtc_config(self, crtc, config_timestamp, mode, rotation, timestamp=X.CurrentTime):
 
763
    return SetCrtcConfig (
 
764
        display=self.display,
 
765
        opcode=self.display.get_extension_major(extname),
 
766
        crtc=crtc,
 
767
        config_timestamp=config_timestamp,
 
768
        mode=mode,
 
769
        rotation=rotation,
 
770
        timestamp=timestamp,
 
771
        )
 
772
 
 
773
 
 
774
class GetCrtcGammaSize(rq.ReplyRequest):
 
775
    _request = rq.Struct(
 
776
        rq.Card8('opcode'),
 
777
        rq.Opcode(22),
 
778
        rq.RequestLength(),
 
779
        rq.Card32('crtc'),
 
780
        )
 
781
    _reply = rq.Struct(
 
782
        rq.ReplyCode(),
 
783
        rq.Card8('status'),
 
784
        rq.Card16('sequence_number'),
 
785
        rq.ReplyLength(),
 
786
        rq.Card16('size'),
 
787
        rq.Pad(22),
 
788
        )
 
789
 
 
790
def get_crtc_gamma_size(self, crtc):
 
791
    return GetCrtcGammaSize (
 
792
        display=self.display,
 
793
        opcode=self.display.get_extension_major(extname),
 
794
        crtc=crtc,
 
795
        )
 
796
 
 
797
 
 
798
class GetCrtcGamma(rq.ReplyRequest):
 
799
    _request = rq.Struct(
 
800
        rq.Card8('opcode'),
 
801
        rq.Opcode(23),
 
802
        rq.RequestLength(),
 
803
        rq.Card32('crtc'),
 
804
        )
 
805
    _reply = rq.Struct(
 
806
        rq.ReplyCode(),
 
807
        rq.Card8('status'),
 
808
        rq.Card16('sequence_number'),
 
809
        rq.ReplyLength(),
 
810
        rq.Card16('size'),
 
811
        rq.Pad(22),
 
812
        rq.List('red', rq.Card16Obj),
 
813
        rq.List('green', rq.Card16Obj),
 
814
        rq.List('blue', rq.Card16Obj),
 
815
        )
 
816
 
 
817
def get_crtc_gamma(self, crtc):
 
818
    return GetCrtcGamma (
 
819
        display=self.display,
 
820
        opcode=self.display.get_extension_major(extname),
 
821
        crtc=crtc,
 
822
        )
 
823
 
 
824
 
 
825
class SetCrtcGamma(rq.Request):
 
826
    _request = rq.Struct(
 
827
        rq.Card8('opcode'),
 
828
        rq.Opcode(24),
 
829
        rq.RequestLength(),
 
830
        rq.Card32('crtc'),
 
831
        rq.Card16('size'),
 
832
        rq.Pad(2),
 
833
        rq.List('red', rq.Card16Obj),
 
834
        rq.List('green', rq.Card16Obj),
 
835
        rq.List('blue', rq.Card16Obj),
 
836
        )
 
837
 
 
838
def set_crtc_gamma(self, crtc, size):
 
839
    return SetCrtcGamma(
 
840
        display=self.display,
 
841
        opcode=self.display.get_extension_major(extname),
 
842
        crtc=crtc,
 
843
        size=size,
 
844
        )
 
845
 
 
846
 
 
847
# version 1.3
 
848
 
 
849
class GetScreenResourcesCurrent(rq.ReplyRequest):
 
850
    _request = rq.Struct(
 
851
        rq.Card8('opcode'),
 
852
        rq.Opcode(25),
 
853
        rq.RequestLength(),
 
854
        rq.Window('window'),
 
855
        )
 
856
    _reply = rq.Struct(
 
857
        rq.ReplyCode(),
 
858
        rq.Pad(1),
 
859
        rq.Card16('sequence_number'),
 
860
        rq.ReplyLength(),
 
861
        rq.Card32('timestamp'),
 
862
        rq.Card32('config_timestamp'),
 
863
        rq.LengthOf('crtcs', 2),
 
864
        rq.LengthOf('outputs', 2),
 
865
        rq.LengthOf('modes', 2),
 
866
        rq.LengthOf('names', 2),
 
867
        rq.Pad(8),
 
868
        rq.List('crtcs', rq.Card32Obj),
 
869
        rq.List('outputs', rq.Card32Obj),
 
870
        rq.List('modes', RandR_ModeInfo),
 
871
        rq.String8('names'),
 
872
        )
 
873
 
 
874
def get_screen_resources_current(self):
 
875
    return GetScreenResourcesCurrent(
 
876
        display=self.display,
 
877
        opcode=self.display.get_extension_major(extname),
 
878
        window=self,
 
879
        )
 
880
 
 
881
 
 
882
class SetCrtcTransform(rq.Request):
 
883
    _request = rq.Struct(
 
884
        rq.Card8('opcode'),
 
885
        rq.Opcode(26),
 
886
        rq.RequestLength(),
 
887
        rq.Card32('crtc'),
 
888
        rq.Object('transform', Render_Transform),
 
889
        rq.LengthOf('filter_name', 2),
 
890
        rq.Pad(2),
 
891
        rq.String8('filter_name'),
 
892
        rq.List('filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161
 
893
        )
 
894
 
 
895
def set_crtc_transform(self, crtc, n_bytes_filter):
 
896
    return SetCrtcTransform(
 
897
        display=self.display,
 
898
        opcode=self.display.get_extension_major(extname),
 
899
        crtc=crtc,
 
900
        n_bytes_filter=n_bytes_filter,
 
901
        )
 
902
 
 
903
 
 
904
class GetCrtcTransform(rq.ReplyRequest):
 
905
    _request = rq.Struct(
 
906
        rq.Card8('opcode'),
 
907
        rq.Opcode(27),
 
908
        rq.RequestLength(),
 
909
        rq.Card32('crtc'),
 
910
        )
 
911
    _reply = rq.Struct(
 
912
        rq.ReplyCode(),
 
913
        rq.Card8('status'),
 
914
        rq.Card16('sequence_number'),
 
915
        rq.ReplyLength(),
 
916
        rq.Object('pending_transform', Render_Transform),
 
917
        rq.Bool('has_transforms'),
 
918
        rq.Pad(3),
 
919
        rq.Object('current_transform', Render_Transform),
 
920
        rq.Pad(4),
 
921
        rq.LengthOf('pending_filter_name', 2),
 
922
        rq.LengthOf('pending_filter_params', 2),
 
923
        rq.LengthOf('current_filter_name', 2),
 
924
        rq.LengthOf('current_filter_params', 2),
 
925
        rq.String8('pending_filter_name'),
 
926
        rq.List('pending_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161
 
927
        rq.String8('current_filter_name'),
 
928
        rq.List('current_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161
 
929
        )
 
930
 
 
931
def get_crtc_transform(self, crtc):
 
932
    return GetCrtcTransform(
 
933
        display=self.display,
 
934
        opcode=self.display.get_extension_major(extname),
 
935
        crtc=crtc,
 
936
        )
 
937
 
 
938
 
 
939
class GetPanning(rq.ReplyRequest):
 
940
    _request = rq.Struct(
 
941
        rq.Card8('opcode'),
 
942
        rq.Opcode(28),
 
943
        rq.RequestLength(),
 
944
        rq.Card32('crtc'),
 
945
        )
 
946
    _reply = rq.Struct(
 
947
        rq.ReplyCode(),
 
948
        rq.Card8('status'),
 
949
        rq.Card16('sequence_number'),
 
950
        rq.ReplyLength(),
 
951
        rq.Card32('timestamp'),
 
952
        rq.Card16('left'),
 
953
        rq.Card16('top'),
 
954
        rq.Card16('width'),
 
955
        rq.Card16('height'),
 
956
        rq.Card16('track_left'),
 
957
        rq.Card16('track_top'),
 
958
        rq.Card16('track_width'),
 
959
        rq.Card16('track_height'),
 
960
        rq.Int16('border_left'),
 
961
        rq.Int16('border_top'),
 
962
        rq.Int16('border_right'),
 
963
        rq.Int16('border_bottom'),
 
964
        )
 
965
 
 
966
def get_panning(self, crtc):
 
967
    return GetPanning (
 
968
        display=self.display,
 
969
        opcode=self.display.get_extension_major(extname),
 
970
        crtc=crtc,
 
971
        )
 
972
 
 
973
 
 
974
class SetPanning(rq.ReplyRequest):
 
975
    _request = rq.Struct(
 
976
        rq.Card8('opcode'),
 
977
        rq.Opcode(29),
 
978
        rq.RequestLength(),
 
979
        rq.Card32('crtc'),
 
980
        rq.Card32('timestamp'),
 
981
        rq.Card16('left'),
 
982
        rq.Card16('top'),
 
983
        rq.Card16('width'),
 
984
        rq.Card16('height'),
 
985
        rq.Card16('track_left'),
 
986
        rq.Card16('track_top'),
 
987
        rq.Card16('track_width'),
 
988
        rq.Card16('track_height'),
 
989
        rq.Int16('border_left'),
 
990
        rq.Int16('border_top'),
 
991
        rq.Int16('border_right'),
 
992
        rq.Int16('border_bottom'),
 
993
        )
 
994
    _reply = rq.Struct(
 
995
        rq.ReplyCode(),
 
996
        rq.Card8('status'),
 
997
        rq.Card16('sequence_number'),
 
998
        rq.ReplyLength(),
 
999
        rq.Card32('new_timestamp'),
 
1000
        rq.Pad(20),
 
1001
        )
 
1002
 
 
1003
def set_panning(self, crtc, left, top, width, height, track_left, track_top, track_width, track_height, border_left, border_top, border_width, border_height, timestamp=X.CurrentTime):
 
1004
    return SetPanning (
 
1005
        display=self.display,
 
1006
        opcode=self.display.get_extension_major(extname),
 
1007
        crtc=crtc,
 
1008
        left=left,
 
1009
        top=top,
 
1010
        width=width,
 
1011
        height=height,
 
1012
        track_left=track_left,
 
1013
        track_top=track_top,
 
1014
        track_width=track_width,
 
1015
        track_height=track_height,
 
1016
        border_left=border_left,
 
1017
        border_top=border_top,
 
1018
        border_width=border_width,
 
1019
        border_height=border_height,
 
1020
        timestamp=timestamp,
 
1021
        )
 
1022
 
 
1023
 
 
1024
class SetOutputPrimary(rq.Request):
 
1025
    _request = rq.Struct(
 
1026
        rq.Card8('opcode'),
 
1027
        rq.Opcode(30),
 
1028
        rq.RequestLength(),
 
1029
        rq.Window('window'),
 
1030
        rq.Card32('output'),
 
1031
        )
 
1032
 
 
1033
def set_output_primary(self, output):
 
1034
    return SetOutputPrimary(
 
1035
        display=self.display,
 
1036
        opcode=self.display.get_extension_major(extname),
 
1037
        window=self,
 
1038
        output=output,
 
1039
        )
 
1040
 
 
1041
 
 
1042
class GetOutputPrimary(rq.ReplyRequest):
 
1043
    _request = rq.Struct(
 
1044
        rq.Card8('opcode'),
 
1045
        rq.Opcode(31),
 
1046
        rq.RequestLength(),
 
1047
        rq.Window('window'),
 
1048
        )
 
1049
    _reply = rq.Struct(
 
1050
        rq.ReplyCode(),
 
1051
        rq.Pad(1),
 
1052
        rq.Card16('sequence_number'),
 
1053
        rq.ReplyLength(),
 
1054
        rq.Card32('output'),
 
1055
        rq.Pad(20),
 
1056
        )
 
1057
 
 
1058
def get_output_primary(self):
 
1059
    return GetOutputPrimary(
 
1060
        display=self.display,
 
1061
        opcode=self.display.get_extension_major(extname),
 
1062
        window=self,
 
1063
        )
 
1064
 
 
1065
 
 
1066
# Events #
 
1067
 
 
1068
class ScreenChangeNotify(rq.Event):
 
1069
    _code = None
 
1070
    _fields = rq.Struct(
 
1071
        rq.Card8('type'),
 
1072
        rq.Card8('rotation'),
 
1073
        rq.Card16('sequence_number'),
 
1074
        rq.Card32('timestamp'),
 
1075
        rq.Card32('config_timestamp'),
 
1076
        rq.Window('root'),
 
1077
        rq.Window('window'),
 
1078
        rq.Card16('size_id'),
 
1079
        rq.Card16('subpixel_order'),
 
1080
        rq.Card16('width_in_pixels'),
 
1081
        rq.Card16('height_in_pixels'),
 
1082
        rq.Card16('width_in_millimeters'),
 
1083
        rq.Card16('height_in_millimeters'),
 
1084
        )
 
1085
 
 
1086
 
 
1087
class CrtcChangeNotify(rq.Event):
 
1088
    _code = None
 
1089
    _fields = rq.Struct(
 
1090
        rq.Card8('type'),
 
1091
        rq.Card8('sub_code'),
 
1092
        rq.Card16('sequence_number'),
 
1093
        rq.Card32('timestamp'),
 
1094
        rq.Window('window'),
 
1095
        rq.Card32('crtc'),
 
1096
        rq.Card32('mode'),
 
1097
        rq.Card16('rotation'),
 
1098
        rq.Pad(2),
 
1099
        rq.Int16('x'),
 
1100
        rq.Int16('y'),
 
1101
        rq.Card16('width'),
 
1102
        rq.Card16('height'),
 
1103
        )
 
1104
 
 
1105
 
 
1106
class OutputChangeNotify(rq.Event):
 
1107
    _code = None
 
1108
    _fields = rq.Struct(
 
1109
        rq.Card8('type'),
 
1110
        rq.Card8('sub_code'),
 
1111
        rq.Card16('sequence_number'),
 
1112
        rq.Card32('timestamp'),
 
1113
        rq.Card32('config_timestamp'),
 
1114
        rq.Window('window'),
 
1115
        rq.Card32('output'),
 
1116
        rq.Card32('crtc'),
 
1117
        rq.Card32('mode'),
 
1118
        rq.Card16('rotation'),
 
1119
        rq.Card8('connection'),
 
1120
        rq.Card8('subpixel_order'),
 
1121
        )
 
1122
 
 
1123
 
 
1124
class OutputPropertyNotify(rq.Event):
 
1125
    _code = None
 
1126
    _fields = rq.Struct(
 
1127
        rq.Card8('type'),
 
1128
        rq.Card8('sub_code'),
 
1129
        rq.Card16('sequence_number'),
 
1130
        rq.Window('window'),
 
1131
        rq.Card32('output'),
 
1132
        rq.Card32('atom'),
 
1133
        rq.Card32('timestamp'),
 
1134
        rq.Card8('state'),
 
1135
        rq.Pad(11),
 
1136
        )
 
1137
 
 
1138
 
 
1139
# Initialization #
 
1140
 
 
1141
def init(disp, info):
 
1142
    print(info.__class__)
 
1143
 
 
1144
    disp.extension_add_method('display', 'xrandr_query_version', query_version)
 
1145
    disp.extension_add_method('window', 'xrandr_select_input', select_input)
 
1146
    disp.extension_add_method('window', 'xrandr_get_screen_info', get_screen_info)
 
1147
    disp.extension_add_method('drawable', 'xrandr_1_0set_screen_config', _1_0set_screen_config)
 
1148
    disp.extension_add_method('drawable', 'xrandr_set_screen_config', set_screen_config)
 
1149
    disp.extension_add_method('window', 'xrandr_get_screen_size_range', get_screen_size_range)
 
1150
    disp.extension_add_method('window', 'xrandr_set_screen_size', set_screen_size)
 
1151
    disp.extension_add_method('window', 'xrandr_get_screen_resources', get_screen_resources)
 
1152
    disp.extension_add_method('display', 'xrandr_get_output_info', get_output_info)
 
1153
    disp.extension_add_method('display', 'xrandr_list_output_properties', list_output_properties)
 
1154
    disp.extension_add_method('display', 'xrandr_query_output_property', query_output_property)
 
1155
    disp.extension_add_method('display', 'xrandr_configure_output_property ', configure_output_property )
 
1156
    disp.extension_add_method('display', 'xrandr_change_output_property', change_output_property)
 
1157
    disp.extension_add_method('display', 'xrandr_delete_output_property', delete_output_property)
 
1158
    disp.extension_add_method('display', 'xrandr_get_output_property', get_output_property)
 
1159
    disp.extension_add_method('window', 'xrandr_create_mode', create_mode)
 
1160
    disp.extension_add_method('display', 'xrandr_destroy_mode', destroy_mode)
 
1161
    disp.extension_add_method('display', 'xrandr_add_output_mode', add_output_mode)
 
1162
    disp.extension_add_method('display', 'xrandr_delete_output_mode', delete_output_mode)
 
1163
    disp.extension_add_method('display', 'xrandr_get_crtc_info', get_crtc_info)
 
1164
    disp.extension_add_method('display', 'xrandr_set_crtc_config', set_crtc_config)
 
1165
    disp.extension_add_method('display', 'xrandr_get_crtc_gamma_size', get_crtc_gamma_size)
 
1166
    disp.extension_add_method('display', 'xrandr_get_crtc_gamma', get_crtc_gamma)
 
1167
    disp.extension_add_method('display', 'xrandr_set_crtc_gamma', set_crtc_gamma)
 
1168
    disp.extension_add_method('window', 'xrandr_get_screen_resources_current', get_screen_resources_current)
 
1169
    disp.extension_add_method('display', 'xrandr_set_crtc_transform', set_crtc_transform)
 
1170
    disp.extension_add_method('display', 'xrandr_get_crtc_transform', get_crtc_transform)
 
1171
    disp.extension_add_method('window', 'xrandr_set_output_primary', set_output_primary)
 
1172
    disp.extension_add_method('window', 'xrandr_get_output_primary', get_output_primary)
 
1173
    disp.extension_add_method('display', 'xrandr_get_panning', get_panning)
 
1174
    disp.extension_add_method('display', 'xrandr_set_panning', set_panning)
 
1175
 
 
1176
    disp.extension_add_event(info.first_event, ScreenChangeNotify)
 
1177
    disp.extension_add_event(info.first_event + 1, CrtcChangeNotify)
 
1178
    disp.extension_add_event(info.first_event + 2, OutputChangeNotify)
 
1179
    disp.extension_add_event(info.first_event + 3, OutputPropertyNotify)
 
1180
 
 
1181
    #disp.extension_add_error(BadRROutput, BadRROutputError)
 
1182
    #disp.extension_add_error(BadRRCrtc, BadRRCrtcError)
 
1183
    #disp.extension_add_error(BadRRMode, BadRRModeError)