/usr/lib/python3/dist-packages/xcffib/screensaver.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 | import xcffib
import struct
import six
MAJOR_VERSION = 1
MINOR_VERSION = 1
key = xcffib.ExtensionKey("MIT-SCREEN-SAVER")
_events = {}
_errors = {}
from . import xproto
class Kind:
Blanked = 0
Internal = 1
External = 2
class Event:
NotifyMask = 1 << 0
CycleMask = 1 << 1
class State:
Off = 0
On = 1
Cycle = 2
Disabled = 3
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_version, self.server_minor_version = unpacker.unpack("xx2x4xHH20x")
self.bufsize = unpacker.offset - base
class QueryVersionCookie(xcffib.Cookie):
reply_type = QueryVersionReply
class QueryInfoReply(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.state, self.saver_window, self.ms_until_server, self.ms_since_user_input, self.event_mask, self.kind = unpacker.unpack("xB2x4xIIIIB7x")
self.bufsize = unpacker.offset - base
class QueryInfoCookie(xcffib.Cookie):
reply_type = QueryInfoReply
class NotifyEvent(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.state, self.time, self.root, self.window, self.kind, self.forced = unpacker.unpack("xB2xIIIBB14x")
self.bufsize = unpacker.offset - base
def pack(self):
buf = six.BytesIO()
buf.write(struct.pack("=B", 0))
buf.write(struct.pack("=B2xIIIBB14x", self.state, self.time, self.root, self.window, self.kind, self.forced))
buf_len = len(buf.getvalue())
if buf_len < 32:
buf.write(struct.pack("x" * (32 - buf_len)))
return buf.getvalue()
@classmethod
def synthetic(cls, state, time, root, window, kind, forced):
self = cls.__new__(cls)
self.state = state
self.time = time
self.root = root
self.window = window
self.kind = kind
self.forced = forced
return self
_events[0] = NotifyEvent
class screensaverExtension(xcffib.Extension):
def QueryVersion(self, client_major_version, client_minor_version, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xBB2x", client_major_version, client_minor_version))
return self.send_request(0, buf, QueryVersionCookie, is_checked=is_checked)
def QueryInfo(self, drawable, is_checked=True):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", drawable))
return self.send_request(1, buf, QueryInfoCookie, is_checked=is_checked)
def SelectInput(self, drawable, event_mask, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xII", drawable, event_mask))
return self.send_request(2, buf, is_checked=is_checked)
def SetAttributes(self, drawable, x, y, width, height, border_width, _class, depth, visual, value_mask, value_list, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xIhhHHHBBII", drawable, x, y, width, height, border_width, _class, depth, visual, value_mask))
if value_mask & CW.BackPixmap:
background_pixmap = value_list.pop(0)
buf.write(struct.pack("=I", background_pixmap))
if value_mask & CW.BackPixel:
background_pixel = value_list.pop(0)
buf.write(struct.pack("=I", background_pixel))
if value_mask & CW.BorderPixmap:
border_pixmap = value_list.pop(0)
buf.write(struct.pack("=I", border_pixmap))
if value_mask & CW.BorderPixel:
border_pixel = value_list.pop(0)
buf.write(struct.pack("=I", border_pixel))
if value_mask & CW.BitGravity:
bit_gravity = value_list.pop(0)
buf.write(struct.pack("=I", bit_gravity))
if value_mask & CW.WinGravity:
win_gravity = value_list.pop(0)
buf.write(struct.pack("=I", win_gravity))
if value_mask & CW.BackingStore:
backing_store = value_list.pop(0)
buf.write(struct.pack("=I", backing_store))
if value_mask & CW.BackingPlanes:
backing_planes = value_list.pop(0)
buf.write(struct.pack("=I", backing_planes))
if value_mask & CW.BackingPixel:
backing_pixel = value_list.pop(0)
buf.write(struct.pack("=I", backing_pixel))
if value_mask & CW.OverrideRedirect:
override_redirect = value_list.pop(0)
buf.write(struct.pack("=I", override_redirect))
if value_mask & CW.SaveUnder:
save_under = value_list.pop(0)
buf.write(struct.pack("=I", save_under))
if value_mask & CW.EventMask:
event_mask = value_list.pop(0)
buf.write(struct.pack("=I", event_mask))
if value_mask & CW.DontPropagate:
do_not_propogate_mask = value_list.pop(0)
buf.write(struct.pack("=I", do_not_propogate_mask))
if value_mask & CW.Colormap:
colormap = value_list.pop(0)
buf.write(struct.pack("=I", colormap))
if value_mask & CW.Cursor:
cursor = value_list.pop(0)
buf.write(struct.pack("=I", cursor))
return self.send_request(3, buf, is_checked=is_checked)
def UnsetAttributes(self, drawable, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xI", drawable))
return self.send_request(4, buf, is_checked=is_checked)
def Suspend(self, suspend, is_checked=False):
buf = six.BytesIO()
buf.write(struct.pack("=xx2xB3x", suspend))
return self.send_request(5, buf, is_checked=is_checked)
xcffib._add_ext(key, screensaverExtension, _events, _errors)
|