Esempio n. 1
0
class GetScreenResources(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(8),
        rq.RequestLength(),
        rq.Window('window'),
    )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('timestamp'),
        rq.Card32('config_timestamp'),
        rq.LengthOf('crtcs', 2),
        rq.LengthOf('outputs', 2),
        rq.LengthOf('modes', 2),
        rq.LengthOf('mode_names', 2),
        rq.Pad(8),
        rq.List('crtcs', rq.Card32Obj),
        rq.List('outputs', rq.Card32Obj),
        rq.List('modes', RandR_ModeInfo),
        rq.String8('mode_names'),
    )
Esempio n. 2
0
class QueryScreens(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(5),
        rq.RequestLength(),
    )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('number'),
        rq.Pad(20),
        rq.List('screens', structs.Rectangle),
    )
Esempio n. 3
0
class XIPassiveUngrabDevice(rq.Request):

    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(55),
        rq.RequestLength(),
        rq.Window('grab_window'),
        rq.Card32('detail'),
        DEVICEID('deviceid'),
        rq.LengthOf('modifiers', 2),
        rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter,
                                GrabtypeFocusIn, GrabtypeTouchBegin)),
        rq.Pad(3),
        rq.List('modifiers', rq.Card32),
    )
Esempio n. 4
0
class GetCrtcInfo(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(20),
        rq.RequestLength(),
        rq.Card32('crtc'),
        rq.Card32('config_timestamp'),
    )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('status'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('timestamp'),
        rq.Card16('width'),
        rq.Card16('height'),
        rq.Card32('mode'),
        rq.Card16('rotation'),
        rq.Card16('possible_rotations'),
        rq.LengthOf('outputs', 2),
        rq.LengthOf('possible_outputs', 2),
        rq.List('outputs', rq.Card32Obj),
        rq.List('possible_outputs', rq.Card32Obj),
    )
Esempio n. 5
0
class ListOutputProperties(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(10),
        rq.RequestLength(),
        rq.Card32('output'),
    )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('atoms', 2),
        rq.Pad(22),
        rq.List('atoms', rq.Card32Obj),
    )
Esempio n. 6
0
class ListHosts(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(110),
        rq.Pad(1),
        rq.RequestLength(),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('mode'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('hosts', 2),
        rq.Pad(22),
        rq.List('hosts', structs.Host),
        )
Esempio n. 7
0
class GetFontPath(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(52),
        rq.Pad(1),
        rq.RequestLength(),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('paths', 2),
        rq.Pad(22),
        rq.List('paths', rq.Str),
        )
Esempio n. 8
0
class ListInstalledColormaps(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(83),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Window('window')
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('cmaps', 2),
        rq.Pad(22),
        rq.List('cmaps', rq.ColormapObj),
        )
Esempio n. 9
0
class ListProperties(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(21),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Window('window')
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('atoms', 2),
        rq.Pad(22),
        rq.List('atoms', rq.Card32Obj),
        )
Esempio n. 10
0
class QueryPictIndexValues(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(2),
        rq.RequestLength(),
        PictFormat('format'),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('indexvalues', 4),
        rq.Pad(20),
        rq.List('indexvalues', IndexValue),
    )
Esempio n. 11
0
class XIListProperties(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(56),
        rq.RequestLength(),
        DEVICEID('deviceid'),
        rq.Pad(2),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('atoms', 2),
        rq.Pad(22),
        rq.List('atoms', rq.Card32Obj),
    )
Esempio n. 12
0
class XIQueryDevice(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(48),
        rq.RequestLength(),
        DEVICEID('deviceid'),
        rq.Pad(2),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('devices', 2),
        rq.Pad(22),
        rq.List('devices', DeviceInfo),
    )
Esempio n. 13
0
class ListFonts(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(49),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Card16('max_names'),
        rq.LengthOf('pattern', 2),
        rq.String8('pattern'),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('fonts', 2),
        rq.Pad(22),
        rq.List('fonts', rq.Str),
        )
Esempio n. 14
0
class GetMotionEvents(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(39),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Window('window'),
        rq.Card32('start'),
        rq.Card32('stop'),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('events', 4),
        rq.Pad(20),
        rq.List('events', structs.TimeCoord),
        )
Esempio n. 15
0
class QueryTree(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(15),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Window('window')
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Window('root'),
        rq.Window('parent', (X.NONE, )),
        rq.LengthOf('children', 2),
        rq.Pad(14),
        rq.List('children', rq.WindowObj),
        )
Esempio n. 16
0
class GetRectangles(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(8),
        rq.RequestLength(),
        rq.Window('window'),
        rq.Set('region', 1, (ShapeBounding, ShapeClip)),
        rq.Pad(3),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('ordering'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('rectangles', 4),
        rq.Pad(20),
        rq.List('rectangles', structs.Rectangle),
    )
Esempio n. 17
0
class QueryOutputProperty(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(11),
        rq.RequestLength(),
        rq.Card32('output'),
        rq.Card32('property'),
    )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Bool('pending'),
        rq.Bool('range'),
        rq.Bool('immutable'),
        rq.Pad(21),
        rq.List('valid_values', rq.Card32Obj),
    )
Esempio n. 18
0
class GetRectangles(rq.ReplyRequest):

    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(8),
        rq.RequestLength(),
        rq.Window('window'),
        KIND('source_kind'),
        rq.Pad(3),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('ordering'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('rectangles', 4),
        rq.Pad(20),
        rq.List('rectangles', structs.Rectangle, pad=0),
    )
Esempio n. 19
0
class _SetCrtcConfig(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(21),
        rq.RequestLength(),
        rq.Card32('crtc'),
        rq.Card32('timestamp'),
        rq.Card32('config_timestamp'),
        rq.Int16('x'),
        rq.Int16('y'),
        rq.Card32('mode'),
        rq.Card16('rotation'),
        rq.Pad(2),
        rq.List('outputs', rq.Card32Obj),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('status'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card32('new_timestamp'),
        rq.Pad(20),
        )
Esempio n. 20
0
class SecurityGenerateAuthorization(rq.ReplyRequest):
    # The order of fields here does not match the specifications I've seen
    # online, but it *does* match with the X.org implementation.  I guess the
    # spec is out-of-date.
    _request = rq.Struct(rq.Card8('opcode'),
                         rq.Opcode(1),
                         rq.RequestLength(),
                         rq.LengthOf('auth_proto', 2),
                         rq.LengthOf('auth_data', 2),
                         rq.Card32('value_mask'),
                         rq.String8('auth_proto'),
                         rq.Binary('auth_data'),
                         rq.List('values', rq.Card32Obj)
                         )
    _reply = rq.Struct(rq.ReplyCode(),
                       rq.Pad(1),
                       rq.Card16('sequence_number'),
                       rq.ReplyLength(),
                       AUTHID('authid'),
                       rq.LengthOf('auth_data_return', 2),
                       rq.Pad(18),
                       rq.Binary('auth_data_return')
                       )
Esempio n. 21
0
class GetScreenInfo(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(5),
        rq.RequestLength(),
        rq.Window('window'),
        )
    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Card8('set_of_rotations'),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Window('root'),
        rq.Card32('timestamp'),
        rq.Card32('config_timestamp'),
        rq.LengthOf('sizes', 2),
        rq.Card16('size_id'),
        rq.Card16('rotation'),
        rq.Card16('rate'), # added in version 1.1
        rq.Card16('n_rate_ents'), # XCB's protocol description disagrees with the X headers on this; ignoring.
        rq.Pad(2),
        rq.List('sizes', RandR_ScreenSizes),
        #rq.List('rates', RandR_Rates) #FIXME: Why does uncommenting this cause an error?
        )
Esempio n. 22
0
    ('c8', rq.Card8, 0x42, partial(pack, 'B')),
    ('c16', rq.Card16, 0x666, partial(pack, 'H')),
    ('c32', rq.Card32, 0xdeadbeef, partial(pack, 'L')),
))

_struct_test('int', (
    ('i8', rq.Int8, -42, partial(pack, 'b')),
    ('i16', rq.Int16, -666, partial(pack, 'h')),
    ('i32', rq.Int32, -2147483648, partial(pack, 'l')),
))

_struct_test('list', (
    (None, lambda name: rq.LengthOf('lc8', 1), None, pack('B', 2)),
    (None, lambda name: rq.LengthOf('lc16', 2), None, pack('H', 3)),
    (None, lambda name: rq.LengthOf('lc32', 4), None, pack('L', 5)),
    ('lc8', lambda name: rq.List(name, rq.Card8, pad=0), [0x42, 0xc3],
     lambda v: pack('2B', *v)),
    ('lc16', lambda name: rq.List(name, rq.Card16, pad=0), [666, 1, 60143],
     lambda v: pack('3H', *v)),
    ('lc32', lambda name: rq.List(name, rq.Card32, pad=0),
     [0xf02facb, 666, 1, 0x1043, 0xdeadbeef], lambda v: pack('5L', *v)),
))

_struct_test('list pad', (
    (None, lambda name: rq.LengthOf('lc8', 1), None, pack('B', 2)),
    (None, lambda name: rq.LengthOf('lc16', 2), None, pack('H', 3)),
    (None, lambda name: rq.LengthOf('lc32', 4), None, pack('L', 5)),
    ('lc8', lambda name: rq.List(name, rq.Card8, pad=1), [0x42, 0xc3],
     lambda v: pack('2B2x', *v)),
    ('lc16', lambda name: rq.List(name, rq.Card16, pad=1), [666, 1, 60143],
     lambda v: pack('3H2x', *v)),
Esempio n. 23
0
    def __init__(self, name, size, item_size):
        rq.LengthOf.__init__(self, name, size)
        self.item_size = item_size

    def parse_value(self, length, display):
        return length // self.item_size


ClientXIDMask = 1 << 0
LocalClientPIDMask = 1 << 1

ClientIdSpec = rq.Struct(rq.Card32("client"), rq.Card32("mask"))

ClientIdValue = rq.Struct(rq.Object("spec",
                                    ClientIdSpec), SizeOf("value", 4, 4),
                          rq.List("value", rq.Card32Obj))


class QueryClientIds(rq.ReplyRequest):
    _request = rq.Struct(rq.Card8("opcode"), rq.Opcode(ResQueryClientIds),
                         rq.RequestLength(), rq.LengthOf("specs", 4),
                         rq.List("specs", ClientIdSpec))
    _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"),
                       rq.ReplyLength(), rq.LengthOf("ids", 4), rq.Pad(20),
                       rq.List("ids", ClientIdValue))


def query_client_ids(self, specs):
    """Request to identify a given set of clients with some identification method.

    The request sends a list of specifiers that select clients and
Esempio n. 24
0
class QueryClients(rq.ReplyRequest):
    _request = rq.Struct(rq.Card8("opcode"), rq.Opcode(ResQueryClients),
                         rq.RequestLength())
    _reply = rq.Struct(rq.ReplyCode(), rq.Pad(1), rq.Card16("sequence_number"),
                       rq.ReplyLength(), rq.LengthOf("clients", 4), rq.Pad(20),
                       rq.List("clients", Client))
Esempio n. 25
0
    rq.Card16('width'),
    rq.Card16('height'),
    rq.Card32('dot_clock'),
    rq.Card16('h_sync_start'),
    rq.Card16('h_sync_end'),
    rq.Card16('h_total'),
    rq.Card16('h_skew'),
    rq.Card16('v_sync_start'),
    rq.Card16('v_sync_end'),
    rq.Card16('v_total'),
    rq.Card16('name_length'),
    rq.Card32('flags'),
)

RandR_Rates = rq.Struct(rq.LengthOf('rates', 2),
                        rq.List('rates', rq.Card16Obj))

# TODO: This struct is part of the RENDER extension and should be moved there
# if/when that extension is added to python-xlib.
Render_Transform = rq.Struct(
    rq.Card32(
        'matrix11'
    ),  #FIXME: All of these are listed as FIXED in the protocol header.
    rq.Card32('matrix12'),
    rq.Card32('matrix13'),
    rq.Card32('matrix21'),
    rq.Card32('matrix22'),
    rq.Card32('matrix23'),
    rq.Card32('matrix31'),
    rq.Card32('matrix32'),
    rq.Card32('matrix33'),
Esempio n. 26
0
class ListFontsWithInfo(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Opcode(50),
        rq.Pad(1),
        rq.RequestLength(),
        rq.Card16('max_names'),
        rq.LengthOf('pattern', 2),
        rq.String8('pattern'),
        )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.LengthOf('name', 1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Object('min_bounds', structs.CharInfo),
        rq.Pad(4),
        rq.Object('max_bounds', structs.CharInfo),
        rq.Pad(4),
        rq.Card16('min_char_or_byte2'),
        rq.Card16('max_char_or_byte2'),
        rq.Card16('default_char'),
        rq.LengthOf('properties', 2),
        rq.Card8('draw_direction'),
        rq.Card8('min_byte1'),
        rq.Card8('max_byte1'),
        rq.Card8('all_chars_exist'),
        rq.Int16('font_ascent'),
        rq.Int16('font_descent'),
        rq.Card32('replies_hint'),
        rq.List('properties', structs.FontProp),
        rq.String8('name'),
        )


    # Somebody must have smoked some really wicked weed when they
    # defined the ListFontsWithInfo request:
    # The server sends a reply for _each_ matching font...
    # It then sends a special reply (name length == 0) to indicate
    # that there are no more fonts in the reply.

    # This means that we have to do some special parsing to see if
    # we have got the end-of-reply reply.  If we haven't, we
    # have to reinsert the request in the front of the
    # display.sent_request queue to catch the next response.

    # Bastards.

    def __init__(self, *args, **keys):
        self._fonts = []
        ReplyRequest.__init__(*(self, ) + args, **keys)

    def _parse_response(self, data):

        if ord(data[1]) == 0:
            self._response_lock.acquire()
            self._data = self._fonts
            del self._fonts
            self._response_lock.release()
            return

        r, d = self._reply.parse_binary(data)
        self._fonts.append(r)

        self._display.sent_requests.insert(0, self)


    # Override the default __getattr__, since it isn't usable for
    # the list reply.  Instead provide a __getitem__ and a __len__.

    def __getattr__(self, attr):
        raise AttributeError(attr)

    def __getitem__(self, item):
        return self._data[item]

    def __len__(self):
        return len(self._data)
Esempio n. 27
0
 def setUp(self):
     self.s1 = rq.Struct(rq.LengthOf('l', 4), rq.List('l', CustomObj))
Esempio n. 28
0
        for byte in reversed(
                struct.unpack('={0:d}B'.format(mask_len), mask_data)):
            mask_value <<= 8
            mask_value |= byte
        data = data[mask_len:]
        assert (mask_value & 1) == 0
        return ButtonMask(mask_value >> 1, length), data


ButtonInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.LengthOf(('state', 'labels'), 2),
    ButtonState('state'),
    rq.List('labels', rq.Card32),
)

KeyInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.LengthOf('keycodes', 2),
    rq.List('keycodes', rq.Card32),
)

ValuatorInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.Card16('number'),
Esempio n. 29
0
        rq.Set('subwindow_mode', 1, (X.ClipByChildren, X.IncludeInferiors)),
        rq.Bool('graphics_exposures'), rq.Int16('clip_x_origin'),
        rq.Int16('clip_y_origin'), rq.Pixmap('clip_mask'),
        rq.Card16('dash_offset'), rq.Card8('dashes'),
        rq.Set('arc_mode', 1, (X.ArcChord, X.ArcPieSlice)))


TimeCoord = rq.Struct(
    rq.Card32('time'),
    rq.Int16('x'),
    rq.Int16('y'),
)

Host = rq.Struct(
    rq.Set('family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)),
    rq.Pad(1), rq.LengthOf('name', 2), rq.List('name', rq.Card8Obj))

CharInfo = rq.Struct(
    rq.Int16('left_side_bearing'),
    rq.Int16('right_side_bearing'),
    rq.Int16('character_width'),
    rq.Int16('ascent'),
    rq.Int16('descent'),
    rq.Card16('attributes'),
)

FontProp = rq.Struct(
    rq.Card32('name'),
    rq.Card32('value'),
)
Esempio n. 30
0
Record_ExtRange = rq.Struct(rq.Card8('major_range_first'),
                            rq.Card8('major_range_last'),
                            rq.Card16('minor_range_first'),
                            rq.Card16('minor_range_last'))
Record_Range = rq.Struct(rq.Object('core_requests', Record_Range8),
                         rq.Object('core_replies', Record_Range8),
                         rq.Object('ext_requests', Record_ExtRange),
                         rq.Object('ext_replies', Record_ExtRange),
                         rq.Object('delivered_events', Record_Range8),
                         rq.Object('device_events', Record_Range8),
                         rq.Object('errors', Record_Range8),
                         rq.Bool('client_started'), rq.Bool('client_died'))

Record_ClientInfo = rq.Struct(rq.Card32('client_resource'),
                              rq.LengthOf('ranges', 4),
                              rq.List('ranges', Record_Range))


class RawField(rq.ValueField):
    """A field with raw data, stored as a string"""

    structcode = None

    def pack_value(self, val):
        return val, len(val), None

    def parse_binary_value(self, data, display, length, format):
        return data, ''


class GetVersion(rq.ReplyRequest):