/usr/lib/python2.7/dist-packages/xcffib/shm.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 | import xcffib
import struct
import six
MAJOR_VERSION = 1
MINOR_VERSION = 2
key = xcffib.ExtensionKey("MIT-SHM")
_events = {}
_errors = {}
from . import xproto
class CompletionEvent(xcffib.Event):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Event.__init__(self, unpacker)
base = unpacker.offset
self.drawable, self.minor_event, self.major_event, self.shmseg, self.offset = unpacker.unpack("xx2xIHBxII")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 0))
buf.write(struct.pack("=x2xIHBxII", self.drawable, self.minor_event, self.major_event, self.shmseg, self.offset))
buf_len = len(buf.getvalue())
if buf_len < 32:
buf.write(struct.pack("x" * (32 - buf_len)))
return buf.getvalue()
@classmethod
def synthetic(cls, drawable, minor_event, major_event, shmseg, offset):
self = cls.__new__(cls)
self.drawable = drawable
self.minor_event = minor_event
self.major_event = major_event
self.shmseg = shmseg
self.offset = offset
return self
_events[0] = CompletionEvent
class BadSegError(xcffib.Error):
def __init__(self, unpacker):
if isinstance(unpacker, xcffib.Protobj):
unpacker = xcffib.MemoryUnpacker(unpacker.pack())
xcffib.Error.__init__(self, unpacker)
base = unpacker.offset
self.bad_value, self.minor_opcode, self.major_opcode = unpacker.unpack("xx2xIHBx")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 0))
buf.write(struct.pack("=x2xIHBx", self.bad_value, self.minor_opcode, self.major_opcode))
return buf.getvalue()
BadBadSeg = BadSegError
_errors[0] = BadSegError
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.shared_pixmaps, self.major_version, self.minor_version, self.uid, self.gid, self.pixmap_format = unpacker.unpack("xB2x4xHHHHB15x")
self.bufsize = unpacker.offset - base
class QueryVersionCookie(xcffib.Cookie):
reply_type = QueryVersionReply
class GetImageReply(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.depth, self.visual, self.size = unpacker.unpack("xB2x4xII")
self.bufsize = unpacker.offset - base
class GetImageCookie(xcffib.Cookie):
reply_type = GetImageReply
class CreateSegmentReply(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.nfd, = unpacker.unpack("xB2x4x24x")
self.bufsize = unpacker.offset - base
class CreateSegmentCookie(xcffib.Cookie):
reply_type = CreateSegmentReply
class shmExtension(xcffib.Extension):
def QueryVersion(self, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2x"))
return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
def Attach(self, shmseg, shmid, read_only, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIB3x", shmseg, shmid, read_only))
return self.send_request(1, buf, is_checked=is_checked)
def Detach(self, shmseg, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", shmseg))
return self.send_request(2, buf, is_checked=is_checked)
def PutImage(self, drawable, gc, total_width, total_height, src_x, src_y, src_width, src_height, dst_x, dst_y, depth, format, send_event, shmseg, offset, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHHHHHhhBBBxII", drawable, gc, total_width, total_height, src_x, src_y, src_width, src_height, dst_x, dst_y, depth, format, send_event, shmseg, offset))
return self.send_request(3, buf, is_checked=is_checked)
def GetImage(self, drawable, x, y, width, height, plane_mask, format, shmseg, offset, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIhhHHIB3xII", drawable, x, y, width, height, plane_mask, format, shmseg, offset))
return self.send_request(4, buf, GetImageCookie, is_checked=is_checked)
def CreatePixmap(self, pid, drawable, width, height, depth, shmseg, offset, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIHHB3xII", pid, drawable, width, height, depth, shmseg, offset))
return self.send_request(5, buf, is_checked=is_checked)
def AttachFd(self, shmseg, read_only, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIB3x", shmseg, read_only))
return self.send_request(6, buf, is_checked=is_checked)
def CreateSegment(self, shmseg, size, read_only, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIIB3x", shmseg, size, read_only))
return self.send_request(7, buf, CreateSegmentCookie, is_checked=is_checked)
xcffib._add_ext(key, shmExtension, _events, _errors)
|