/usr/lib/python3/dist-packages/Xlib/ext/record.py is in python3-xlib 0.20-3.
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 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | # Xlib.ext.record -- RECORD extension module
#
# Copyright (C) 2006 Alex Badea <vamposdecampos@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.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
from Xlib import X
from Xlib.protocol import rq
extname = 'RECORD'
FromServerTime = 0x01
FromClientTime = 0x02
FromClientSequence = 0x04
CurrentClients = 1
FutureClients = 2
AllClients = 3
FromServer = 0
FromClient = 1
ClientStarted = 2
ClientDied = 3
StartOfData = 4
EndOfData = 5
Record_Range8 = rq.Struct(
rq.Card8('first'),
rq.Card8('last'))
Record_Range16 = rq.Struct(
rq.Card16('first'),
rq.Card16('last'))
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):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(0),
rq.RequestLength(),
rq.Card16('major_version'),
rq.Card16('minor_version'))
_reply = rq.Struct(
rq.Pad(2),
rq.Card16('sequence_number'),
rq.ReplyLength(),
rq.Card16('major_version'),
rq.Card16('minor_version'),
rq.Pad(20))
def get_version(self, major, minor):
return GetVersion(
display = self.display,
opcode = self.display.get_extension_major(extname),
major_version = major,
minor_version = minor)
class CreateContext(rq.Request):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(1),
rq.RequestLength(),
rq.Card32('context'), # Record_RC
rq.Card8('element_header'), # Record_Element_Header
rq.Pad(3),
rq.LengthOf('clients', 4),
rq.LengthOf('ranges', 4),
rq.List('clients', rq.Card32Obj),
rq.List('ranges', Record_Range))
def create_context(self, datum_flags, clients, ranges):
context = self.display.allocate_resource_id()
CreateContext(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context,
element_header = datum_flags,
clients = clients,
ranges = ranges)
return context
class RegisterClients(rq.Request):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(2),
rq.RequestLength(),
rq.Card32('context'), # Record_RC
rq.Card8('element_header'), # Record_Element_Header
rq.Pad(3),
rq.LengthOf('clients', 4),
rq.LengthOf('ranges', 4),
rq.List('clients', rq.Card32Obj),
rq.List('ranges', Record_Range))
def register_clients(self, context, element_header, clients, ranges):
RegisterClients(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context,
element_header = element_header,
clients = clients,
ranges = ranges)
class UnregisterClients(rq.Request):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(3),
rq.RequestLength(),
rq.Card32('context'), # Record_RC
rq.LengthOf('clients', 4),
rq.List('clients', rq.Card32Obj))
def unregister_clients(self, context, clients):
UnregisterClients(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context,
clients = clients)
class GetContext(rq.ReplyRequest):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(4),
rq.RequestLength(),
rq.Card32('context')) # Record_RC
_reply = rq.Struct(
rq.Pad(2),
rq.Card16('sequence_number'),
rq.ReplyLength(),
rq.Card8('element_header'), # Record_Element_Header
rq.Pad(3),
rq.LengthOf('client_info', 4),
rq.Pad(16),
rq.List('client_info', Record_ClientInfo))
def get_context(self, context):
return GetContext(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context)
class EnableContext(rq.ReplyRequest):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(5),
rq.RequestLength(),
rq.Card32('context')) # Record_RC
_reply = rq.Struct(
rq.Pad(1),
rq.Card8('category'),
rq.Card16('sequence_number'),
rq.ReplyLength(),
rq.Card8('element_header'), # Record_Element_Header
rq.Bool('client_swapped'),
rq.Pad(2),
rq.Card32('id_base'), # Record_XIDBase
rq.Card32('server_time'),
rq.Card32('recorded_sequence_number'),
rq.Pad(8),
RawField('data'))
# This request receives multiple responses, so we need to keep
# ourselves in the 'sent_requests' list in order to receive them all.
# See the discussion on ListFonstsWithInfo in request.py
def __init__(self, callback, *args, **keys):
self._callback = callback
rq.ReplyRequest.__init__(self, *args, **keys)
def _parse_response(self, data):
r, d = self._reply.parse_binary(data, self._display)
self._callback(r)
if r.category == StartOfData:
# Hack ourselves a sequence number, used by the code in
# Xlib.protocol.display.Display.parse_request_response()
self.sequence_number = r.sequence_number
if r.category == EndOfData:
self._response_lock.acquire()
self._data = r
self._response_lock.release()
else:
self._display.sent_requests.insert(0, self)
def enable_context(self, context, callback):
EnableContext(
callback = callback,
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context)
class DisableContext(rq.Request):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(6),
rq.RequestLength(),
rq.Card32('context')) # Record_RC
def disable_context(self, context):
DisableContext(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context)
class FreeContext(rq.Request):
_request = rq.Struct(
rq.Card8('opcode'),
rq.Opcode(7),
rq.RequestLength(),
rq.Card32('context')) # Record_RC
def free_context(self, context):
FreeContext(
display = self.display,
opcode = self.display.get_extension_major(extname),
context = context)
self.display.free_resource_id(context)
def init(disp, info):
disp.extension_add_method('display', 'record_get_version', get_version)
disp.extension_add_method('display', 'record_create_context', create_context)
disp.extension_add_method('display', 'record_register_clients', register_clients)
disp.extension_add_method('display', 'record_unregister_clients', unregister_clients)
disp.extension_add_method('display', 'record_get_context', get_context)
disp.extension_add_method('display', 'record_enable_context', enable_context)
disp.extension_add_method('display', 'record_disable_context', disable_context)
disp.extension_add_method('display', 'record_free_context', free_context)
|