# Xlib.ext.res -- X-Resource extension module
#
#    Copyright (C) 2021 Aleksei Bavshin <alebastr89@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
#    Free Software Foundation, Inc.,
#    51 Franklin Street,
#    Fifth Floor,
#    Boston, MA 02110-1301 USA

"""X-Resource extension allows a client to query the X server about its usage
of various resources.

For detailed description see any of the following documents.
Protocol specification:
    https://www.x.org/releases/current/doc/resourceproto/resproto.txt
XCB Protocol specification:
    https://cgit.freedesktop.org/xcb/proto/tree/src/res.xml
"""
from Xlib.protocol import rq

RES_MAJOR_VERSION = 1
RES_MINOR_VERSION = 2

extname = "X-Resource"

# v1.0
ResQueryVersion = 0
ResQueryClients = 1
ResQueryClientResources = 2
ResQueryClientPixmapBytes = 3
# v1.2
ResQueryClientIds = 4
ResQueryResourceBytes = 5


class QueryVersion(rq.ReplyRequest):
    _request = rq.Struct(
            rq.Card8("opcode"),
            rq.Opcode(ResQueryVersion),
            rq.RequestLength(),
            rq.Card8("client_major"),
            rq.Card8("client_minor"),
            rq.Pad(2))
    _reply = rq.Struct(
            rq.ReplyCode(),
            rq.Pad(1),
            rq.Card16("sequence_number"),
            rq.ReplyLength(),
            rq.Card16("server_major"),
            rq.Card16("server_minor"),
            rq.Pad(20))


def query_version(self, client_major=RES_MAJOR_VERSION,
                  client_minor=RES_MINOR_VERSION):
    """ Query the protocol version supported by the X server.

    The client sends the highest supported version to the server and the
    server sends the highest version it supports, but no higher than the
    requested version."""
    return QueryVersion(
            display=self.display,
            opcode=self.display.get_extension_major(extname),
            client_major=client_major,
            client_minor=client_minor)


Client = rq.Struct(
        rq.Card32("resource_base"),
        rq.Card32("resource_mask"))


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))


def query_clients(self):
    """Request the list of all currently connected clients."""
    return QueryClients(
            display=self.display,
            opcode=self.display.get_extension_major(extname))


Type = rq.Struct(
        rq.Card32("resource_type"),
        rq.Card32("count"))


class QueryClientResources(rq.ReplyRequest):
    _request = rq.Struct(
            rq.Card8("opcode"),
            rq.Opcode(ResQueryClientResources),
            rq.RequestLength(),
            rq.Card32("client"))
    _reply = rq.Struct(
            rq.ReplyCode(),
            rq.Pad(1),
            rq.Card16("sequence_number"),
            rq.ReplyLength(),
            rq.LengthOf("types", 4),
            rq.Pad(20),
            rq.List("types", Type))


def query_client_resources(self, client):
    """Request the number of resources owned by a client.

    The server will return the counts of each type of resource.
    """
    return QueryClientResources(
            display=self.display,
            opcode=self.display.get_extension_major(extname),
            client=client)


class QueryClientPixmapBytes(rq.ReplyRequest):
    _request = rq.Struct(
            rq.Card8("opcode"),
            rq.Opcode(ResQueryClientPixmapBytes),
            rq.RequestLength(),
            rq.Card32("client"))
    _reply = rq.Struct(
            rq.ReplyCode(),
            rq.Pad(1),
            rq.Card16("sequence_number"),
            rq.ReplyLength(),
            rq.Card32("bytes"),
            rq.Card32("bytes_overflow"),
            rq.Pad(16))


def query_client_pixmap_bytes(self, client):
    """Query the pixmap usage of some client.

    The returned number is a sum of memory usage of each pixmap that can be
    attributed to the given client.
    """
    return QueryClientPixmapBytes(
            display=self.display,
            opcode=self.display.get_extension_major(extname),
            client=client)


class SizeOf(rq.LengthOf):
    """A SizeOf stores the size in bytes of some other Field whose size
    may vary, e.g. List
    """
    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
    identification methods to server. The server then tries to identify the
    chosen clients using the identification methods specified for each client.
    The server returns IDs for those clients that were successfully identified.
    """
    return QueryClientIds(
            display=self.display,
            opcode=self.display.get_extension_major(extname),
            specs=specs)


ResourceIdSpec = rq.Struct(
        rq.Card32("resource"),
        rq.Card32("type"))


ResourceSizeSpec = rq.Struct(
        # inline struct ResourceIdSpec to work around
        # a parser bug with nested objects
        rq.Card32("resource"),
        rq.Card32("type"),
        rq.Card32("bytes"),
        rq.Card32("ref_count"),
        rq.Card32("use_count"))


ResourceSizeValue = rq.Struct(
        rq.Object("size", ResourceSizeSpec),
        rq.LengthOf("cross_references", 4),
        rq.List("cross_references", ResourceSizeSpec))


class QueryResourceBytes(rq.ReplyRequest):
    _request = rq.Struct(
            rq.Card8("opcode"),
            rq.Opcode(ResQueryResourceBytes),
            rq.RequestLength(),
            rq.Card32("client"),
            rq.LengthOf("specs", 4),
            rq.List("specs", ResourceIdSpec))
    _reply = rq.Struct(
            rq.ReplyCode(),
            rq.Pad(1),
            rq.Card16("sequence_number"),
            rq.ReplyLength(),
            rq.LengthOf("sizes", 4),
            rq.Pad(20),
            rq.List("sizes", ResourceSizeValue))


def query_resource_bytes(self, client, specs):
    """Query the sizes of resources from X server.

    The request sends a list of specifiers that selects resources for size
    calculation. The server tries to calculate the sizes of chosen resources
    and returns an estimate for a resource only if the size could be determined
    """
    return QueryResourceBytes(
            display=self.display,
            opcode=self.display.get_extension_major(extname),
            client=client,
            specs=specs)


def init(disp, info):
    disp.extension_add_method("display", "res_query_version", query_version)
    disp.extension_add_method("display", "res_query_clients", query_clients)
    disp.extension_add_method("display", "res_query_client_resources",
                              query_client_resources)
    disp.extension_add_method("display", "res_query_client_pixmap_bytes",
                              query_client_pixmap_bytes)
    disp.extension_add_method("display", "res_query_client_ids",
                              query_client_ids)
    disp.extension_add_method("display", "res_query_resource_bytes",
                              query_resource_bytes)

[((81, 8, 81, 34), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(81, 18, 81, 33): '"""resource_base"""'}, {}), "('resource_base')", False, 'from Xlib.protocol import rq\n'), ((82, 8, 82, 34), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(82, 18, 82, 33): '"""resource_mask"""'}, {}), "('resource_mask')", False, 'from Xlib.protocol import rq\n'), ((108, 8, 108, 34), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(108, 18, 108, 33): '"""resource_type"""'}, {}), "('resource_type')", False, 'from Xlib.protocol import rq\n'), ((109, 8, 109, 26), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(109, 18, 109, 25): '"""count"""'}, {}), "('count')", False, 'from Xlib.protocol import rq\n'), ((184, 8, 184, 27), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(184, 18, 184, 26): '"""client"""'}, {}), "('client')", False, 'from Xlib.protocol import rq\n'), ((185, 8, 185, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(185, 18, 185, 24): '"""mask"""'}, {}), "('mask')", False, 'from Xlib.protocol import rq\n'), ((189, 8, 189, 39), 'Xlib.protocol.rq.Object', 'rq.Object', ({(189, 18, 189, 24): '"""spec"""', (189, 26, 189, 38): 'ClientIdSpec'}, {}), "('spec', ClientIdSpec)", False, 'from Xlib.protocol import rq\n'), ((191, 8, 191, 38), 'Xlib.protocol.rq.List', 'rq.List', ({(191, 16, 191, 23): '"""value"""', (191, 25, 191, 37): 'rq.Card32Obj'}, {}), "('value', rq.Card32Obj)", False, 'from Xlib.protocol import rq\n'), ((226, 8, 226, 29), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(226, 18, 226, 28): '"""resource"""'}, {}), "('resource')", False, 'from Xlib.protocol import rq\n'), ((227, 8, 227, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(227, 18, 227, 24): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((233, 8, 233, 29), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(233, 18, 233, 28): '"""resource"""'}, {}), "('resource')", False, 'from Xlib.protocol import rq\n'), ((234, 8, 234, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(234, 18, 234, 24): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((235, 8, 235, 26), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(235, 18, 235, 25): '"""bytes"""'}, {}), "('bytes')", False, 'from Xlib.protocol import rq\n'), ((236, 8, 236, 30), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(236, 18, 236, 29): '"""ref_count"""'}, {}), "('ref_count')", False, 'from Xlib.protocol import rq\n'), ((237, 8, 237, 30), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(237, 18, 237, 29): '"""use_count"""'}, {}), "('use_count')", False, 'from Xlib.protocol import rq\n'), ((241, 8, 241, 43), 'Xlib.protocol.rq.Object', 'rq.Object', ({(241, 18, 241, 24): '"""size"""', (241, 26, 241, 42): 'ResourceSizeSpec'}, {}), "('size', ResourceSizeSpec)", False, 'from Xlib.protocol import rq\n'), ((242, 8, 242, 42), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(242, 20, 242, 38): '"""cross_references"""', (242, 40, 242, 41): '4'}, {}), "('cross_references', 4)", False, 'from Xlib.protocol import rq\n'), ((243, 8, 243, 53), 'Xlib.protocol.rq.List', 'rq.List', ({(243, 16, 243, 34): '"""cross_references"""', (243, 36, 243, 52): 'ResourceSizeSpec'}, {}), "('cross_references', ResourceSizeSpec)", False, 'from Xlib.protocol import rq\n'), ((50, 12, 50, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(50, 21, 50, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((51, 12, 51, 38), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(51, 22, 51, 37): 'ResQueryVersion'}, {}), '(ResQueryVersion)', False, 'from Xlib.protocol import rq\n'), ((52, 12, 52, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((53, 12, 53, 36), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(53, 21, 53, 35): '"""client_major"""'}, {}), "('client_major')", False, 'from Xlib.protocol import rq\n'), ((54, 12, 54, 36), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(54, 21, 54, 35): '"""client_minor"""'}, {}), "('client_minor')", False, 'from Xlib.protocol import rq\n'), ((55, 12, 55, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(55, 19, 55, 20): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((57, 12, 57, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((58, 12, 58, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(58, 19, 58, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((59, 12, 59, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(59, 22, 59, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((60, 12, 60, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((61, 12, 61, 37), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(61, 22, 61, 36): '"""server_major"""'}, {}), "('server_major')", False, 'from Xlib.protocol import rq\n'), ((62, 12, 62, 37), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(62, 22, 62, 36): '"""server_minor"""'}, {}), "('server_minor')", False, 'from Xlib.protocol import rq\n'), ((63, 12, 63, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(63, 19, 63, 21): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((87, 12, 87, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(87, 21, 87, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((88, 12, 88, 38), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(88, 22, 88, 37): 'ResQueryClients'}, {}), '(ResQueryClients)', False, 'from Xlib.protocol import rq\n'), ((89, 12, 89, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((91, 12, 91, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((92, 12, 92, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(92, 19, 92, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((93, 12, 93, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(93, 22, 93, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((94, 12, 94, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((95, 12, 95, 37), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(95, 24, 95, 33): '"""clients"""', (95, 35, 95, 36): '4'}, {}), "('clients', 4)", False, 'from Xlib.protocol import rq\n'), ((96, 12, 96, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(96, 19, 96, 21): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((97, 12, 97, 38), 'Xlib.protocol.rq.List', 'rq.List', ({(97, 20, 97, 29): '"""clients"""', (97, 31, 97, 37): 'Client'}, {}), "('clients', Client)", False, 'from Xlib.protocol import rq\n'), ((114, 12, 114, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(114, 21, 114, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((115, 12, 115, 46), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(115, 22, 115, 45): 'ResQueryClientResources'}, {}), '(ResQueryClientResources)', False, 'from Xlib.protocol import rq\n'), ((116, 12, 116, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((117, 12, 117, 31), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(117, 22, 117, 30): '"""client"""'}, {}), "('client')", False, 'from Xlib.protocol import rq\n'), ((119, 12, 119, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((120, 12, 120, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(120, 19, 120, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((121, 12, 121, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(121, 22, 121, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((122, 12, 122, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((123, 12, 123, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(123, 24, 123, 31): '"""types"""', (123, 33, 123, 34): '4'}, {}), "('types', 4)", False, 'from Xlib.protocol import rq\n'), ((124, 12, 124, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(124, 19, 124, 21): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((125, 12, 125, 34), 'Xlib.protocol.rq.List', 'rq.List', ({(125, 20, 125, 27): '"""types"""', (125, 29, 125, 33): 'Type'}, {}), "('types', Type)", False, 'from Xlib.protocol import rq\n'), ((141, 12, 141, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(141, 21, 141, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((142, 12, 142, 48), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(142, 22, 142, 47): 'ResQueryClientPixmapBytes'}, {}), '(ResQueryClientPixmapBytes)', False, 'from Xlib.protocol import rq\n'), ((143, 12, 143, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((144, 12, 144, 31), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(144, 22, 144, 30): '"""client"""'}, {}), "('client')", False, 'from Xlib.protocol import rq\n'), ((146, 12, 146, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((147, 12, 147, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(147, 19, 147, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((148, 12, 148, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(148, 22, 148, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((149, 12, 149, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((150, 12, 150, 30), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(150, 22, 150, 29): '"""bytes"""'}, {}), "('bytes')", False, 'from Xlib.protocol import rq\n'), ((151, 12, 151, 39), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(151, 22, 151, 38): '"""bytes_overflow"""'}, {}), "('bytes_overflow')", False, 'from Xlib.protocol import rq\n'), ((152, 12, 152, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(152, 19, 152, 21): '16'}, {}), '(16)', False, 'from Xlib.protocol import rq\n'), ((172, 8, 172, 46), 'Xlib.protocol.rq.LengthOf.__init__', 'rq.LengthOf.__init__', ({(172, 29, 172, 33): 'self', (172, 35, 172, 39): 'name', (172, 41, 172, 45): 'size'}, {}), '(self, name, size)', False, 'from Xlib.protocol import rq\n'), ((196, 12, 196, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(196, 21, 196, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((197, 12, 197, 40), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(197, 22, 197, 39): 'ResQueryClientIds'}, {}), '(ResQueryClientIds)', False, 'from Xlib.protocol import rq\n'), ((198, 12, 198, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((199, 12, 199, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(199, 24, 199, 31): '"""specs"""', (199, 33, 199, 34): '4'}, {}), "('specs', 4)", False, 'from Xlib.protocol import rq\n'), ((200, 12, 200, 42), 'Xlib.protocol.rq.List', 'rq.List', ({(200, 20, 200, 27): '"""specs"""', (200, 29, 200, 41): 'ClientIdSpec'}, {}), "('specs', ClientIdSpec)", False, 'from Xlib.protocol import rq\n'), ((202, 12, 202, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((203, 12, 203, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(203, 19, 203, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((204, 12, 204, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(204, 22, 204, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((205, 12, 205, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((206, 12, 206, 33), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(206, 24, 206, 29): '"""ids"""', (206, 31, 206, 32): '4'}, {}), "('ids', 4)", False, 'from Xlib.protocol import rq\n'), ((207, 12, 207, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(207, 19, 207, 21): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((208, 12, 208, 41), 'Xlib.protocol.rq.List', 'rq.List', ({(208, 20, 208, 25): '"""ids"""', (208, 27, 208, 40): 'ClientIdValue'}, {}), "('ids', ClientIdValue)", False, 'from Xlib.protocol import rq\n'), ((248, 12, 248, 30), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(248, 21, 248, 29): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((249, 12, 249, 44), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(249, 22, 249, 43): 'ResQueryResourceBytes'}, {}), '(ResQueryResourceBytes)', False, 'from Xlib.protocol import rq\n'), ((250, 12, 250, 30), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((251, 12, 251, 31), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(251, 22, 251, 30): '"""client"""'}, {}), "('client')", False, 'from Xlib.protocol import rq\n'), ((252, 12, 252, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(252, 24, 252, 31): '"""specs"""', (252, 33, 252, 34): '4'}, {}), "('specs', 4)", False, 'from Xlib.protocol import rq\n'), ((253, 12, 253, 44), 'Xlib.protocol.rq.List', 'rq.List', ({(253, 20, 253, 27): '"""specs"""', (253, 29, 253, 43): 'ResourceIdSpec'}, {}), "('specs', ResourceIdSpec)", False, 'from Xlib.protocol import rq\n'), ((255, 12, 255, 26), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((256, 12, 256, 21), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(256, 19, 256, 20): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((257, 12, 257, 40), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(257, 22, 257, 39): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((258, 12, 258, 28), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((259, 12, 259, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(259, 24, 259, 31): '"""sizes"""', (259, 33, 259, 34): '4'}, {}), "('sizes', 4)", False, 'from Xlib.protocol import rq\n'), ((260, 12, 260, 22), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(260, 19, 260, 21): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((261, 12, 261, 47), 'Xlib.protocol.rq.List', 'rq.List', ({(261, 20, 261, 27): '"""sizes"""', (261, 29, 261, 46): 'ResourceSizeValue'}, {}), "('sizes', ResourceSizeValue)", False, 'from Xlib.protocol import rq\n')]