/usr/lib/python2.7/dist-packages/xcffib/res.py is in python-xcffib 0.5.1-1build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import xcffib
import struct
import six
MAJOR_VERSION = 1
MINOR_VERSION = 2
key = xcffib.ExtensionKey("X-Resource")
_events = {}
_errors = {}
from . import xproto
class Client(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.resource_base, self.resource_mask = unpacker.unpack("II")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=II", self.resource_base, self.resource_mask))
return buf.getvalue()
fixed_size = 8
@classmethod
def synthetic(cls, resource_base, resource_mask):
self = cls.__new__(cls)
self.resource_base = resource_base
self.resource_mask = resource_mask
return self
class Type(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.resource_type, self.count = unpacker.unpack("II")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=II", self.resource_type, self.count))
return buf.getvalue()
fixed_size = 8
@classmethod
def synthetic(cls, resource_type, count):
self = cls.__new__(cls)
self.resource_type = resource_type
self.count = count
return self
class ClientIdMask:
ClientXID = 1 << 0
LocalClientPID = 1 << 1
class ClientIdSpec(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.client, self.mask = unpacker.unpack("II")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=II", self.client, self.mask))
return buf.getvalue()
fixed_size = 8
@classmethod
def synthetic(cls, client, mask):
self = cls.__new__(cls)
self.client = client
self.mask = mask
return self
class ClientIdValue(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.spec = ClientIdSpec(unpacker)
self.length, = unpacker.unpack("I")
unpacker.pad("I")
self.value = xcffib.List(unpacker, "I", self.length)
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=I", self.length))
buf.write(self.spec.pack() if hasattr(self.spec, "pack") else ClientIdSpec.synthetic(*self.spec).pack())
buf.write(xcffib.pack_list(self.value, "I"))
return buf.getvalue()
@classmethod
def synthetic(cls, spec, length, value):
self = cls.__new__(cls)
self.spec = spec
self.length = length
self.value = value
return self
class ResourceIdSpec(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.resource, self.type = unpacker.unpack("II")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=II", self.resource, self.type))
return buf.getvalue()
fixed_size = 8
@classmethod
def synthetic(cls, resource, type):
self = cls.__new__(cls)
self.resource = resource
self.type = type
return self
class ResourceSizeSpec(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.spec = ResourceIdSpec(unpacker)
self.bytes, self.ref_count, self.use_count = unpacker.unpack("III")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=III", self.bytes, self.ref_count, self.use_count))
buf.write(self.spec.pack() if hasattr(self.spec, "pack") else ResourceIdSpec.synthetic(*self.spec).pack())
return buf.getvalue()
@classmethod
def synthetic(cls, spec, bytes, ref_count, use_count):
self = cls.__new__(cls)
self.spec = spec
self.bytes = bytes
self.ref_count = ref_count
self.use_count = use_count
return self
class ResourceSizeValue(xcffib.Struct):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Struct.__init__(self, unpacker)
base = unpacker.offset
self.size = ResourceSizeSpec(unpacker)
self.num_cross_references, = unpacker.unpack("I")
unpacker.pad(ResourceSizeSpec)
self.cross_references = xcffib.List(unpacker, ResourceSizeSpec, self.num_cross_references)
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=I", self.num_cross_references))
buf.write(self.size.pack() if hasattr(self.size, "pack") else ResourceSizeSpec.synthetic(*self.size).pack())
buf.write(xcffib.pack_list(self.cross_references, ResourceSizeSpec))
return buf.getvalue()
@classmethod
def synthetic(cls, size, num_cross_references, cross_references):
self = cls.__new__(cls)
self.size = size
self.num_cross_references = num_cross_references
self.cross_references = cross_references
return self
class QueryVersionReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.server_major, self.server_minor = unpacker.unpack("xx2x4xHH")
self.bufsize = unpacker.offset - base
class QueryVersionCookie(xcffib.Cookie):
reply_type = QueryVersionReply
class QueryClientsReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.num_clients, = unpacker.unpack("xx2x4xI20x")
self.clients = xcffib.List(unpacker, Client, self.num_clients)
self.bufsize = unpacker.offset - base
class QueryClientsCookie(xcffib.Cookie):
reply_type = QueryClientsReply
class QueryClientResourcesReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.num_types, = unpacker.unpack("xx2x4xI20x")
self.types = xcffib.List(unpacker, Type, self.num_types)
self.bufsize = unpacker.offset - base
class QueryClientResourcesCookie(xcffib.Cookie):
reply_type = QueryClientResourcesReply
class QueryClientPixmapBytesReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.bytes, self.bytes_overflow = unpacker.unpack("xx2x4xII")
self.bufsize = unpacker.offset - base
class QueryClientPixmapBytesCookie(xcffib.Cookie):
reply_type = QueryClientPixmapBytesReply
class QueryClientIdsReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.num_ids, = unpacker.unpack("xx2x4xI20x")
self.ids = xcffib.List(unpacker, ClientIdValue, self.num_ids)
self.bufsize = unpacker.offset - base
class QueryClientIdsCookie(xcffib.Cookie):
reply_type = QueryClientIdsReply
class QueryResourceBytesReply(xcffib.Reply):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Reply.__init__(self, unpacker)
base = unpacker.offset
self.num_sizes, = unpacker.unpack("xx2x4xI20x")
self.sizes = xcffib.List(unpacker, ResourceSizeValue, self.num_sizes)
self.bufsize = unpacker.offset - base
class QueryResourceBytesCookie(xcffib.Cookie):
reply_type = QueryResourceBytesReply
class resExtension(xcffib.Extension):
def QueryVersion(self, client_major, client_minor, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xBB", client_major, client_minor))
return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
def QueryClients(self, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2x"))
return self.send_request(1, buf, QueryClientsCookie, is_checked=is_checked)
def QueryClientResources(self, xid, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", xid))
return self.send_request(2, buf, QueryClientResourcesCookie, is_checked=is_checked)
def QueryClientPixmapBytes(self, xid, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", xid))
return self.send_request(3, buf, QueryClientPixmapBytesCookie, is_checked=is_checked)
def QueryClientIds(self, num_specs, specs, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", num_specs))
buf.write(xcffib.pack_list(specs, ClientIdSpec))
return self.send_request(4, buf, QueryClientIdsCookie, is_checked=is_checked)
def QueryResourceBytes(self, client, num_specs, specs, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xII", client, num_specs))
buf.write(xcffib.pack_list(specs, ResourceIdSpec))
return self.send_request(5, buf, QueryResourceBytesCookie, is_checked=is_checked)
xcffib._add_ext(key, resExtension, _events, _errors)
|