/usr/lib/python3/dist-packages/xcffib/present.py is in python3-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 | import xcffib
import struct
import six
MAJOR_VERSION = 1
MINOR_VERSION = 0
key = xcffib.ExtensionKey("Present")
_events = {}
_errors = {}
from . import xproto
from . import randr
from . import xfixes
from . import sync
class Event:
ConfigureNotify = 0
CompleteNotify = 1
IdleNotify = 2
RedirectNotify = 3
class EventMask:
NoEvent = 0
ConfigureNotify = 1 << 0
CompleteNotify = 1 << 1
IdleNotify = 1 << 2
RedirectNotify = 1 << 3
class Option:
_None = 0
Async = 1 << 0
Copy = 1 << 1
UST = 1 << 2
class Capability:
_None = 0
Async = 1 << 0
Fence = 1 << 1
UST = 1 << 2
class CompleteKind:
Pixmap = 0
NotifyMSC = 1
class CompleteMode:
Copy = 0
Flip = 1
Skip = 2
class Notify(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.window, self.serial = unpacker.unpack("II")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=II", self.window, self.serial))
return buf.getvalue()
fixed_size = 8
@classmethod
def synthetic(cls, window, serial):
self = cls.__new__(cls)
self.window = window
self.serial = serial
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.major_version, self.minor_version = unpacker.unpack("xx2x4xII")
self.bufsize = unpacker.offset - base
class QueryVersionCookie(xcffib.Cookie):
reply_type = QueryVersionReply
class QueryCapabilitiesReply(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.capabilities, = unpacker.unpack("xx2x4xI")
self.bufsize = unpacker.offset - base
class QueryCapabilitiesCookie(xcffib.Cookie):
reply_type = QueryCapabilitiesReply
class GenericEvent(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.extension, self.length, self.evtype, self.event = unpacker.unpack("xB2xIH2xI")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 0))
buf.write(struct.pack("=B2xIH2xI", self.extension, self.length, self.evtype, self.event))
buf_len = len(buf.getvalue())
if buf_len < 32:
buf.write(struct.pack("x" * (32 - buf_len)))
return buf.getvalue()
@classmethod
def synthetic(cls, extension, length, evtype, event):
self = cls.__new__(cls)
self.extension = extension
self.length = length
self.evtype = evtype
self.event = event
return self
_events[0] = GenericEvent
class ConfigureNotifyEvent(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.event, self.window, self.x, self.y, self.width, self.height, self.off_x, self.off_y, self.pixmap_width, self.pixmap_height, self.pixmap_flags = unpacker.unpack("xx2x2xIIhhHHhhHHI")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 0))
buf.write(struct.pack("=x2x2xIIhhHHhhHHI", self.event, self.window, self.x, self.y, self.width, self.height, self.off_x, self.off_y, self.pixmap_width, self.pixmap_height, self.pixmap_flags))
buf_len = len(buf.getvalue())
if buf_len < 32:
buf.write(struct.pack("x" * (32 - buf_len)))
return buf.getvalue()
@classmethod
def synthetic(cls, event, window, x, y, width, height, off_x, off_y, pixmap_width, pixmap_height, pixmap_flags):
self = cls.__new__(cls)
self.event = event
self.window = window
self.x = x
self.y = y
self.width = width
self.height = height
self.off_x = off_x
self.off_y = off_y
self.pixmap_width = pixmap_width
self.pixmap_height = pixmap_height
self.pixmap_flags = pixmap_flags
return self
_events[0] = ConfigureNotifyEvent
class IdleNotifyEvent(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.event, self.window, self.serial, self.pixmap, self.idle_fence = unpacker.unpack("xx2x2xIIIII")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 2))
buf.write(struct.pack("=x2x2xIIIII", self.event, self.window, self.serial, self.pixmap, self.idle_fence))
buf_len = len(buf.getvalue())
if buf_len < 32:
buf.write(struct.pack("x" * (32 - buf_len)))
return buf.getvalue()
@classmethod
def synthetic(cls, event, window, serial, pixmap, idle_fence):
self = cls.__new__(cls)
self.event = event
self.window = window
self.serial = serial
self.pixmap = pixmap
self.idle_fence = idle_fence
return self
_events[2] = IdleNotifyEvent
class presentExtension(xcffib.Extension):
def QueryVersion(self, major_version, minor_version, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xII", major_version, minor_version))
return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
def SelectInput(self, eid, window, event_mask, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIII", eid, window, event_mask))
return self.send_request(3, buf, is_checked=is_checked)
def QueryCapabilities(self, target, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", target))
return self.send_request(4, buf, QueryCapabilitiesCookie, is_checked=is_checked)
xcffib._add_ext(key, presentExtension, _events, _errors)
|