python-xlib-0.14+20091101/0000755000175000017500000000000011274546224013341 5ustar stewstewpython-xlib-0.14+20091101/TODO0000644000175000017500000000323407436415543014037 0ustar stewstew *** To be a real C Xlib replacement * High-level functions: currently, there are mostly methods which directly correspond to X requests. There should be some simpler functions (e.g. Window.resize_window() in addition to Window.configure(), Drawable.rectangle() in addition to Drawable.poly_rectangle(), etc), and possibly also compound functions (e.g. create_pixmap_from_image() which would load an image file and create a pixmap of it). * Events: advanced event queue handling, e.g. filtering out events, only process events for a certain window, etc. * Extensions: as many extensions as possible should be implemented. *** Miscellaneous * Faster, faster! The protocol engine isn't very fast, despite the optimizations in version 0.7. I've started on this, but it is a big job. * The tread support and the protocol engine needs to be stress tested. They _seem_ to work, but that's no guarantee. * Much more documentation. * Test suite: a test suite which exercises the entire library would definitely be a nice thing to have. A start has been made for this, testing the protocol definitions. * Porting: the library should be runnable wherever there is a Python interpreter (with the necessary IPC support, that is.) * Widget set: a Python-optimized widget set using the X library would be really cute. The AnyGUI project could be a good front-end to use. * Server-side support: while we're at it, why not extend the library to provide at least the server-side parsing of the X protocol? It could be usable for writing X proxies, or for that matter, a complete X server in Python (this might be a little too spaced-out, though...) python-xlib-0.14+20091101/utils/0000755000175000017500000000000011273361453014477 5ustar stewstewpython-xlib-0.14+20091101/utils/parsexbug.py0000644000175000017500000001603210633003257017045 0ustar stewstew#!/usr/bin/python import sys import os import pprint import struct # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) def dummy_buffer(str, x, y = sys.maxint): return str[x:y] __builtins__.buffer = dummy_buffer from Xlib.protocol import display, request, rq, event from Xlib import error # We don't want any fancy dictwrapper, just plain mappings rq.DictWrapper = lambda x: x class BugFile: def __init__(self, file): self.file = file self.cbuf = self.sbuf = '' def read_client(self, bytes): while len(self.cbuf) < bytes and self.file: self.read_next() d = self.cbuf[:bytes] self.cbuf = self.cbuf[bytes:] return d def read_server(self, bytes): while len(self.sbuf) < bytes and self.file: self.read_next() d = self.sbuf[:bytes] self.sbuf = self.sbuf[bytes:] return d def read_next(self): line = self.file.readline() if line == '': self.file = None return src = line[0] length = int(line[1:-1]) data = self.file.read(length) if src == 'C': self.cbuf = self.cbuf + data elif src == 'S': self.sbuf = self.sbuf + data else: raise ValueError('Bad control line: %s' % line) class ParseString: def __init__(self, datafunc): self.get_data = datafunc self.data = '' def __getitem__(self, i): if i < 0: raise ValueError('bad string index: %d' % i) if len(self.data) <= i: if not self.get_data: raise RuntimeError('attempt to allocate more data after returning a new ParseString') self.data = self.data + self.get_data(i - len(self.data) + 1) return self.data[i] def __getslice__(self, i, j): if j == sys.maxint: if self.get_data: ps = ParseString(self.get_data) self.get_data = None return ps else: raise RuntimeError('attempt to allocate another ParseString') if i < 0 or j < 0 or i > j: raise ValueError('bad slice indices: [%d:%d]' % (i, j)) if len(self.data) < j: if not self.get_data: raise RuntimeError('attempt to allocate more data after returning a new ParseString') self.data = self.data + self.get_data(j - len(self.data)) return self.data[i:j] class DummyDisplay: def get_resource_class(self, name): return None class ParseXbug: def __init__(self, infile = sys.stdin, outfile = sys.stdout): bf = BugFile(infile) self.cdata = ParseString(bf.read_client) sdata = ParseString(bf.read_server) self.outfile = outfile self.xpprint = pprint.PrettyPrinter(indent = 2, stream = outfile) self.disp = DummyDisplay() # Parse client setup request r, self.cdata = display.ConnectionSetupRequest._request.parse_binary(self.cdata, self.disp) self.print_xbug('request', 'ConnectionSetup', r) # Parse server reply r, sdata = display.ConnectionSetupRequest._reply.parse_binary(sdata, self.disp) extra = r['additional_length'] * 4 del r['additional_length'] extradata = sdata[:extra] sdata = sdata[extra:] if r['status'] == 0: r['reason'] = extradata[:r['reason_length']] del r['status'] del r['reason_length'] self.print_xbug('error', 'ConnectionSetup', r) return elif r['status'] == 1: r2, d = display.ConnectionSetupRequest._success_reply.parse_binary(extradata, self.disp) del r['status'] del r['reason_length'] r.update(r2) del r2 self.print_xbug('reply', 'ConnectionSetup', r) else: raise ValueError('bad connection setup reply status: %d' % r['status']) self.last_serial = 0 self.last_request = None while 1: # Get next server item, always at least 32 bytes d = sdata[:32] if len(d) != 32: # Print out remaining requests try: self.get_requests(sys.maxint) except ValueError: pass return sdata = sdata[32:] # Check type t = ord(d[0]) # Error if t == 0: # Code is second byte code = ord(d[1]) # Fetch error class estruct = error.xerror_class.get(code, error.XError) r, d = estruct._fields.parse_binary(d, self.disp) del r['type'] self.get_requests(r['sequence_number']) self.print_xbug('error', estruct.__name__, r) # Reply elif t == 1: # Get sequence number, and read corresponding request sno = struct.unpack('=H', d[2:4])[0] self.get_requests(sno) # Get entire reply length rlen = int(struct.unpack('=L', d[4:8])[0]) * 4 d = d + sdata[:rlen] sdata = sdata[rlen:] if self.last_request: r, d = self.last_request._reply.parse_binary(d, self.disp) self.print_xbug('reply', self.last_request.__name__, r) else: self.print_xbug('reply', 'Unknown', { 'sequence_number': sno }) # Some event else: estruct = event.event_class.get(t, event.AnyEvent) r, d = estruct._fields.parse_binary(d, self.disp) self.get_requests(r['sequence_number']) self.print_xbug('event', estruct.__name__, r) def get_requests(self, serial): # Get request length while self.last_serial < serial: d = self.cdata[2:4] if len(d) != 2: raise ValueError('client request missing') rlen = struct.unpack('=H', d)[0] * 4 d = self.cdata[:rlen] if len(d) != rlen: raise ValueError('client request missing') self.cdata = self.cdata[rlen:] opcode = ord(d[0]) self.last_request = request.major_codes.get(opcode) self.last_serial = self.last_serial + 1 if self.last_request: r, d = self.last_request._request.parse_binary(d, self.disp) r['sequence_number'] = self.last_serial self.print_xbug('request', self.last_request.__name__, r) else: self.print_xbug('request', 'Unknown (%d)' % opcode, { 'sequence_number': self.last_serial }) def print_xbug(self, rtype, name, data): self.outfile.write('%-8s %s\n' % (rtype + ':', name)) self.xpprint.pprint(data) self.outfile.write('\n') if __name__ == '__main__': ParseXbug() python-xlib-0.14+20091101/utils/tcpbug.py0000755000175000017500000000430210633003257016331 0ustar stewstew#!/usr/bin/python import socket import select import sys import os def tcpbug(listenaddr, destaddr, outputfd): listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) listen.bind(listenaddr) listen.listen(1) client, addr = listen.accept() server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.connect(destaddr) cwbuf = swbuf = outbuf = '' while client or server or outbuf: readset = [] if client: readset.append(client) if server: readset.append(server) writeset = [] if cwbuf and client: writeset.append(client) if swbuf and server: writeset.append(server) if outbuf: writeset.append(outputfd) readset, writeset, e = select.select(readset, writeset, []) if client in readset: data = client.recv(2000) if data: swbuf = swbuf + data outbuf = outbuf + 'C%d\n%s' % (len(data), data) else: client = None if server in readset: data = server.recv(2000) if data: cwbuf = cwbuf + data outbuf = outbuf + 'S%d\n%s' % (len(data), data) else: server = None if client in writeset: n = client.send(cwbuf) cwbuf = cwbuf[n:] if server in writeset: n = server.send(swbuf) swbuf = swbuf[n:] if outputfd in writeset: n = os.write(outputfd, outbuf) outbuf = outbuf[n:] if client and not cwbuf and not server: client.close() client = None if server and not swbuf and not client: server.close() server = None def main(): try: lport = int(sys.argv[1]) dhost = sys.argv[2] dport = int(sys.argv[3]) except (IndexError, ValueError): sys.stderr.write('Usage: %s listenport desthost destport\n' % sys.argv[0]) exit(1) tcpbug(('', lport), (dhost, dport), 1) if __name__ == '__main__': main() python-xlib-0.14+20091101/test/0000755000175000017500000000000011273361453014316 5ustar stewstewpython-xlib-0.14+20091101/test/test_events_le.py0000755000175000017500000007033110633003257017714 0ustar stewstew#!/usr/bin/env python import sys, os sys.path.insert(1, os.path.join(sys.path[0], '..')) import string import unittest from Xlib.protocol import request, rq, event import Xlib.protocol.event import struct import array class CmpArray: def __init__(self, *args, **kws): self.array = apply(array.array, args, kws) def __len__(self): return len(self.array) def __getslice__(self, x, y): return list(self.array[x:y]) def __getattr__(self, attr): return getattr(self.array, attr) def __cmp__(self, other): return cmp(self.array.tolist(), other) rq.array = CmpArray def tohex(bin): bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '') bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("'%s'" % bins[i]) return string.join(bins2, ' \\\n ') class DummyDisplay: def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() def check_endian(): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: sys.stderr.write('Little-endian tests, skipping on this system.\n') sys.exit(0) class TestKeymapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'type': 173, 'data': [130, 181, 177, 244, 167, 144, 216, 185, 228, 220, 254, 130, 239, 213, 142, 240, 233, 248, 161, 238, 160, 205, 212, 205, 166, 156, 241, 169, 198, 147, 144], } self.evt_bin_0 = '\xad\x82\xb5\xb1' '\xf4\xa7\x90\xd8' \ '\xb9\xe4\xdc\xfe' '\x82\xef\xd5\x8e' \ '\xf0\xe9\xf8\xa1' '\xee\xa0\xcd\xd4' \ '\xcd\xa6\x9c\xf1' '\xa9\xc6\x93\x90' def testPack0(self): bin = apply(event.KeymapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'count': 31063, 'width': 57024, 'window': 1993119152, 'y': 29154, 'x': 15652, 'type': 192, 'sequence_number': 45668, 'height': 29709, } self.evt_bin_0 = '\xc0\x00\x64\xb2' '\xb0\x95\xcc\x76' \ '\x24\x3d\xe2\x71' '\xc0\xde\x0d\x74' \ '\x57\x79\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.Expose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestGraphicsExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'count': 7002, 'width': 21650, 'major_event': 238, 'minor_event': 44368, 'y': 2412, 'x': 50041, 'drawable': 950531249, 'type': 138, 'sequence_number': 9516, 'height': 10465, } self.evt_bin_0 = '\x8a\x00\x2c\x25' '\xb1\xf4\xa7\x38' \ '\x79\xc3\x6c\x09' '\x92\x54\xe1\x28' \ '\x50\xad\x5a\x1b' '\xee\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.GraphicsExpose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestNoExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'minor_event': 49058, 'window': 1389793826, 'type': 198, 'major_event': 149, 'sequence_number': 51301, } self.evt_bin_0 = '\xc6\x00\x65\xc8' '\x22\x92\xd6\x52' \ '\xa2\xbf\x95\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.NoExpose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestVisibilityNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 848538738, 'type': 233, 'state': 239, 'sequence_number': 38248, } self.evt_bin_0 = '\xe9\x00\x68\x95' '\x72\xac\x93\x32' \ '\xef\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.VisibilityNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestCreateNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'width': 24559, 'window': 1328254552, 'parent': 112487253, 'override': 0, 'y': -31372, 'x': -13676, 'border_width': 32812, 'type': 230, 'sequence_number': 14268, 'height': 8803, } self.evt_bin_0 = '\xe6\x00\xbc\x37' '\x55\x6b\xb4\x06' \ '\x58\x8e\x2b\x4f' '\x94\xca\x74\x85' \ '\xef\x5f\x63\x22' '\x2c\x80\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.CreateNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestDestroyNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1384567865, 'type': 183, 'event': 1596763581, 'sequence_number': 37839, } self.evt_bin_0 = '\xb7\x00\xcf\x93' '\xbd\xad\x2c\x5f' \ '\x39\xd4\x86\x52' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.DestroyNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestUnmapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1267184116, 'type': 192, 'event': 913541146, 'sequence_number': 55135, 'from_configure': 0, } self.evt_bin_0 = '\xc0\x00\x5f\xd7' '\x1a\x88\x73\x36' \ '\xf4\xb1\x87\x4b' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.UnmapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestMapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'override': 0, 'window': 2002432488, 'type': 216, 'event': 1566597012, 'sequence_number': 8920, } self.evt_bin_0 = '\xd8\x00\xd8\x22' '\x94\x5f\x60\x5d' \ '\xe8\xb1\x5a\x77' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestMapRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1740270413, 'type': 242, 'parent': 1188866605, 'sequence_number': 6729, } self.evt_bin_0 = '\xf2\x00\x49\x1a' '\x2d\xaa\xdc\x46' \ '\x4d\x6b\xba\x67' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MapRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestReparentNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'override': 0, 'window': 918878719, 'parent': 1046822430, 'y': -10755, 'x': -11814, 'type': 185, 'event': 1344092894, 'sequence_number': 31034, } self.evt_bin_0 = '\xb9\x00\x3a\x79' '\xde\x3a\x1d\x50' \ '\xff\xf9\xc4\x36' '\x1e\x3e\x65\x3e' \ '\xda\xd1\xfd\xd5' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ReparentNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestConfigureNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'y': -32583, 'above_sibling': 1143940649, 'height': 44365, 'width': 24191, 'window': 1699527401, 'override': 1, 'x': -23713, 'border_width': 51797, 'type': 191, 'event': 2102634753, 'sequence_number': 21818, } self.evt_bin_0 = '\xbf\x00\x3a\x55' '\x01\xa9\x53\x7d' \ '\xe9\xba\x4c\x65' '\x29\x26\x2f\x44' \ '\x5f\xa3\xb9\x80' '\x7f\x5e\x4d\xad' \ '\x55\xca\x01\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ConfigureNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestConfigureRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'parent': 1484835068, 'width': 46666, 'value_mask': 41755, 'stack_mode': 155, 'height': 27280, 'sibling': 1153557246, 'window': 549283037, 'y': -1019, 'x': -11524, 'border_width': 41299, 'type': 140, 'sequence_number': 48820, } self.evt_bin_0 = '\x8c\x9b\xb4\xbe' '\xfc\xc8\x80\x58' \ '\xdd\x64\xbd\x20' '\xfe\xe2\xc1\x44' \ '\xfc\xd2\x05\xfc' '\x4a\xb6\x90\x6a' \ '\x53\xa1\x1b\xa3' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ConfigureRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestGravityNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1471159096, 'y': -26841, 'x': -10882, 'type': 191, 'event': 860169186, 'sequence_number': 48472, } self.evt_bin_0 = '\xbf\x00\x58\xbd' '\xe2\x23\x45\x33' \ '\x38\x1b\xb0\x57' '\x7e\xd5\x27\x97' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.GravityNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestResizeRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'width': 8842, 'window': 995086195, 'type': 139, 'sequence_number': 9443, 'height': 58942, } self.evt_bin_0 = '\x8b\x00\xe3\x24' '\x73\xcf\x4f\x3b' \ '\x8a\x22\x3e\xe6' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ResizeRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestPropertyNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1763395006, 'time': 936540618, 'atom': 47197280, 'type': 205, 'state': 241, 'sequence_number': 47586, } self.evt_bin_0 = '\xcd\x00\xe2\xb9' '\xbe\x45\x1b\x69' \ '\x60\x2c\xd0\x02' '\xca\x79\xd2\x37' \ '\xf1\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.PropertyNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionClear(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 336291153, 'atom': 256452607, 'type': 232, 'sequence_number': 26660, 'time': 1732839301, } self.evt_bin_0 = '\xe8\x00\x24\x68' '\x85\x07\x49\x67' \ '\x51\x65\x0b\x14' '\xff\x27\x49\x0f' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionClear._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'requestor': 264947265, 'selection': 1535909824, 'target': 607705863, 'time': 1423586793, 'owner': 764886771, 'property': 1148098854, 'type': 147, 'sequence_number': 20571, } self.evt_bin_0 = '\x93\x00\x5b\x50' '\xe9\x35\xda\x54' \ '\xf3\x3e\x97\x2d' '\x41\xc6\xca\x0f' \ '\xc0\x1f\x8c\x5b' '\x07\xdb\x38\x24' \ '\x26\x99\x6e\x44' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'requestor': 971528625, 'selection': 327380230, 'target': 1874329297, 'time': 1022248107, 'property': 1791820478, 'type': 133, 'sequence_number': 30741, } self.evt_bin_0 = '\x85\x00\x15\x78' '\xab\x44\xee\x3c' \ '\xb1\x59\xe8\x39' '\x06\x6d\x83\x13' \ '\xd1\xfe\xb7\x6f' '\xbe\x02\xcd\x6a' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestColormapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'window': 1353796539, 'colormap': 659729309, 'new': 1, 'type': 211, 'state': 168, 'sequence_number': 8684, } self.evt_bin_0 = '\xd3\x00\xec\x21' '\xbb\x4b\xb1\x50' \ '\x9d\xab\x52\x27' '\x01\xa8\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ColormapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestClientMessage(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'type': 237, 'window': 1804643202, 'client_type': 455293257, 'data': (8, '01234567890123456789'), 'sequence_number': 14854, } self.evt_bin_0 = '\xed\x08\x06\x3a' '\x82\xab\x90\x6b' \ '\x49\x39\x23\x1b' '\x30\x31\x32\x33' \ '\x34\x35\x36\x37' '\x38\x39\x30\x31' \ '\x32\x33\x34\x35' '\x36\x37\x38\x39' self.evt_args_1 = { 'type': 160, 'window': 948875838, 'client_type': 212297388, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'sequence_number': 28171, } self.evt_bin_1 = '\xa0\x10\x0b\x6e' '\x3e\xb2\x8e\x38' \ '\xac\x66\xa7\x0c' '\x01\x00\x02\x00' \ '\x03\x00\x04\x00' '\x05\x00\x06\x00' \ '\x07\x00\x08\x00' '\x09\x00\x0a\x00' self.evt_args_2 = { 'type': 243, 'window': 581929030, 'client_type': 966878718, 'data': (32, [1, 2, 3, 4, 5]), 'sequence_number': 63569, } self.evt_bin_2 = '\xf3\x20\x51\xf8' '\x46\x88\xaf\x22' \ '\xfe\x65\xa1\x39' '\x01\x00\x00\x00' \ '\x02\x00\x00\x00' '\x03\x00\x00\x00' \ '\x04\x00\x00\x00' '\x05\x00\x00\x00' def testPack0(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) def testPack1(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_1) try: assert bin == self.evt_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_1 except AssertionError: raise AssertionError(args) def testPack2(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_2) try: assert bin == self.evt_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_2 except AssertionError: raise AssertionError(args) class TestMappingNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'first_keycode': 246, 'request': 189, 'type': 198, 'count': 201, 'sequence_number': 32665, } self.evt_bin_0 = '\xc6\x00\x99\x7f' '\xbd\xf6\xc9\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MappingNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) if __name__ == "__main__": check_endian() unittest.main() python-xlib-0.14+20091101/test/test_rdb.py0000755000175000017500000000715610633003257016504 0ustar stewstew#!/usr/bin/env python import sys import os sys.path.insert(1, os.path.join(sys.path[0], '..')) import Xlib.rdb import unittest resources = """ ! Single component single: name Single: class ?: wild ! name vs class vs ? p.first.second: n.n p.first.Second: n.c p.first.?: n.w p.First.second: c.n p.First.Second: c.c p.First.?: c.w p.?.second: w.n p.?.Second: w.c p.?.?: w.w ! Tight over loose bindings b.tight.match: tight b.tight*match: bad b.loose*match: loose ! skip matches s.*end: default s.foo*end: default foo s.foo.bar.end: bar foo ! Multiple skip matches ss.*mid*end: default ss.foo*mid*end: default foo ss.foo*mid.bar*end: bar foo ! First component unbound *fie.fum: skipfirst fie.fum: matchtwo feh.fie.fum: matchfirst """ queries = ( # Single component ('single', 'Single', 'name'), ('noname', 'Single', 'class'), ('noname', 'Noclass', 'wild'), # Name vs class vs ? ('p.first.second', 'P.First.Second', 'n.n'), ('p.first.noname', 'P.First.Second', 'n.c'), ('p.first.noname', 'P.First.Noclass', 'n.w'), ('p.noname.second', 'P.First.Second', 'c.n'), ('p.noname.noname', 'P.First.Second', 'c.c'), ('p.noname.noname', 'P.First.Noclass', 'c.w'), ('p.noname.second', 'P.Noclass.Second', 'w.n'), ('p.noname.noname', 'P.Noclass.Second', 'w.c'), ('p.noname.noname', 'P.Noclass.Noclass', 'w.w'), # Tight over loose bindings ('b.tight.match', 'B.Tight.Match', 'tight'), ('b.loose.match', 'B.Loose.Match', 'loose'), # skip matches ('s.bar.end', 'S.Bar.End', 'default'), ('s.foo.bar.end', 'S.Foo.Bar.End', 'bar foo'), ('s.foo.gazonk.end', 'S.Foo.Gazonk.End', 'default foo'), # Multiple skip matches ('ss.x.mid.x.end', 'Ss.X.Mid.X.End', 'default'), ('ss.foo.x.mid.x.end', 'Ss.Foo.X.Mid.X.End', 'default foo'), ('ss.foo.x.mid.bar.x.end', 'Ss.Foo.X.Mid.Bar.X.End', 'bar foo'), ('ss.foo.mid.x.mid.bar.x.end', 'Ss.Foo.Mid.X.Mid.Bar.X.End', 'default foo'), ('ss.foo.x.mid.x.mid.bar.x.end', 'Ss.Foo.X.Mid.X.Mid.Bar.X.End', 'default foo'), # First component unbound ('fie.fum', 'Fie.Fum', 'matchtwo'), ('noname.fie.fum', 'Noclass.Fie.Fum', 'skipfirst'), ('feh.fie.fum', 'Feh.Fie.Fum', 'matchfirst'), ) resource_set1 = ( ('foo.bar', 1,), ('foo.bar.gazonk', 2), ('*bar*gazonk', 3), ) resource_set2 = ( ('foo.bar', 10,), # Changing the value of an item ('foo.bar.whee', 11), # Adding entries to existing component ('foo.bar*whoho', 12), ('foo.fie', 13), # Copy new resources ('foo.fie*fum', 14), ('*foo.bar', 15), ) class TestRDB(unittest.TestCase): def testParseAndQuery(self): # Test string parsing and querying db = Xlib.rdb.ResourceDB(string = resources) for name, cls, value in queries: try: v = db[name, cls] except KeyError: raise AssertionError('Value not found for %s/%s:\n expected %s' % (name, cls, value)) if v != value: raise AssertionError('Value mismatch for %s/%s:\n expected %s, got %s' % (name, cls, value, v)) def testUpdate(self): # Test update. An update should have the same result as # inserting all the resource entries in the manually db1 = Xlib.rdb.ResourceDB() db2 = Xlib.rdb.ResourceDB() db3 = Xlib.rdb.ResourceDB() db1.insert_resources(resource_set1) db2.insert_resources(resource_set2) db1.update(db2) db3.insert_resources(resource_set1) db3.insert_resources(resource_set2) assert db1.db == db3.db if __name__ == '__main__': unittest.main() python-xlib-0.14+20091101/test/test_requests_be.py0000644000175000017500000057601510633003257020260 0ustar stewstew#!/usr/bin/env python import sys, os sys.path.insert(1, os.path.join(sys.path[0], '..')) import string import unittest from Xlib.protocol import request, rq, event import Xlib.protocol.event import struct import array class CmpArray: def __init__(self, *args, **kws): self.array = apply(array.array, args, kws) def __len__(self): return len(self.array) def __getslice__(self, x, y): return list(self.array[x:y]) def __getattr__(self, attr): return getattr(self.array, attr) def __cmp__(self, other): return cmp(self.array.tolist(), other) rq.array = CmpArray def tohex(bin): bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '') bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("'%s'" % bins[i]) return string.join(bins2, ' \\\n ') class DummyDisplay: def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() def check_endian(): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: sys.stderr.write('Big-endian tests, skipping on this system.\n') sys.exit(0) class TestCreateWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'height': 38608, 'window_class': 0, 'border_width': 34451, 'visual': 398069779, 'x': -20771, 'y': -4049, 'parent': 1960526158, 'attrs': {'backing_pixel': 561400151, 'cursor': 1442692293, 'background_pixmap': 1583833923, 'border_pixmap': 1992559786, 'backing_planes': 1454152605, 'win_gravity': 3, 'backing_store': 2, 'event_mask': 368242204, 'save_under': 0, 'background_pixel': 209127175, 'colormap': 377416705, 'border_pixel': 2135465356, 'bit_gravity': 0, 'do_not_propagate_mask': 597142897, 'override_redirect': 0}, 'wid': 1828913444, 'depth': 186, 'width': 51466, } self.req_bin_0 = '\x01\xba\x00\x17' '\x6d\x03\x01\x24' \ '\x74\xdb\x41\x4e' '\xae\xdd\xf0\x2f' \ '\xc9\x0a\x96\xd0' '\x86\x93\x00\x00' \ '\x17\xba\x10\x13' '\x00\x00\x7f\xff' \ '\x5e\x67\x63\x43' '\x0c\x77\x07\x07' \ '\x76\xc4\x0c\xaa' '\x7f\x48\x9d\x8c' \ '\x00\x00\x00\x00' '\x03\x00\x00\x00' \ '\x02\x00\x00\x00' '\x56\xac\x9b\x9d' \ '\x21\x76\x49\x57' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x15\xf2\xee\x1c' \ '\x23\x97\xad\x71' '\x16\x7e\xec\x01' \ '\x55\xfd\xbc\xc5' def testPackRequest0(self): bin = apply(request.CreateWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeWindowAttributes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1813552124, 'attrs': {'backing_pixel': 59516078, 'cursor': 1682969315, 'background_pixmap': 370313360, 'border_pixmap': 1158771722, 'backing_planes': 1432315664, 'win_gravity': 3, 'backing_store': 1, 'event_mask': 1054128649, 'save_under': 0, 'background_pixel': 1953340842, 'colormap': 1462101672, 'border_pixel': 287436510, 'bit_gravity': 10, 'do_not_propagate_mask': 1283834625, 'override_redirect': 0}, } self.req_bin_0 = '\x02\x00\x00\x12' '\x6c\x18\x9b\xfc' \ '\x00\x00\x7f\xff' '\x16\x12\x88\x90' \ '\x74\x6d\x9d\xaa' '\x45\x11\x74\x0a' \ '\x11\x21\xee\xde' '\x0a\x00\x00\x00' \ '\x03\x00\x00\x00' '\x01\x00\x00\x00' \ '\x55\x5f\x67\x10' '\x03\x8c\x24\xae' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x3e\xd4\xba\x09' '\x4c\x85\xc3\x01' \ '\x57\x25\xe6\xa8' '\x64\x50\x12\xe3' def testPackRequest0(self): bin = apply(request.ChangeWindowAttributes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetWindowAttributes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1931593850, } self.req_bin_0 = '\x03\x00\x00\x02' '\x73\x21\xc8\x7a' self.reply_args_0 = { 'sequence_number': 60057, 'backing_pixel': 136561993, 'your_event_mask': 1332399119, 'map_is_installed': 0, 'visual': 687387929, 'backing_bit_planes': 990144409, 'backing_store': 147, 'win_class': 18284, 'map_state': 185, 'save_under': 0, 'all_event_masks': 270223628, 'colormap': 1161384334, 'win_gravity': 157, 'bit_gravity': 253, 'do_not_propagate_mask': 33787, 'override_redirect': 0, } self.reply_bin_0 = '\x01\x93\xea\x99' '\x00\x00\x00\x03' \ '\x28\xf8\xb5\x19' '\x47\x6c\xfd\x9d' \ '\x3b\x04\x67\x99' '\x08\x23\xc5\x49' \ '\x00\x00\xb9\x00' '\x45\x39\x51\x8e' \ '\x10\x1b\x49\x0c' '\x4f\x6a\xcc\x0f' \ '\x83\xfb\x00\x00' def testPackRequest0(self): bin = apply(request.GetWindowAttributes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetWindowAttributes._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestDestroyWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1622184267, } self.req_bin_0 = '\x04\x00\x00\x02' '\x60\xb0\x91\x4b' def testPackRequest0(self): bin = apply(request.DestroyWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestDestroySubWindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1000376476, } self.req_bin_0 = '\x05\x00\x00\x02' '\x3b\xa0\x88\x9c' def testPackRequest0(self): bin = apply(request.DestroySubWindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeSaveSet(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1577523459, 'mode': 0, } self.req_bin_0 = '\x06\x00\x00\x02' '\x5e\x07\x19\x03' def testPackRequest0(self): bin = apply(request.ChangeSaveSet._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestReparentWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'parent': 72188776, 'window': 1300734112, 'x': -5207, 'y': -22675, } self.req_bin_0 = '\x07\x00\x00\x04' '\x4d\x87\xa0\xa0' \ '\x04\x4d\x83\x68' '\xeb\xa9\xa7\x6d' def testPackRequest0(self): bin = apply(request.ReparentWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestMapWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 61469476, } self.req_bin_0 = '\x08\x00\x00\x02' '\x03\xa9\xf3\x24' def testPackRequest0(self): bin = apply(request.MapWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestMapSubwindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 818738118, } self.req_bin_0 = '\x09\x00\x00\x02' '\x30\xcc\xf3\xc6' def testPackRequest0(self): bin = apply(request.MapSubwindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUnmapWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1923663468, } self.req_bin_0 = '\x0a\x00\x00\x02' '\x72\xa8\xc6\x6c' def testPackRequest0(self): bin = apply(request.UnmapWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUnmapSubwindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 999740194, } self.req_bin_0 = '\x0b\x00\x00\x02' '\x3b\x96\xd3\x22' def testPackRequest0(self): bin = apply(request.UnmapSubwindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestConfigureWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 190634459, 'attrs': {'height': 57788, 'stack_mode': 2, 'border_width': -320, 'width': 53674, 'x': -2248, 'y': -29960, 'sibling': 1012823324}, } self.req_bin_0 = '\x0c\x00\x00\x0a' '\x0b\x5c\xd9\xdb' \ '\x00\x7f\x00\x00' '\xf7\x38\x00\x00' \ '\x8a\xf8\x00\x00' '\xd1\xaa\x00\x00' \ '\xe1\xbc\x00\x00' '\xfe\xc0\x00\x00' \ '\x3c\x5e\x75\x1c' '\x02\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ConfigureWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCirculateWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1712979067, 'direction': 1, } self.req_bin_0 = '\x0d\x01\x00\x02' '\x66\x19\xfc\x7b' def testPackRequest0(self): bin = apply(request.CirculateWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetGeometry(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 680179490, } self.req_bin_0 = '\x0e\x00\x00\x02' '\x28\x8a\xb7\x22' self.reply_args_0 = { 'height': 64954, 'sequence_number': 39469, 'root': 609586545, 'border_width': 496, 'x': -1253, 'y': -11180, 'depth': 204, 'width': 38433, } self.reply_bin_0 = '\x01\xcc\x9a\x2d' '\x00\x00\x00\x00' \ '\x24\x55\x8d\x71' '\xfb\x1b\xd4\x54' \ '\x96\x21\xfd\xba' '\x01\xf0\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetGeometry._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetGeometry._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryTree(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 2052496265, } self.req_bin_0 = '\x0f\x00\x00\x02' '\x7a\x56\x9b\x89' self.reply_args_0 = { 'sequence_number': 33887, 'children': [1795767666, 1494491557, 748301378, 729512097, 1262057849, 64238195, 1088261715], 'root': 1856577120, 'parent': 2105827407, } self.reply_bin_0 = '\x01\x00\x84\x5f' '\x00\x00\x00\x07' \ '\x6e\xa9\x1e\x60' '\x7d\x84\x60\x4f' \ '\x00\x07\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x6b\x09\x3d\x72' '\x59\x14\x21\xa5' \ '\x2c\x9a\x2c\x42' '\x2b\x7b\x78\xa1' \ '\x4b\x39\x79\x79' '\x03\xd4\x32\x73' \ '\x40\xdd\x8e\x53' def testPackRequest0(self): bin = apply(request.QueryTree._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryTree._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestInternAtom(unittest.TestCase): def setUp(self): self.req_args_0 = { 'only_if_exists': 0, 'name': 'fuzzy_prop', } self.req_bin_0 = '\x10\x00\x00\x05' '\x00\x0a\x00\x00' \ '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \ '\x6f\x70\x00\x00' self.reply_args_0 = { 'atom': 48723297, 'sequence_number': 35223, } self.reply_bin_0 = '\x01\x00\x89\x97' '\x00\x00\x00\x00' \ '\x02\xe7\x75\x61' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.InternAtom._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.InternAtom._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetAtomName(unittest.TestCase): def setUp(self): self.req_args_0 = { 'atom': 1022286544, } self.req_bin_0 = '\x11\x00\x00\x02' '\x3c\xee\xda\xd0' self.reply_args_0 = { 'sequence_number': 22699, 'name': 'WM_CLASS', } self.reply_bin_0 = '\x01\x00\x58\xab' '\x00\x00\x00\x02' \ '\x00\x08\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53' def testPackRequest0(self): bin = apply(request.GetAtomName._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetAtomName._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 0, 'data': (8, ''), 'property': 2085394193, 'window': 266197951, 'type': 1343008022, } self.req_bin_0 = '\x12\x00\x00\x06' '\x0f\xdd\xdb\xbf' \ '\x7c\x4c\x97\x11' '\x50\x0c\xad\x16' \ '\x08\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_1 = { 'mode': 2, 'data': (8, 'foo'), 'property': 449719979, 'window': 1522118044, 'type': 121096013, } self.req_bin_1 = '\x12\x02\x00\x07' '\x5a\xb9\xad\x9c' \ '\x1a\xce\x2e\xab' '\x07\x37\xc7\x4d' \ '\x08\x00\x00\x00' '\x00\x00\x00\x03' \ '\x66\x6f\x6f\x00' self.req_args_2 = { 'mode': 2, 'data': (8, 'zoom'), 'property': 1009841498, 'window': 286324270, 'type': 1547457396, } self.req_bin_2 = '\x12\x02\x00\x07' '\x11\x10\xf6\x2e' \ '\x3c\x30\xf5\x5a' '\x5c\x3c\x53\x74' \ '\x08\x00\x00\x00' '\x00\x00\x00\x04' \ '\x7a\x6f\x6f\x6d' self.req_args_3 = { 'mode': 0, 'data': (16, []), 'property': 426983104, 'window': 1964921608, 'type': 692879036, } self.req_bin_3 = '\x12\x00\x00\x06' '\x75\x1e\x53\x08' \ '\x19\x73\x3e\xc0' '\x29\x4c\x7e\xbc' \ '\x10\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_4 = { 'mode': 0, 'data': (16, [1, 2, 3]), 'property': 801006756, 'window': 560040176, 'type': 2030208993, } self.req_bin_4 = '\x12\x00\x00\x08' '\x21\x61\x88\xf0' \ '\x2f\xbe\x64\xa4' '\x79\x02\x87\xe1' \ '\x10\x00\x00\x00' '\x00\x00\x00\x03' \ '\x00\x01\x00\x02' '\x00\x03\x00\x00' self.req_args_5 = { 'mode': 0, 'data': (16, [1, 2, 3, 4]), 'property': 1401687842, 'window': 2016421454, 'type': 434059096, } self.req_bin_5 = '\x12\x00\x00\x08' '\x78\x30\x26\x4e' \ '\x53\x8c\x0f\x22' '\x19\xdf\x37\x58' \ '\x10\x00\x00\x00' '\x00\x00\x00\x04' \ '\x00\x01\x00\x02' '\x00\x03\x00\x04' self.req_args_6 = { 'mode': 2, 'data': (32, []), 'property': 1008934075, 'window': 461926013, 'type': 613217208, } self.req_bin_6 = '\x12\x02\x00\x06' '\x1b\x88\x6e\x7d' \ '\x3c\x23\x1c\xbb' '\x24\x8c\xf3\xb8' \ '\x20\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_7 = { 'mode': 1, 'data': (32, [1, 2, 3]), 'property': 1472503640, 'window': 367636986, 'type': 1085552939, } self.req_bin_7 = '\x12\x01\x00\x09' '\x15\xe9\xb1\xfa' \ '\x57\xc4\x9f\x58' '\x40\xb4\x39\x2b' \ '\x20\x00\x00\x00' '\x00\x00\x00\x03' \ '\x00\x00\x00\x01' '\x00\x00\x00\x02' \ '\x00\x00\x00\x03' def testPackRequest0(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) def testPackRequest2(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_2) try: assert bin == self.req_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_2 except AssertionError: raise AssertionError(args) def testPackRequest3(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_3) try: assert bin == self.req_bin_3 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_3 except AssertionError: raise AssertionError(args) def testPackRequest4(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_4) try: assert bin == self.req_bin_4 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_4 except AssertionError: raise AssertionError(args) def testPackRequest5(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_5) try: assert bin == self.req_bin_5 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_5 except AssertionError: raise AssertionError(args) def testPackRequest6(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_6) try: assert bin == self.req_bin_6 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_6 except AssertionError: raise AssertionError(args) def testPackRequest7(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_7) try: assert bin == self.req_bin_7 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_7 except AssertionError: raise AssertionError(args) class TestDeleteProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'property': 506897017, 'window': 381870530, } self.req_bin_0 = '\x13\x00\x00\x03' '\x16\xc2\xe1\xc2' \ '\x1e\x36\xa2\x79' def testPackRequest0(self): bin = apply(request.DeleteProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'delete': 0, 'long_offset': 1563462862, 'type': 1556454304, 'property': 1007774483, 'window': 1477792536, 'long_length': 1346507413, } self.req_bin_0 = '\x14\x00\x00\x06' '\x58\x15\x53\x18' \ '\x3c\x11\x6b\x13' '\x5c\xc5\x9b\xa0' \ '\x5d\x30\x8c\xce' '\x50\x42\x12\x95' self.reply_args_0 = { 'value': (8, ''), 'sequence_number': 30606, 'property_type': 1392423916, 'bytes_after': 2046056935, } self.reply_bin_0 = '\x01\x08\x77\x8e' '\x00\x00\x00\x00' \ '\x52\xfe\xb3\xec' '\x79\xf4\x59\xe7' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_1 = { 'value': (8, 'foo'), 'sequence_number': 44279, 'property_type': 186441230, 'bytes_after': 469299413, } self.reply_bin_1 = '\x01\x08\xac\xf7' '\x00\x00\x00\x01' \ '\x0b\x1c\xde\x0e' '\x1b\xf8\xf0\xd5' \ '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x66\x6f\x6f\x00' self.reply_args_2 = { 'value': (8, 'zoom'), 'sequence_number': 12674, 'property_type': 1802804296, 'bytes_after': 1968158856, } self.reply_bin_2 = '\x01\x08\x31\x82' '\x00\x00\x00\x01' \ '\x6b\x74\x9c\x48' '\x75\x4f\xb8\x88' \ '\x00\x00\x00\x04' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x7a\x6f\x6f\x6d' self.reply_args_3 = { 'value': (16, []), 'sequence_number': 25311, 'property_type': 536196393, 'bytes_after': 1874157309, } self.reply_bin_3 = '\x01\x10\x62\xdf' '\x00\x00\x00\x00' \ '\x1f\xf5\xb5\x29' '\x6f\xb5\x5e\xfd' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_4 = { 'value': (16, [1, 2, 3]), 'sequence_number': 22665, 'property_type': 1046879880, 'bytes_after': 1952710167, } self.reply_bin_4 = '\x01\x10\x58\x89' '\x00\x00\x00\x02' \ '\x3e\x66\x1e\x88' '\x74\x63\xfe\x17' \ '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x01\x00\x02' '\x00\x03\x00\x00' self.reply_args_5 = { 'value': (16, [1, 2, 3, 4]), 'sequence_number': 19028, 'property_type': 1014173132, 'bytes_after': 1791090668, } self.reply_bin_5 = '\x01\x10\x4a\x54' '\x00\x00\x00\x02' \ '\x3c\x73\x0d\xcc' '\x6a\xc1\xdf\xec' \ '\x00\x00\x00\x04' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x01\x00\x02' '\x00\x03\x00\x04' self.reply_args_6 = { 'value': (32, []), 'sequence_number': 47226, 'property_type': 2053870497, 'bytes_after': 1727548898, } self.reply_bin_6 = '\x01\x20\xb8\x7a' '\x00\x00\x00\x00' \ '\x7a\x6b\x93\xa1' '\x66\xf8\x4d\xe2' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_7 = { 'value': (32, [1, 2, 3]), 'sequence_number': 37094, 'property_type': 704363625, 'bytes_after': 1957409055, } self.reply_bin_7 = '\x01\x20\x90\xe6' '\x00\x00\x00\x03' \ '\x29\xfb\xbc\x69' '\x74\xab\xb1\x1f' \ '\x00\x00\x00\x03' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x01' '\x00\x00\x00\x02' \ '\x00\x00\x00\x03' def testPackRequest0(self): bin = apply(request.GetProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) def testPackReply2(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_2) try: assert bin == self.reply_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_2 except AssertionError: raise AssertionError(args) def testPackReply3(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_3) try: assert bin == self.reply_bin_3 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_3 except AssertionError: raise AssertionError(args) def testPackReply4(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_4) try: assert bin == self.reply_bin_4 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_4 except AssertionError: raise AssertionError(args) def testPackReply5(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_5) try: assert bin == self.reply_bin_5 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_5 except AssertionError: raise AssertionError(args) def testPackReply6(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_6) try: assert bin == self.reply_bin_6 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_6 except AssertionError: raise AssertionError(args) def testPackReply7(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_7) try: assert bin == self.reply_bin_7 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_7 except AssertionError: raise AssertionError(args) class TestListProperties(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 91262675, } self.req_bin_0 = '\x15\x00\x00\x02' '\x05\x70\x8e\xd3' self.reply_args_0 = { 'atoms': [580972634, 926488735, 714741529, 408777797, 679906858, 705092899, 2063243279, 893967755, 1591182471, 571137996, 1677110101, 1783836762, 1678219148, 1992402577, 871298793, 1182885899, 1155013854, 1822076326, 2117552706, 1972668469, 1660227078, 1523268962, 694042433], 'sequence_number': 42191, } self.reply_bin_0 = '\x01\x00\xa4\xcf' '\x00\x00\x00\x17' \ '\x00\x17\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x22\xa0\xf0\x5a' '\x37\x39\x18\x9f' \ '\x2a\x9a\x17\x19' '\x18\x5d\x74\x45' \ '\x28\x86\x8e\x2a' '\x2a\x06\xdd\x23' \ '\x7a\xfa\x98\x0f' '\x35\x48\xdd\x8b' \ '\x5e\xd7\x84\x87' '\x22\x0a\xdf\xcc' \ '\x63\xf6\xab\x55' '\x6a\x53\x30\x5a' \ '\x64\x07\x97\x8c' '\x76\xc1\xa6\x91' \ '\x33\xee\xf6\xe9' '\x46\x81\x68\x0b' \ '\x44\xd8\x1c\xde' '\x6c\x9a\xad\xa6' \ '\x7e\x37\x4a\x42' '\x75\x94\x88\x35' \ '\x62\xf5\x0e\x06' '\x5a\xcb\x3d\x62' \ '\x29\x5e\x3f\x41' def testPackRequest0(self): bin = apply(request.ListProperties._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListProperties._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetSelectionOwner(unittest.TestCase): def setUp(self): self.req_args_0 = { 'selection': 2071258139, 'window': 1190911777, 'time': 1606660593, } self.req_bin_0 = '\x16\x00\x00\x04' '\x46\xfb\xdf\x21' \ '\x7b\x74\xe4\x1b' '\x5f\xc3\xb1\xf1' def testPackRequest0(self): bin = apply(request.SetSelectionOwner._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetSelectionOwner(unittest.TestCase): def setUp(self): self.req_args_0 = { 'selection': 819576555, } self.req_bin_0 = '\x17\x00\x00\x02' '\x30\xd9\xbe\xeb' self.reply_args_0 = { 'sequence_number': 14152, 'owner': 1922331178, } self.reply_bin_0 = '\x01\x00\x37\x48' '\x00\x00\x00\x00' \ '\x72\x94\x72\x2a' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetSelectionOwner._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetSelectionOwner._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestConvertSelection(unittest.TestCase): def setUp(self): self.req_args_0 = { 'property': 2137791927, 'time': 1594653142, 'target': 1972273672, 'selection': 125139929, 'requestor': 300355135, } self.req_bin_0 = '\x18\x00\x00\x06' '\x11\xe7\x0e\x3f' \ '\x07\x75\x7b\xd9' '\x75\x8e\x82\x08' \ '\x7f\x6c\x1d\xb7' '\x5f\x0c\x79\xd6' def testPackRequest0(self): bin = apply(request.ConvertSelection._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSendEvent(unittest.TestCase): def setUp(self): self.req_args_0 = { 'event': Xlib.protocol.event.Expose(height = 64784, sequence_number = 0, type = 12, x = 52546, y = 56316, window = 1322187412, width = 16612, count = 14164), 'propagate': 1, 'destination': 1369243800, 'event_mask': 1594482936, } self.req_bin_0 = '\x19\x01\x00\x0b' '\x51\x9d\x00\x98' \ '\x5f\x09\xe0\xf8' '\x0c\x00\x00\x00' \ '\x4e\xce\xfa\x94' '\xcd\x42\xdb\xfc' \ '\x40\xe4\xfd\x10' '\x37\x54\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SendEvent._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'owner_events': 1, 'grab_window': 2104857020, 'confine_to': 1988278615, 'event_mask': 2075, 'pointer_mode': 0, 'time': 1316427724, 'keyboard_mode': 1, 'cursor': 17101598, } self.req_bin_0 = '\x1a\x01\x00\x06' '\x7d\x75\x91\xbc' \ '\x08\x1b\x00\x01' '\x76\x82\xb9\x57' \ '\x01\x04\xf3\x1e' '\x4e\x77\x17\xcc' self.reply_args_0 = { 'sequence_number': 47539, 'status': 149, } self.reply_bin_0 = '\x01\x95\xb9\xb3' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GrabPointer._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestUngrabPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 209008422, } self.req_bin_0 = '\x1b\x00\x00\x02' '\x0c\x75\x37\x26' def testPackRequest0(self): bin = apply(request.UngrabPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabButton(unittest.TestCase): def setUp(self): self.req_args_0 = { 'owner_events': 1, 'grab_window': 526402184, 'confine_to': 1843948635, 'event_mask': 16279, 'pointer_mode': 1, 'modifiers': 15589, 'button': 208, 'keyboard_mode': 1, 'cursor': 1070323643, } self.req_bin_0 = '\x1c\x01\x00\x06' '\x1f\x60\x42\x88' \ '\x3f\x97\x01\x01' '\x6d\xe8\x6c\x5b' \ '\x3f\xcb\xd7\xbb' '\xd0\x00\x3c\xe5' def testPackRequest0(self): bin = apply(request.GrabButton._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabButton(unittest.TestCase): def setUp(self): self.req_args_0 = { 'grab_window': 795414150, 'button': 240, 'modifiers': 51717, } self.req_bin_0 = '\x1d\xf0\x00\x03' '\x2f\x69\x0e\x86' \ '\xca\x05\x00\x00' def testPackRequest0(self): bin = apply(request.UngrabButton._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeActivePointerGrab(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 891337572, 'event_mask': 23423, 'cursor': 1696594928, } self.req_bin_0 = '\x1e\x00\x00\x04' '\x65\x1f\xfb\xf0' \ '\x35\x20\xbb\x64' '\x5b\x7f\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeActivePointerGrab._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabKeyboard(unittest.TestCase): def setUp(self): self.req_args_0 = { 'owner_events': 0, 'grab_window': 76132199, 'time': 1562605785, 'pointer_mode': 1, 'keyboard_mode': 1, } self.req_bin_0 = '\x1f\x00\x00\x04' '\x04\x89\xaf\x67' \ '\x5d\x23\x78\xd9' '\x01\x01\x00\x00' self.reply_args_0 = { 'sequence_number': 9648, 'status': 129, } self.reply_bin_0 = '\x01\x81\x25\xb0' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabKeyboard._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GrabKeyboard._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestUngrabKeyboard(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 1352311886, } self.req_bin_0 = '\x20\x00\x00\x02' '\x50\x9a\xa4\x4e' def testPackRequest0(self): bin = apply(request.UngrabKeyboard._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabKey(unittest.TestCase): def setUp(self): self.req_args_0 = { 'owner_events': 1, 'grab_window': 1467490800, 'pointer_mode': 0, 'keyboard_mode': 0, 'modifiers': 28819, 'key': 193, } self.req_bin_0 = '\x21\x01\x00\x04' '\x57\x78\x21\xf0' \ '\x70\x93\xc1\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabKey._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabKey(unittest.TestCase): def setUp(self): self.req_args_0 = { 'grab_window': 769929659, 'key': 215, 'modifiers': 60588, } self.req_bin_0 = '\x22\xd7\x00\x03' '\x2d\xe4\x31\xbb' \ '\xec\xac\x00\x00' def testPackRequest0(self): bin = apply(request.UngrabKey._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestAllowEvents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 342147129, 'mode': 1, } self.req_bin_0 = '\x23\x01\x00\x02' '\x14\x64\xc0\x39' def testPackRequest0(self): bin = apply(request.AllowEvents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabServer(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x24\x00\x00\x01' def testPackRequest0(self): bin = apply(request.GrabServer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabServer(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x25\x00\x00\x01' def testPackRequest0(self): bin = apply(request.UngrabServer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 561336799, } self.req_bin_0 = '\x26\x00\x00\x02' '\x21\x75\x51\xdf' self.reply_args_0 = { 'win_y': -25733, 'same_screen': 0, 'sequence_number': 41448, 'root': 1599238998, 'root_x': -4185, 'root_y': -6112, 'mask': 35955, 'child': 1075058918, 'win_x': -18858, } self.reply_bin_0 = '\x01\x00\xa1\xe8' '\x00\x00\x00\x00' \ '\x5f\x52\x73\x56' '\x40\x14\x18\xe6' \ '\xef\xa7\xe8\x20' '\xb6\x56\x9b\x7b' \ '\x8c\x73\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryPointer._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetMotionEvents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 843681780, 'start': 1520150500, 'stop': 11115313, } self.req_bin_0 = '\x27\x00\x00\x04' '\x32\x49\x8f\xf4' \ '\x5a\x9b\xa7\xe4' '\x00\xa9\x9b\x31' self.reply_args_0 = { 'sequence_number': 52222, 'events': [{'time': 2107444516, 'x': -649, 'y': -11631}, {'time': 1827536960, 'x': -18061, 'y': -2301}, {'time': 554175146, 'x': -32111, 'y': -13522}, {'time': 608168588, 'x': -5963, 'y': -24618}, {'time': 590416221, 'x': -3325, 'y': -19656}], } self.reply_bin_0 = '\x01\x00\xcb\xfe' '\x00\x00\x00\x0a' \ '\x00\x00\x00\x05' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x7d\x9d\x0d\x24' '\xfd\x77\xd2\x91' \ '\x6c\xee\x00\x40' '\xb9\x73\xf7\x03' \ '\x21\x08\x0a\xaa' '\x82\x91\xcb\x2e' \ '\x24\x3f\xea\x8c' '\xe8\xb5\x9f\xd6' \ '\x23\x31\x09\x5d' '\xf3\x03\xb3\x38' def testPackRequest0(self): bin = apply(request.GetMotionEvents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetMotionEvents._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestTranslateCoords(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_y': -27247, 'src_x': -25331, 'src_wid': 257619448, 'dst_wid': 1238981863, } self.req_bin_0 = '\x28\x00\x00\x04' '\x0f\x5a\xf5\xf8' \ '\x49\xd9\x5c\xe7' '\x9d\x0d\x95\x91' self.reply_args_0 = { 'child': 2050350678, 'same_screen': 1, 'sequence_number': 38657, 'x': -18096, 'y': -5252, } self.reply_bin_0 = '\x01\x01\x97\x01' '\x00\x00\x00\x00' \ '\x7a\x35\xde\x56' '\xb9\x50\xeb\x7c' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.TranslateCoords._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.TranslateCoords._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestWarpPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_height': 56634, 'src_window': 1335081711, 'dst_window': 675547124, 'src_width': 21809, 'src_y': -26071, 'src_x': -27119, 'dst_x': -30516, 'dst_y': -24204, } self.req_bin_0 = '\x29\x00\x00\x06' '\x4f\x93\xba\xef' \ '\x28\x44\x07\xf4' '\x96\x11\x9a\x29' \ '\x55\x31\xdd\x3a' '\x88\xcc\xa1\x74' def testPackRequest0(self): bin = apply(request.WarpPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetInputFocus(unittest.TestCase): def setUp(self): self.req_args_0 = { 'revert_to': 1, 'time': 1079702500, 'focus': 1026400247, } self.req_bin_0 = '\x2a\x01\x00\x03' '\x3d\x2d\x9f\xf7' \ '\x40\x5a\xf3\xe4' def testPackRequest0(self): bin = apply(request.SetInputFocus._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetInputFocus(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x2b\x00\x00\x01' self.reply_args_0 = { 'revert_to': 152, 'sequence_number': 16002, 'focus': 2024022965, } self.reply_bin_0 = '\x01\x98\x3e\x82' '\x00\x00\x00\x00' \ '\x78\xa4\x23\xb5' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetInputFocus._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetInputFocus._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryKeymap(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x2c\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 16233, 'map': [186, 167, 191, 213, 241, 231, 234, 175, 154, 169, 132, 146, 215, 191, 196, 212, 158, 156, 177, 233, 220, 192, 130, 226, 181, 233, 238, 141, 129, 215, 245, 215], } self.reply_bin_0 = '\x01\x00\x3f\x69' '\x00\x00\x00\x02' \ '\xba\xa7\xbf\xd5' '\xf1\xe7\xea\xaf' \ '\x9a\xa9\x84\x92' '\xd7\xbf\xc4\xd4' \ '\x9e\x9c\xb1\xe9' '\xdc\xc0\x82\xe2' \ '\xb5\xe9\xee\x8d' '\x81\xd7\xf5\xd7' def testPackRequest0(self): bin = apply(request.QueryKeymap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryKeymap._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestOpenFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'fid': 1728036313, 'name': 'foofont', } self.req_bin_0 = '\x2d\x00\x00\x05' '\x66\xff\xbd\xd9' \ '\x00\x07\x00\x00' '\x66\x6f\x6f\x66' \ '\x6f\x6e\x74\x00' def testPackRequest0(self): bin = apply(request.OpenFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCloseFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 1139770507, } self.req_bin_0 = '\x2e\x00\x00\x02' '\x43\xef\x84\x8b' def testPackRequest0(self): bin = apply(request.CloseFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 1867659050, } self.req_bin_0 = '\x2f\x00\x00\x02' '\x6f\x52\x37\x2a' self.reply_args_0 = { 'sequence_number': 8877, 'properties': [{'value': 2110348825, 'name': 1450586355}], 'min_byte1': 190, 'max_byte1': 168, 'char_infos': [{'descent': -331, 'ascent': -14454, 'character_width': -28521, 'left_side_bearing': -4521, 'right_side_bearing': -9875, 'attributes': 55191}, {'descent': -18739, 'ascent': -6278, 'character_width': -4532, 'left_side_bearing': -20397, 'right_side_bearing': -25187, 'attributes': 29476}, {'descent': -18381, 'ascent': -2378, 'character_width': -21855, 'left_side_bearing': -20068, 'right_side_bearing': -906, 'attributes': 34385}], 'max_char_or_byte2': 2516, 'default_char': 8994, 'min_char_or_byte2': 49360, 'draw_direction': 143, 'min_bounds': {'descent': -29813, 'ascent': -27033, 'character_width': -5286, 'left_side_bearing': -20740, 'right_side_bearing': -21698, 'attributes': 11392}, 'all_chars_exist': 1, 'font_ascent': -15646, 'font_descent': -23067, 'max_bounds': {'descent': -24292, 'ascent': -26972, 'character_width': -19286, 'left_side_bearing': -16363, 'right_side_bearing': -3149, 'attributes': 35968}, } self.reply_bin_0 = '\x01\x00\x22\xad' '\x00\x00\x00\x12' \ '\xae\xfc\xab\x3e' '\xeb\x5a\x96\x67' \ '\x8b\x8b\x2c\x80' '\x00\x00\x00\x00' \ '\xc0\x15\xf3\xb3' '\xb4\xaa\x96\xa4' \ '\xa1\x1c\x8c\x80' '\x00\x00\x00\x00' \ '\xc0\xd0\x09\xd4' '\x23\x22\x00\x01' \ '\x8f\xbe\xa8\x01' '\xc2\xe2\xa5\xe5' \ '\x00\x00\x00\x03' '\x56\x76\x30\xf3' \ '\x7d\xc9\x5e\x19' '\xee\x57\xd9\x6d' \ '\x90\x97\xc7\x8a' '\xfe\xb5\xd7\x97' \ '\xb0\x53\x9d\x9d' '\xee\x4c\xe7\x7a' \ '\xb6\xcd\x73\x24' '\xb1\x9c\xfc\x76' \ '\xaa\xa1\xf6\xb6' '\xb8\x33\x86\x51' def testPackRequest0(self): bin = apply(request.QueryFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryFont._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryTextExtents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 1562125736, 'string': (102, 111, 111), } self.req_bin_0 = '\x30\x01\x00\x04' '\x5d\x1c\x25\xa8' \ '\x00\x66\x00\x6f' '\x00\x6f\x00\x00' self.reply_args_0 = { 'overall_width': -1378352414, 'draw_direction': 219, 'sequence_number': 6791, 'font_ascent': -16915, 'overall_ascent': -22910, 'overall_descent': -1795, 'overall_right': -530284310, 'overall_left': -1046976699, 'font_descent': -14179, } self.reply_bin_0 = '\x01\xdb\x1a\x87' '\x00\x00\x00\x00' \ '\xbd\xed\xc8\x9d' '\xa6\x82\xf8\xfd' \ '\xad\xd8\x02\xe2' '\xc1\x98\x67\x45' \ '\xe0\x64\x80\xea' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryTextExtents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryTextExtents._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListFonts(unittest.TestCase): def setUp(self): self.req_args_0 = { 'max_names': 53961, 'pattern': 'bhazr', } self.req_bin_0 = '\x31\x00\x00\x04' '\xd2\xc9\x00\x05' \ '\x62\x68\x61\x7a' '\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], 'sequence_number': 38267, } self.reply_bin_0 = '\x01\x00\x95\x7b' '\x00\x00\x00\x05' \ '\x00\x03\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \ '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \ '\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = apply(request.ListFonts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListFonts._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListFontsWithInfo(unittest.TestCase): def setUp(self): self.req_args_0 = { 'max_names': 46571, 'pattern': 'bhazr2', } self.req_bin_0 = '\x32\x00\x00\x04' '\xb5\xeb\x00\x06' \ '\x62\x68\x61\x7a' '\x72\x32\x00\x00' self.reply_args_0 = { 'sequence_number': 20014, 'properties': [{'value': 2110430409, 'name': 435956656}], 'min_byte1': 214, 'max_byte1': 217, 'max_char_or_byte2': 2479, 'default_char': 17041, 'min_char_or_byte2': 26638, 'draw_direction': 192, 'replies_hint': 1985190562, 'min_bounds': {'descent': -27837, 'ascent': -14775, 'character_width': -13026, 'left_side_bearing': -29767, 'right_side_bearing': -31908, 'attributes': 2465}, 'all_chars_exist': 0, 'name': 'fontfont', 'font_ascent': -30550, 'font_descent': -28978, 'max_bounds': {'descent': -20692, 'ascent': -6999, 'character_width': -15180, 'left_side_bearing': -7789, 'right_side_bearing': -5339, 'attributes': 1068}, } self.reply_bin_0 = '\x01\x08\x4e\x2e' '\x00\x00\x00\x0b' \ '\x8b\xb9\x83\x5c' '\xcd\x1e\xc6\x49' \ '\x93\x43\x09\xa1' '\x00\x00\x00\x00' \ '\xe1\x93\xeb\x25' '\xc4\xb4\xe4\xa9' \ '\xaf\x2c\x04\x2c' '\x00\x00\x00\x00' \ '\x68\x0e\x09\xaf' '\x42\x91\x00\x01' \ '\xc0\xd6\xd9\x00' '\x88\xaa\x8e\xce' \ '\x76\x53\x9a\xa2' '\x19\xfc\x2b\xb0' \ '\x7d\xca\x9c\xc9' '\x66\x6f\x6e\x74' \ '\x66\x6f\x6e\x74' def testPackRequest0(self): bin = apply(request.ListFontsWithInfo._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListFontsWithInfo._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetFontPath(unittest.TestCase): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } self.req_bin_0 = '\x33\x00\x00\x06' '\x00\x03\x00\x00' \ '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \ '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } self.req_bin_1 = '\x33\x00\x00\x02' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) class TestGetFontPath(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x34\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 21510, 'paths': ['path1', 'path2232'], } self.reply_bin_0 = '\x01\x00\x54\x06' '\x00\x00\x00\x04' \ '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x05\x70\x61\x74' '\x68\x31\x08\x70' \ '\x61\x74\x68\x32' '\x32\x33\x32\x00' self.reply_args_1 = { 'sequence_number': 62463, 'paths': [], } self.reply_bin_1 = '\x01\x00\xf3\xff' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetFontPath._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) class TestCreatePixmap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'height': 65515, 'drawable': 162261202, 'pid': 926490960, 'depth': 145, 'width': 5641, } self.req_bin_0 = '\x35\x91\x00\x04' '\x37\x39\x21\x50' \ '\x09\xab\xe8\xd2' '\x16\x09\xff\xeb' def testPackRequest0(self): bin = apply(request.CreatePixmap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreePixmap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'pixmap': 213012851, } self.req_bin_0 = '\x36\x00\x00\x02' '\x0c\xb2\x51\x73' def testPackRequest0(self): bin = apply(request.FreePixmap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cid': 1060658282, 'drawable': 456876463, 'attrs': {'dashes': 183, 'fill_rule': 0, 'clip_mask': 620422624, 'plane_mask': 1797423280, 'line_style': 1, 'tile': 77620460, 'arc_mode': 0, 'clip_y_origin': -7419, 'dash_offset': 62459, 'line_width': 50494, 'background': 44336037, 'clip_x_origin': -32045, 'join_style': 2, 'graphics_exposures': 0, 'font': 95118395, 'tile_stipple_y_origin': -17619, 'stipple': 631657813, 'fill_style': 0, 'cap_style': 0, 'subwindow_mode': 0, 'tile_stipple_x_origin': -12494, 'foreground': 2096879871, 'function': 10}, } self.req_bin_0 = '\x37\x00\x00\x1b' '\x3f\x38\x5c\x6a' \ '\x1b\x3b\x61\xaf' '\x00\x7f\xff\xff' \ '\x0a\x00\x00\x00' '\x6b\x22\x80\xb0' \ '\x7c\xfb\xd8\xff' '\x02\xa4\x83\xa5' \ '\xc5\x3e\x00\x00' '\x01\x00\x00\x00' \ '\x00\x00\x00\x00' '\x02\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x04\xa0\x64\xec' '\x25\xa6\x55\x55' \ '\xcf\x32\x00\x00' '\xbb\x2d\x00\x00' \ '\x05\xab\x64\x3b' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x82\xd3\x00\x00' \ '\xe3\x05\x00\x00' '\x24\xfa\xe5\xe0' \ '\xf3\xfb\x00\x00' '\xb7\x00\x00\x00' \ '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.CreateGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'attrs': {'dashes': 249, 'fill_rule': 1, 'clip_mask': 496525721, 'plane_mask': 1467281901, 'line_style': 2, 'tile': 1713935374, 'arc_mode': 0, 'clip_y_origin': -24572, 'dash_offset': 46636, 'line_width': 61036, 'background': 1598773587, 'clip_x_origin': -19725, 'join_style': 1, 'graphics_exposures': 0, 'font': 429323306, 'tile_stipple_y_origin': -11767, 'stipple': 1365263649, 'fill_style': 2, 'cap_style': 1, 'subwindow_mode': 1, 'tile_stipple_x_origin': -23501, 'foreground': 1272378077, 'function': 11}, 'gc': 518903558, } self.req_bin_0 = '\x38\x00\x00\x1a' '\x1e\xed\xd7\x06' \ '\x00\x7f\xff\xff' '\x0b\x00\x00\x00' \ '\x57\x74\xf1\xed' '\x4b\xd6\xf2\xdd' \ '\x5f\x4b\x59\x53' '\xee\x6c\x00\x00' \ '\x02\x00\x00\x00' '\x01\x00\x00\x00' \ '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ '\x01\x00\x00\x00' '\x66\x28\x94\x0e' \ '\x51\x60\x45\x21' '\xa4\x33\x00\x00' \ '\xd2\x09\x00\x00' '\x19\x96\xf4\x2a' \ '\x01\x00\x00\x00' '\x00\x00\x00\x00' \ '\xb2\xf3\x00\x00' '\xa0\x04\x00\x00' \ '\x1d\x98\x61\x99' '\xb6\x2c\x00\x00' \ '\xf9\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mask': 1039948946, 'src_gc': 1958847367, 'dst_gc': 1311353896, } self.req_bin_0 = '\x39\x00\x00\x04' '\x74\xc1\xa3\x87' \ '\x4e\x29\xac\x28' '\x3d\xfc\x5c\x92' def testPackRequest0(self): bin = apply(request.CopyGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetDashes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dashes': [169, 241, 158, 238, 173, 159, 182, 139, 139], 'dash_offset': 51693, 'gc': 1639787502, } self.req_bin_0 = '\x3a\x00\x00\x06' '\x61\xbd\x2b\xee' \ '\xc9\xed\x00\x09' '\xa9\xf1\x9e\xee' \ '\xad\x9f\xb6\x8b' '\x8b\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetDashes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetClipRectangles(unittest.TestCase): def setUp(self): self.req_args_0 = { 'rectangles': [{'height': 59391, 'x': -15430, 'width': 46673, 'y': -3009}, {'height': 9883, 'x': -14046, 'width': 7782, 'y': -24857}], 'gc': 1105675380, 'x_origin': -22760, 'y_origin': -16557, 'ordering': 3, } self.req_bin_0 = '\x3b\x03\x00\x07' '\x41\xe7\x44\x74' \ '\xa7\x18\xbf\x53' '\xc3\xba\xf4\x3f' \ '\xb6\x51\xe7\xff' '\xc9\x22\x9e\xe7' \ '\x1e\x66\x26\x9b' self.req_args_1 = { 'rectangles': [], 'gc': 291514811, 'x_origin': -29867, 'y_origin': -10293, 'ordering': 0, } self.req_bin_1 = '\x3b\x00\x00\x03' '\x11\x60\x29\xbb' \ '\x8b\x55\xd7\xcb' def testPackRequest0(self): bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) class TestFreeGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 371787524, } self.req_bin_0 = '\x3c\x00\x00\x02' '\x16\x29\x07\x04' def testPackRequest0(self): bin = apply(request.FreeGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestClearArea(unittest.TestCase): def setUp(self): self.req_args_0 = { 'exposures': 0, 'height': 53776, 'width': 63821, 'window': 1253992673, 'x': -1843, 'y': -32148, } self.req_bin_0 = '\x3d\x00\x00\x04' '\x4a\xbe\x68\xe1' \ '\xf8\xcd\x82\x6c' '\xf9\x4d\xd2\x10' def testPackRequest0(self): bin = apply(request.ClearArea._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyArea(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_drawable': 321720617, 'dst_drawable': 252019697, 'src_y': -8372, 'src_x': -25544, 'gc': 126071392, 'width': 49414, 'height': 61502, 'dst_x': -19068, 'dst_y': -4602, } self.req_bin_0 = '\x3e\x00\x00\x07' '\x13\x2d\x11\x29' \ '\x0f\x05\x83\xf1' '\x07\x83\xb2\x60' \ '\x9c\x38\xdf\x4c' '\xb5\x84\xee\x06' \ '\xc1\x06\xf0\x3e' def testPackRequest0(self): bin = apply(request.CopyArea._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyPlane(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_drawable': 1988650265, 'bit_plane': 2052065832, 'dst_drawable': 2120887972, 'src_y': -22401, 'src_x': -4542, 'gc': 1266180573, 'width': 41241, 'height': 33787, 'dst_x': -24940, 'dst_y': -13009, } self.req_bin_0 = '\x3f\x00\x00\x08' '\x76\x88\x65\x19' \ '\x7e\x6a\x2e\xa4' '\x4b\x78\x61\xdd' \ '\xee\x42\xa8\x7f' '\x9e\x94\xcd\x2f' \ '\xa1\x19\x83\xfb' '\x7a\x50\x0a\x28' def testPackRequest0(self): bin = apply(request.CopyPlane._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyPoint(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 206266633, 'points': [{'x': -22449, 'y': -16714}, {'x': -16465, 'y': -12850}, {'x': -19616, 'y': -13131}], 'drawable': 1008674, 'coord_mode': 1, } self.req_bin_0 = '\x40\x01\x00\x06' '\x00\x0f\x64\x22' \ '\x0c\x4b\x61\x09' '\xa8\x4f\xbe\xb6' \ '\xbf\xaf\xcd\xce' '\xb3\x60\xcc\xb5' def testPackRequest0(self): bin = apply(request.PolyPoint._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyLine(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 1355594189, 'points': [{'x': -11743, 'y': -18781}, {'x': -21373, 'y': -22722}, {'x': -17579, 'y': -13699}, {'x': -26545, 'y': -19353}, {'x': -11779, 'y': -26488}], 'drawable': 1668889192, 'coord_mode': 1, } self.req_bin_0 = '\x41\x01\x00\x08' '\x63\x79\x3a\x68' \ '\x50\xcc\xb9\xcd' '\xd2\x21\xb6\xa3' \ '\xac\x83\xa7\x3e' '\xbb\x55\xca\x7d' \ '\x98\x4f\xb4\x67' '\xd1\xfd\x98\x88' def testPackRequest0(self): bin = apply(request.PolyLine._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolySegment(unittest.TestCase): def setUp(self): self.req_args_0 = { 'segments': [{'y1': -24252, 'y2': -22523, 'x1': -12610, 'x2': -25770}], 'drawable': 146511635, 'gc': 53385255, } self.req_bin_0 = '\x42\x00\x00\x05' '\x08\xbb\x97\x13' \ '\x03\x2e\x98\x27' '\xce\xbe\xa1\x44' \ '\x9b\x56\xa8\x05' def testPackRequest0(self): bin = apply(request.PolySegment._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyRectangle(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 1927481661, 'gc': 410140275, 'rectangles': [{'height': 63567, 'x': -16992, 'width': 11122, 'y': -21320}, {'height': 34652, 'x': -18051, 'width': 59622, 'y': -30426}, {'height': 45646, 'x': -1111, 'width': 46231, 'y': -25261}], } self.req_bin_0 = '\x43\x00\x00\x09' '\x72\xe3\x09\x3d' \ '\x18\x72\x3e\x73' '\xbd\xa0\xac\xb8' \ '\x2b\x72\xf8\x4f' '\xb9\x7d\x89\x26' \ '\xe8\xe6\x87\x5c' '\xfb\xa9\x9d\x53' \ '\xb4\x97\xb2\x4e' def testPackRequest0(self): bin = apply(request.PolyRectangle._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyArc(unittest.TestCase): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 37549, 'angle1': -16979, 'x': -4943, 'angle2': -25650, 'width': 65448, 'y': -9205}, {'height': 9322, 'angle1': -20781, 'x': -13865, 'angle2': -8498, 'width': 62173, 'y': -22862}, {'height': 63266, 'angle1': -1231, 'x': -12693, 'angle2': -809, 'width': 63732, 'y': -7550}], 'drawable': 718777148, 'gc': 1127021391, } self.req_bin_0 = '\x44\x00\x00\x0c' '\x2a\xd7\xab\x3c' \ '\x43\x2c\xfb\x4f' '\xec\xb1\xdc\x0b' \ '\xff\xa8\x92\xad' '\xbd\xad\x9b\xce' \ '\xc9\xd7\xa6\xb2' '\xf2\xdd\x24\x6a' \ '\xae\xd3\xde\xce' '\xce\x6b\xe2\x82' \ '\xf8\xf4\xf7\x22' '\xfb\x31\xfc\xd7' def testPackRequest0(self): bin = apply(request.PolyArc._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFillPoly(unittest.TestCase): def setUp(self): self.req_args_0 = { 'shape': 1, 'gc': 1070496026, 'points': [{'x': -18749, 'y': -19415}, {'x': -8904, 'y': -26948}, {'x': -13336, 'y': -9462}], 'drawable': 1326525185, 'coord_mode': 0, } self.req_bin_0 = '\x45\x00\x00\x07' '\x4f\x11\x2b\x01' \ '\x3f\xce\x79\x1a' '\x01\x00\x00\x00' \ '\xb6\xc3\xb4\x29' '\xdd\x38\x96\xbc' \ '\xcb\xe8\xdb\x0a' def testPackRequest0(self): bin = apply(request.FillPoly._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyFillRectangle(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 1708671692, 'gc': 1965498255, 'rectangles': [{'height': 36920, 'x': -2965, 'width': 26437, 'y': -3568}, {'height': 44383, 'x': -18327, 'width': 37730, 'y': -26752}], } self.req_bin_0 = '\x46\x00\x00\x07' '\x65\xd8\x42\xcc' \ '\x75\x27\x1f\x8f' '\xf4\x6b\xf2\x10' \ '\x67\x45\x90\x38' '\xb8\x69\x97\x80' \ '\x93\x62\xad\x5f' def testPackRequest0(self): bin = apply(request.PolyFillRectangle._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyFillArc(unittest.TestCase): def setUp(self): self.req_args_0 = { 'arcs': [{'height': 64114, 'angle1': -28360, 'x': -10754, 'angle2': -6712, 'width': 53819, 'y': -19555}], 'drawable': 2083870696, 'gc': 414470877, } self.req_bin_0 = '\x47\x00\x00\x06' '\x7c\x35\x57\xe8' \ '\x18\xb4\x52\xdd' '\xd5\xfe\xb3\x9d' \ '\xd2\x3b\xfa\x72' '\x91\x38\xe5\xc8' def testPackRequest0(self): bin = apply(request.PolyFillArc._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPutImage(unittest.TestCase): def setUp(self): self.req_args_0 = { 'height': 9883, 'data': 'bit map data', 'drawable': 1534678783, 'left_pad': 147, 'format': 1, 'dst_x': -3284, 'gc': 209913475, 'depth': 173, 'width': 62850, 'dst_y': -30693, } self.req_bin_0 = '\x48\x01\x00\x09' '\x5b\x79\x56\xff' \ '\x0c\x83\x06\x83' '\xf5\x82\x26\x9b' \ '\xf3\x2c\x88\x1b' '\x93\xad\x00\x00' \ '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \ '\x64\x61\x74\x61' def testPackRequest0(self): bin = apply(request.PutImage._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetImage(unittest.TestCase): def setUp(self): self.req_args_0 = { 'height': 42657, 'plane_mask': 1756278272, 'drawable': 1329487747, 'x': -27672, 'y': -30859, 'format': 1, 'width': 58993, } self.req_bin_0 = '\x49\x01\x00\x05' '\x4f\x3e\x5f\x83' \ '\x93\xe8\x87\x75' '\xe6\x71\xa6\xa1' \ '\x68\xae\xae\x00' self.reply_args_0 = { 'sequence_number': 54997, 'data': 'this is real ly imag e b-map', 'visual': 1108632607, 'depth': 181, } self.reply_bin_0 = '\x01\xb5\xd6\xd5' '\x00\x00\x00\x07' \ '\x42\x14\x64\x1f' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x74\x68\x69\x73' '\x20\x69\x73\x20' \ '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \ '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \ '\x2d\x6d\x61\x70' def testPackRequest0(self): bin = apply(request.GetImage._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetImage._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestPolyText8(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 1481564777, 'x': -13548, 'drawable': 1550998666, 'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}], 'y': -8902, } self.req_bin_0 = '\x4a\x00\x00\x08' '\x5c\x72\x5c\x8a' \ '\x58\x4e\xe2\x69' '\xcb\x14\xdd\x3a' \ '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \ '\x03\x04\x02\x00' '\x69\x65\x00\x00' def testPackRequest0(self): bin = apply(request.PolyText8._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyText16(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 400697368, 'x': -31614, 'drawable': 1591407092, 'items': [{'delta': 2, 'string': (4131, 18)}, 16909060], 'y': -2741, } self.req_bin_0 = '\x4b\x00\x00\x07' '\x5e\xda\xf1\xf4' \ '\x17\xe2\x28\x18' '\x84\x82\xf5\x4b' \ '\x02\x02\x10\x23' '\x00\x12\xff\x01' \ '\x02\x03\x04\x00' def testPackRequest0(self): bin = apply(request.PolyText16._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestImageText8(unittest.TestCase): def setUp(self): self.req_args_0 = { 'string': 'showme', 'gc': 1393590305, 'drawable': 1823595869, 'x': -16077, 'y': -4873, } self.req_bin_0 = '\x4c\x06\x00\x06' '\x6c\xb1\xdd\x5d' \ '\x53\x10\x80\x21' '\xc1\x33\xec\xf7' \ '\x73\x68\x6f\x77' '\x6d\x65\x00\x00' def testPackRequest0(self): bin = apply(request.ImageText8._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestImageText16(unittest.TestCase): def setUp(self): self.req_args_0 = { 'string': (115, 104, 111, 119, 109, 111, 114, 101), 'gc': 1702299870, 'drawable': 33607184, 'x': -21343, 'y': -24237, } self.req_bin_0 = '\x4d\x08\x00\x08' '\x02\x00\xce\x10' \ '\x65\x77\x08\xde' '\xac\xa1\xa1\x53' \ '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \ '\x00\x6d\x00\x6f' '\x00\x72\x00\x65' def testPackRequest0(self): bin = apply(request.ImageText16._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mid': 157536683, 'alloc': 0, 'visual': 813982403, 'window': 698475631, } self.req_bin_0 = '\x4e\x00\x00\x04' '\x09\x63\xd1\xab' \ '\x29\xa1\xe4\x6f' '\x30\x84\x62\xc3' def testPackRequest0(self): bin = apply(request.CreateColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreeColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1296514923, } self.req_bin_0 = '\x4f\x00\x00\x02' '\x4d\x47\x3f\x6b' def testPackRequest0(self): bin = apply(request.FreeColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyColormapAndFree(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_cmap': 1049336329, 'mid': 1237242690, } self.req_bin_0 = '\x50\x00\x00\x03' '\x49\xbe\xd3\x42' \ '\x3e\x8b\x9a\x09' def testPackRequest0(self): bin = apply(request.CopyColormapAndFree._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestInstallColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1539075582, } self.req_bin_0 = '\x51\x00\x00\x02' '\x5b\xbc\x6d\xfe' def testPackRequest0(self): bin = apply(request.InstallColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUninstallColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 959493342, } self.req_bin_0 = '\x52\x00\x00\x02' '\x39\x30\xb4\xde' def testPackRequest0(self): bin = apply(request.UninstallColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestListInstalledColormaps(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1517864638, } self.req_bin_0 = '\x53\x00\x00\x02' '\x5a\x78\xc6\xbe' self.reply_args_0 = { 'cmaps': [2146327722, 1361260227], 'sequence_number': 61652, } self.reply_bin_0 = '\x01\x00\xf0\xd4' '\x00\x00\x00\x02' \ '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x7f\xee\x5c\xaa' '\x51\x23\x2e\xc3' def testPackRequest0(self): bin = apply(request.ListInstalledColormaps._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListInstalledColormaps._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'red': 39725, 'green': 49854, 'cmap': 523356125, 'blue': 49580, } self.req_bin_0 = '\x54\x00\x00\x04' '\x1f\x31\xc7\xdd' \ '\x9b\x2d\xc2\xbe' '\xc1\xac\x00\x00' self.reply_args_0 = { 'sequence_number': 10904, 'red': 43784, 'green': 3170, 'pixel': 1067923656, 'blue': 14525, } self.reply_bin_0 = '\x01\x00\x2a\x98' '\x00\x00\x00\x00' \ '\xab\x08\x0c\x62' '\x38\xbd\x00\x00' \ '\x3f\xa7\x38\xc8' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocNamedColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 128217824, 'name': 'octarin', } self.req_bin_0 = '\x55\x00\x00\x05' '\x07\xa4\x72\xe0' \ '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \ '\x72\x69\x6e\x00' self.reply_args_0 = { 'sequence_number': 19971, 'pixel': 1324239222, 'screen_green': 50499, 'screen_red': 33379, 'exact_green': 29067, 'exact_blue': 58811, 'screen_blue': 43109, 'exact_red': 64213, } self.reply_bin_0 = '\x01\x00\x4e\x03' '\x00\x00\x00\x00' \ '\x4e\xee\x49\x76' '\xfa\xd5\x71\x8b' \ '\xe5\xbb\x82\x63' '\xc5\x43\xa8\x65' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocNamedColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocNamedColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocColorCells(unittest.TestCase): def setUp(self): self.req_args_0 = { 'planes': 32867, 'colors': 58698, 'cmap': 675372338, 'contiguous': 1, } self.req_bin_0 = '\x56\x01\x00\x03' '\x28\x41\x5d\x32' \ '\xe5\x4a\x80\x63' self.reply_args_0 = { 'masks': [733927381, 1023311668, 595898647], 'pixels': [693075497, 1294879029, 1478712895, 1781963728, 1442185575, 1654003869, 787619123, 1049825849, 1773935772, 1689075922, 1626562257, 177731275, 661046122, 1970509470, 1918486395, 688539096, 41044851], 'sequence_number': 54025, } self.reply_bin_0 = '\x01\x00\xd3\x09' '\x00\x00\x00\x14' \ '\x00\x11\x00\x03' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x29\x4f\x7e\x29' '\x4d\x2e\x49\x35' \ '\x58\x23\x5e\x3f' '\x6a\x36\x9b\xd0' \ '\x55\xf6\x01\x67' '\x62\x96\x18\x9d' \ '\x2e\xf2\x1d\x33' '\x3e\x93\x12\x39' \ '\x69\xbc\x1c\x9c' '\x64\xad\x40\xd2' \ '\x60\xf3\x5e\xd1' '\x0a\x97\xf6\xcb' \ '\x27\x66\xc3\x6a' '\x75\x73\x96\x9e' \ '\x72\x59\xc7\x7b' '\x29\x0a\x45\xd8' \ '\x02\x72\x4b\x73' '\x2b\xbe\xd7\xd5' \ '\x3c\xfe\x7f\x34' '\x23\x84\xb1\x17' self.reply_args_1 = { 'masks': [], 'pixels': [], 'sequence_number': 6273, } self.reply_bin_1 = '\x01\x00\x18\x81' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocColorCells._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) class TestAllocColorPlanes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'red': 22876, 'colors': 58275, 'green': 9425, 'cmap': 308019811, 'contiguous': 0, 'blue': 23880, } self.req_bin_0 = '\x57\x00\x00\x04' '\x12\x5c\x02\x63' \ '\xe3\xa3\x59\x5c' '\x24\xd1\x5d\x48' self.reply_args_0 = { 'green_mask': 265888391, 'sequence_number': 36175, 'pixels': [491961865, 1301906366, 1604705021, 1418751120], 'blue_mask': 44676180, 'red_mask': 734623206, } self.reply_bin_0 = '\x01\x00\x8d\x4f' '\x00\x00\x00\x04' \ '\x00\x04\x00\x00' '\x2b\xc9\x75\xe6' \ '\x0f\xd9\x22\x87' '\x02\xa9\xb4\x54' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x1d\x52\xbe\x09' '\x4d\x99\x83\xbe' \ '\x5f\xa5\xda\xfd' '\x54\x90\x6c\x90' def testPackRequest0(self): bin = apply(request.AllocColorPlanes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColorPlanes._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestFreeColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 727008216, 'pixels': [61281082, 398475082, 1660604639, 1516738417, 1211104329, 105034864, 884930615, 902914796, 288637231, 2097165249, 1171127263, 1027274519, 806213035, 1485898709, 542709465, 169067149, 1230881159], 'plane_mask': 1204733200, } self.req_bin_0 = '\x58\x00\x00\x14' '\x2b\x55\x43\xd8' \ '\x47\xce\xc5\x10' '\x03\xa7\x13\x3a' \ '\x17\xc0\x3f\x4a' '\x62\xfa\xd0\xdf' \ '\x5a\x67\x97\x71' '\x48\x2f\xfc\x49' \ '\x06\x42\xb4\x70' '\x34\xbe\xf8\x37' \ '\x35\xd1\x62\xec' '\x11\x34\x41\x2f' \ '\x7d\x00\x33\xc1' '\x45\xcd\xfb\xdf' \ '\x3d\x3a\xf7\x17' '\x30\x0d\xd5\xab' \ '\x58\x91\x03\xd5' '\x20\x59\x16\xd9' \ '\x0a\x13\xc2\x8d' '\x49\x5d\xc1\x87' def testPackRequest0(self): bin = apply(request.FreeColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestStoreColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 501035281, 'items': [{'red': 27925, 'pixel': 1094971765, 'green': 3673, 'flags': 189, 'blue': 31593}, {'red': 41633, 'pixel': 1330003189, 'green': 56186, 'flags': 178, 'blue': 30263}, {'red': 36007, 'pixel': 1813524037, 'green': 29697, 'flags': 224, 'blue': 14071}, {'red': 45716, 'pixel': 1987610486, 'green': 55405, 'flags': 200, 'blue': 35734}], } self.req_bin_0 = '\x59\x00\x00\x0e' '\x1d\xdd\x31\x11' \ '\x41\x43\xf1\x75' '\x6d\x15\x0e\x59' \ '\x7b\x69\xbd\x00' '\x4f\x46\x3c\xf5' \ '\xa2\xa1\xdb\x7a' '\x76\x37\xb2\x00' \ '\x6c\x18\x2e\x45' '\x8c\xa7\x74\x01' \ '\x36\xf7\xe0\x00' '\x76\x78\x87\x76' \ '\xb2\x94\xd8\x6d' '\x8b\x96\xc8\x00' def testPackRequest0(self): bin = apply(request.StoreColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestStoreNamedColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'name': 'blue', 'flags': 186, 'cmap': 2061119590, 'pixel': 1846011298, } self.req_bin_0 = '\x5a\xba\x00\x05' '\x7a\xda\x30\x66' \ '\x6e\x07\xe5\xa2' '\x00\x04\x00\x00' \ '\x62\x6c\x75\x65' def testPackRequest0(self): bin = apply(request.StoreNamedColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 596369797, 'pixels': [1018587496, 1553480933, 952694607, 341816269, 306591348, 1178729919, 173027853, 875811363], } self.req_bin_0 = '\x5b\x00\x00\x0a' '\x23\x8b\xe1\x85' \ '\x3c\xb6\x69\x68' '\x5c\x98\x3c\xe5' \ '\x38\xc8\xf7\x4f' '\x14\x5f\xb3\xcd' \ '\x12\x46\x36\x74' '\x46\x41\xfd\xbf' \ '\x0a\x50\x32\x0d' '\x34\x33\xd2\x23' self.reply_args_0 = { 'colors': [{'red': 6715, 'blue': 40144, 'green': 56664}, {'red': 5799, 'blue': 22078, 'green': 35523}, {'red': 60111, 'blue': 58654, 'green': 25206}, {'red': 7433, 'blue': 60908, 'green': 14468}, {'red': 31213, 'blue': 9298, 'green': 27481}], 'sequence_number': 60323, } self.reply_bin_0 = '\x01\x00\xeb\xa3' '\x00\x00\x00\x0a' \ '\x00\x05\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x1a\x3b\xdd\x58' '\x9c\xd0\x00\x00' \ '\x16\xa7\x8a\xc3' '\x56\x3e\x00\x00' \ '\xea\xcf\x62\x76' '\xe5\x1e\x00\x00' \ '\x1d\x09\x38\x84' '\xed\xec\x00\x00' \ '\x79\xed\x6b\x59' '\x24\x52\x00\x00' self.req_args_1 = { 'cmap': 79317049, 'pixels': [], } self.req_bin_1 = '\x5b\x00\x00\x02' '\x04\xba\x48\x39' def testPackRequest0(self): bin = apply(request.QueryColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.QueryColors._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryColors._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestLookupColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 789574750, 'name': 'octarin', } self.req_bin_0 = '\x5c\x00\x00\x05' '\x2f\x0f\xf4\x5e' \ '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \ '\x72\x69\x6e\x00' self.reply_args_0 = { 'sequence_number': 21040, 'screen_green': 65314, 'screen_red': 51033, 'exact_green': 59546, 'exact_blue': 61512, 'screen_blue': 29893, 'exact_red': 41875, } self.reply_bin_0 = '\x01\x00\x52\x30' '\x00\x00\x00\x00' \ '\xa3\x93\xe8\x9a' '\xf0\x48\xc7\x59' \ '\xff\x22\x74\xc5' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.LookupColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.LookupColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestCreateCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'x': 14199, 'fore_red': 65323, 'back_green': 5090, 'mask': 420188900, 'back_blue': 49879, 'y': 32780, 'cid': 2022028217, 'fore_blue': 63540, 'fore_green': 43028, 'back_red': 31899, 'source': 794739749, } self.req_bin_0 = '\x5d\x00\x00\x08' '\x78\x85\xb3\xb9' \ '\x2f\x5e\xc4\x25' '\x19\x0b\x92\xe4' \ '\xff\x2b\xa8\x14' '\xf8\x34\x7c\x9b' \ '\x13\xe2\xc2\xd7' '\x37\x77\x80\x0c' def testPackRequest0(self): bin = apply(request.CreateCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateGlyphCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'fore_red': 56306, 'source_char': 7568, 'mask': 2018599719, 'back_blue': 6500, 'cid': 1999539964, 'mask_char': 46124, 'fore_blue': 30793, 'fore_green': 16989, 'back_red': 64484, 'source': 1412345132, 'back_green': 52966, } self.req_bin_0 = '\x5e\x00\x00\x08' '\x77\x2e\x8e\xfc' \ '\x54\x2e\xad\x2c' '\x78\x51\x63\x27' \ '\x1d\x90\xb4\x2c' '\xdb\xf2\x42\x5d' \ '\x78\x49\xfb\xe4' '\xce\xe6\x19\x64' def testPackRequest0(self): bin = apply(request.CreateGlyphCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreeCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 553262138, } self.req_bin_0 = '\x5f\x00\x00\x02' '\x20\xfa\x1c\x3a' def testPackRequest0(self): bin = apply(request.FreeCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestRecolorCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'fore_red': 44718, 'fore_green': 33104, 'back_blue': 49533, 'back_green': 12163, 'fore_blue': 17246, 'back_red': 64013, 'cursor': 295995276, } self.req_bin_0 = '\x60\x00\x00\x05' '\x11\xa4\x87\x8c' \ '\xae\xae\x81\x50' '\x43\x5e\xfa\x0d' \ '\x2f\x83\xc1\x7d' def testPackRequest0(self): bin = apply(request.RecolorCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryBestSize(unittest.TestCase): def setUp(self): self.req_args_0 = { 'height': 34743, 'drawable': 503496990, 'item_class': 1, 'width': 27916, } self.req_bin_0 = '\x61\x01\x00\x03' '\x1e\x02\xc1\x1e' \ '\x6d\x0c\x87\xb7' self.reply_args_0 = { 'height': 60728, 'sequence_number': 34070, 'width': 35970, } self.reply_bin_0 = '\x01\x00\x85\x16' '\x00\x00\x00\x00' \ '\x8c\x82\xed\x38' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryBestSize._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryBestSize._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryExtension(unittest.TestCase): def setUp(self): self.req_args_0 = { 'name': 'XTRA', } self.req_bin_0 = '\x62\x00\x00\x03' '\x00\x04\x00\x00' \ '\x58\x54\x52\x41' self.reply_args_0 = { 'sequence_number': 39952, 'major_opcode': 195, 'first_error': 150, 'present': 1, 'first_event': 202, } self.reply_bin_0 = '\x01\x00\x9c\x10' '\x00\x00\x00\x00' \ '\x01\xc3\xca\x96' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryExtension._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryExtension._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListExtensions(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x63\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 20200, 'names': ['XTRA', 'XTRA-II'], } self.reply_bin_0 = '\x01\x02\x4e\xe8' '\x00\x00\x00\x04' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x04\x58\x54\x52' '\x41\x07\x58\x54' \ '\x52\x41\x2d\x49' '\x49\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ListExtensions._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListExtensions._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeKeyboardMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'keysyms': [[707837223, 99294840, 1205405602], [67157514, 879853050, 2059131033], [1139736188, 578113249, 1525786315], [1335349176, 246731334, 277761436], [1386594542, 1676932187, 1862777168], [535892916, 342718655, 195574000], [5712156, 1820472637, 848853860], [1123197289, 1664064022, 94999154], [380150420, 402902535, 1061375041], [510686316, 502245882, 422893644], [1423643601, 194077695, 403885178], [1571826296, 529249772, 623556591], [720045879, 37553034, 955963792], [513407882, 861125615, 219940695], [184890179, 472466494, 1649347894], [1679171989, 1991748404, 1674460475], [1762342934, 276695222, 1941684480], [886658026, 1860690072, 577030090], [227169721, 1390318675, 321524615], [2144591365, 545119116, 404205206]], 'first_keycode': 250, } self.req_bin_0 = '\x64\x14\x00\x3e' '\xfa\x03\x00\x00' \ '\x2a\x30\xbd\x27' '\x05\xeb\x1e\x78' \ '\x47\xd9\x07\xa2' '\x04\x00\xbe\x0a' \ '\x34\x71\x7d\xfa' '\x7a\xbb\xd8\x99' \ '\x43\xee\xfe\x7c' '\x22\x75\x4e\xe1' \ '\x5a\xf1\xa6\xcb' '\x4f\x97\xcf\xb8' \ '\x0e\xb4\xd2\x46' '\x10\x8e\x4d\x9c' \ '\x52\xa5\xc0\xee' '\x63\xf3\xf4\x5b' \ '\x6f\x07\xb9\x50' '\x1f\xf1\x13\xb4' \ '\x14\x6d\x78\xbf' '\x0b\xa8\x38\xf0' \ '\x00\x57\x29\x1c' '\x6c\x82\x35\x3d' \ '\x32\x98\x7b\x64' '\x42\xf2\xa1\x69' \ '\x63\x2f\x9a\x16' '\x05\xa9\x92\x72' \ '\x16\xa8\xa2\x94' '\x18\x03\xce\x07' \ '\x3f\x43\x4c\x41' '\x1e\x70\x74\x6c' \ '\x1d\xef\xa9\xfa' '\x19\x34\xd8\x4c' \ '\x54\xdb\x13\xd1' '\x0b\x91\x63\xff' \ '\x18\x12\xcc\x7a' '\x5d\xb0\x2a\x78' \ '\x1f\x8b\xb5\xec' '\x25\x2a\xb7\xef' \ '\x2a\xeb\x07\x37' '\x02\x3d\x03\x8a' \ '\x38\xfa\xd9\x90' '\x1e\x99\xfb\x8a' \ '\x33\x53\xbb\xef' '\x0d\x1c\x07\x57' \ '\x0b\x05\x33\x43' '\x1c\x29\x44\x3e' \ '\x62\x4f\x0d\x36' '\x64\x16\x21\x95' \ '\x76\xb7\xab\x34' '\x63\xce\x3d\x3b' \ '\x69\x0b\x38\x16' '\x10\x7e\x08\xb6' \ '\x73\xbb\xc1\x00' '\x34\xd9\x53\xea' \ '\x6e\xe7\xe0\x98' '\x22\x64\xc7\xca' \ '\x0d\x8a\x55\xb9' '\x52\xde\x94\x53' \ '\x13\x2a\x13\x87' '\x7f\xd3\xde\x05' \ '\x20\x7d\xdb\x8c' '\x18\x17\xae\x96' def testPackRequest0(self): bin = apply(request.ChangeKeyboardMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetKeyboardMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'count': 131, 'first_keycode': 206, } self.req_bin_0 = '\x65\x00\x00\x02' '\xce\x83\x00\x00' self.reply_args_0 = { 'keysyms': [[1550369014, 1683205347, 1879538861], [452613596, 1132022246, 357271408], [528724632, 2118423140, 640580111], [1981239140, 195173082, 497130901], [2001675011, 809172000, 1577756130], [739794769, 1774524806, 787951551], [1784021539, 1998872082, 1747812414], [396316053, 1525431160, 1808906812], [1676662850, 1222579650, 1205117622], [396026453, 1956747483, 1762026309], [1222502216, 1488139702, 1799119214], [1504675136, 1414564657, 419659384], [1934768917, 2095924224, 590955729], [582168798, 383228141, 1552516537], [1482483262, 1041896520, 1047041873], [1932705867, 292473490, 226147737], [780322016, 1965031752, 1481062205], [89811542, 1313413666, 686267194], [237776128, 1310737228, 792176733], [849034415, 1592538831, 837355505]], 'sequence_number': 61409, } self.reply_bin_0 = '\x01\x03\xef\xe1' '\x00\x00\x00\x3c' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x5c\x68\xc0\xf6' '\x64\x53\xac\xe3' \ '\x70\x07\x7c\xad' '\x1a\xfa\x55\xdc' \ '\x43\x79\x49\xe6' '\x15\x4b\x87\x70' \ '\x1f\x83\xb2\x98' '\x7e\x44\x92\x64' \ '\x26\x2e\x7a\x0f' '\x76\x17\x4f\x64' \ '\x0b\xa2\x1a\xda' '\x1d\xa1\x9d\x95' \ '\x77\x4f\x23\x03' '\x30\x3a\xfc\x20' \ '\x5e\x0a\xa5\xe2' '\x2c\x18\x5f\x51' \ '\x69\xc5\x19\x86' '\x2e\xf7\x2f\xbf' \ '\x6a\x56\x02\x23' '\x77\x24\x5e\x12' \ '\x68\x2d\x80\x3e' '\x17\x9f\x4d\x95' \ '\x5a\xec\x3b\x78' '\x6b\xd1\xba\x3c' \ '\x63\xef\xd8\x42' '\x48\xdf\x15\xc2' \ '\x47\xd4\xa2\xb6' '\x17\x9a\xe2\x55' \ '\x74\xa1\x98\xdb' '\x69\x06\x63\x45' \ '\x48\xdd\xe7\x48' '\x58\xb3\x35\xb6' \ '\x6b\x3c\x61\x6e' '\x59\xaf\x85\x40' \ '\x54\x50\x8b\x31' '\x19\x03\x7e\x78' \ '\x73\x52\x3b\x15' '\x7c\xed\x44\x00' \ '\x23\x39\x44\xd1' '\x22\xb3\x30\xde' \ '\x16\xd7\x98\xed' '\x5c\x89\x85\xb9' \ '\x58\x5c\xe6\x3e' '\x3e\x1a\x14\x48' \ '\x3e\x68\x97\x51' '\x73\x32\xc0\x4b' \ '\x11\x6e\xca\x92' '\x0d\x7a\xbd\x99' \ '\x2e\x82\xc4\xe0' '\x75\x20\x01\x48' \ '\x58\x47\x37\x3d' '\x05\x5a\x6a\x56' \ '\x4e\x49\x1a\x22' '\x28\xe7\x9b\x3a' \ '\x0e\x2c\x2d\x00' '\x4e\x20\x43\x4c' \ '\x2f\x37\xa8\x5d' '\x32\x9b\x3c\xaf' \ '\x5e\xec\x36\xcf' '\x31\xe9\x07\xf1' def testPackRequest0(self): bin = apply(request.GetKeyboardMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetKeyboardMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeKeyboardControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'attrs': {'key_click_percent': -35, 'bell_percent': -53, 'led_mode': 1, 'bell_pitch': -17390, 'auto_repeat_mode': 2, 'bell_duration': -30281, 'key': 235, 'led': 192}, } self.req_bin_0 = '\x66\x00\x00\x0a' '\x00\x00\x00\xff' \ '\xdd\x00\x00\x00' '\xcb\x00\x00\x00' \ '\xbc\x12\x00\x00' '\x89\xb7\x00\x00' \ '\xc0\x00\x00\x00' '\x01\x00\x00\x00' \ '\xeb\x00\x00\x00' '\x02\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeKeyboardControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetKeyboardControl(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x67\x00\x00\x01' self.reply_args_0 = { 'key_click_percent': 206, 'sequence_number': 30149, 'bell_percent': 251, 'bell_pitch': 13779, 'auto_repeats': [217, 171, 167, 167, 243, 163, 129, 239, 168, 153, 225, 199, 189, 155, 228, 149, 148, 237, 139, 150, 211, 133, 135, 250, 191, 166, 146, 212, 239, 183, 214, 250], 'global_auto_repeat': 0, 'led_mask': 438224369, 'bell_duration': 20235, } self.reply_bin_0 = '\x01\x00\x75\xc5' '\x00\x00\x00\x05' \ '\x1a\x1e\xc5\xf1' '\xce\xfb\x35\xd3' \ '\x4f\x0b\x00\x00' '\xd9\xab\xa7\xa7' \ '\xf3\xa3\x81\xef' '\xa8\x99\xe1\xc7' \ '\xbd\x9b\xe4\x95' '\x94\xed\x8b\x96' \ '\xd3\x85\x87\xfa' '\xbf\xa6\x92\xd4' \ '\xef\xb7\xd6\xfa' def testPackRequest0(self): bin = apply(request.GetKeyboardControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetKeyboardControl._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestBell(unittest.TestCase): def setUp(self): self.req_args_0 = { 'percent': -19, } self.req_bin_0 = '\x68\xed\x00\x01' def testPackRequest0(self): bin = apply(request.Bell._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangePointerControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'accel_denum': -32484, 'accel_num': -9346, 'do_accel': 0, 'do_thresh': 0, 'threshold': -8309, } self.req_bin_0 = '\x69\x00\x00\x03' '\xdb\x7e\x81\x1c' \ '\xdf\x8b\x00\x00' def testPackRequest0(self): bin = apply(request.ChangePointerControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetPointerControl(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6a\x00\x00\x01' self.reply_args_0 = { 'accel_denom': 63793, 'sequence_number': 59946, 'threshold': 46060, 'accel_num': 53419, } self.reply_bin_0 = '\x01\x00\xea\x2a' '\x00\x00\x00\x00' \ '\xd0\xab\xf9\x31' '\xb3\xec\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetPointerControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetPointerControl._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { 'allow_exposures': 0, 'timeout': -12675, 'interval': -12318, 'prefer_blank': 2, } self.req_bin_0 = '\x6b\x00\x00\x03' '\xce\x7d\xcf\xe2' \ '\x02\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6c\x00\x00\x01' self.reply_args_0 = { 'allow_exposures': 1, 'timeout': 1865, 'sequence_number': 14674, 'prefer_blanking': 1, 'interval': 60559, } self.reply_bin_0 = '\x01\x00\x39\x52' '\x00\x00\x00\x00' \ '\x07\x49\xec\x8f' '\x01\x01\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetScreenSaver._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeHosts(unittest.TestCase): def setUp(self): self.req_args_0 = { 'host': [188, 226, 135, 199], 'mode': 1, 'host_family': 1, } self.req_bin_0 = '\x6d\x01\x00\x03' '\x01\x00\x00\x04' \ '\xbc\xe2\x87\xc7' def testPackRequest0(self): bin = apply(request.ChangeHosts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestListHosts(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6e\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 31662, 'mode': 1, 'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}], } self.reply_bin_0 = '\x01\x01\x7b\xae' '\x00\x00\x00\x04' \ '\x00\x02\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x04' '\x22\x17\xb2\x0c' \ '\x00\x00\x00\x04' '\x82\xec\xfe\x0f' def testPackRequest0(self): bin = apply(request.ListHosts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListHosts._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetAccessControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 0, } self.req_bin_0 = '\x6f\x00\x00\x01' def testPackRequest0(self): bin = apply(request.SetAccessControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetCloseDownMode(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 0, } self.req_bin_0 = '\x70\x00\x00\x01' def testPackRequest0(self): bin = apply(request.SetCloseDownMode._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestKillClient(unittest.TestCase): def setUp(self): self.req_args_0 = { 'resource': 1679944210, } self.req_bin_0 = '\x71\x00\x00\x02' '\x64\x21\xea\x12' def testPackRequest0(self): bin = apply(request.KillClient._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestRotateProperties(unittest.TestCase): def setUp(self): self.req_args_0 = { 'delta': -27095, 'window': 109899869, 'properties': [1758270592, 1474783027, 1362037883, 19212066, 1095428186, 1435857629, 337040311, 1202859364, 1426187239, 725785004, 1722986690, 435243112], } self.req_bin_0 = '\x72\x00\x00\x0f' '\x06\x8c\xf0\x5d' \ '\x00\x0c\x96\x29' '\x68\xcd\x14\x80' \ '\x57\xe7\x67\x33' '\x51\x2f\x0c\x7b' \ '\x01\x25\x27\x22' '\x41\x4a\xe8\x5a' \ '\x55\x95\x72\xdd' '\x14\x16\xd3\xb7' \ '\x47\xb2\x2d\x64' '\x55\x01\xe3\xe7' \ '\x2b\x42\x99\xac' '\x66\xb2\xb0\xc2' \ '\x19\xf1\x48\x68' def testPackRequest0(self): bin = apply(request.RotateProperties._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestForceScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = '\x73\x01\x00\x01' def testPackRequest0(self): bin = apply(request.ForceScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetPointerMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'map': [218, 142, 195, 250, 194], } self.req_bin_0 = '\x74\x05\x00\x03' '\xda\x8e\xc3\xfa' \ '\xc2\x00\x00\x00' self.reply_args_0 = { 'sequence_number': 11995, 'status': 187, } self.reply_bin_0 = '\x01\xbb\x2e\xdb' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetPointerMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.SetPointerMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetPointerMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x75\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 35825, 'map': [165, 233, 136, 197, 230], } self.reply_bin_0 = '\x01\x05\x8b\xf1' '\x00\x00\x00\x02' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\xa5\xe9\x88\xc5' '\xe6\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetPointerMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetPointerMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetModifierMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'keycodes': [[72, 169], [161, 154], [26, 10], [108, 187], [110, 198], [225, 88], [33, 66], [189, 147]], } self.req_bin_0 = '\x76\x02\x00\x05' '\x48\xa9\xa1\x9a' \ '\x1a\x0a\x6c\xbb' '\x6e\xc6\xe1\x58' \ '\x21\x42\xbd\x93' self.reply_args_0 = { 'sequence_number': 44526, 'status': 188, } self.reply_bin_0 = '\x01\xbc\xad\xee' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetModifierMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.SetModifierMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetModifierMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x77\x00\x00\x01' self.reply_args_0 = { 'sequence_number': 58377, 'keycodes': [[3, 183], [213, 173], [9, 97], [35, 60], [249, 78], [175, 62], [237, 11], [26, 119]], } self.reply_bin_0 = '\x01\x02\xe4\x09' '\x00\x00\x00\x04' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x03\xb7\xd5\xad' '\x09\x61\x23\x3c' \ '\xf9\x4e\xaf\x3e' '\xed\x0b\x1a\x77' def testPackRequest0(self): bin = apply(request.GetModifierMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetModifierMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestNoOperation(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x7f\x00\x00\x01' def testPackRequest0(self): bin = apply(request.NoOperation._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) if __name__ == "__main__": check_endian() unittest.main() python-xlib-0.14+20091101/test/gen/0000755000175000017500000000000011273361453015067 5ustar stewstewpython-xlib-0.14+20091101/test/gen/protdef0000644000175000017500000004756407436416254016503 0ustar stewstewRESOURCEREQUEST GetWindowAttributes RESOURCEREQUEST DestroyWindow RESOURCEREQUEST DestroySubWindows RESOURCEREQUEST MapWindow RESOURCEREQUEST MapSubwindows RESOURCEREQUEST UnmapWindow RESOURCEREQUEST UnmapSubwindows RESOURCEREQUEST GetGeometry RESOURCEREQUEST QueryTree RESOURCEREQUEST GetAtomName RESOURCEREQUEST ListProperties RESOURCEREQUEST GetSelectionOwner RESOURCEREQUEST UngrabPointer RESOURCEREQUEST UngrabKeyboard RESOURCEREQUEST QueryPointer RESOURCEREQUEST CloseFont RESOURCEREQUEST QueryFont RESOURCEREQUEST FreePixmap RESOURCEREQUEST FreeGC RESOURCEREQUEST FreeColormap RESOURCEREQUEST InstallColormap RESOURCEREQUEST UninstallColormap RESOURCEREQUEST ListInstalledColormaps RESOURCEREQUEST FreeCursor RESOURCEREQUEST KillClient MINIREQUEST GetFontPath MINIREQUEST GrabServer MINIREQUEST UngrabServer MINIREQUEST GetInputFocus MINIREQUEST QueryKeymap MINIREQUEST ListExtensions MINIREQUEST GetKeyboardControl MINIREQUEST GetPointerControl MINIREQUEST GetScreenSaver MINIREQUEST GetPointerMapping MINIREQUEST GetModifierMapping MINIREQUEST NoOperation REQUEST RotateProperties CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD16:nAtoms INT16:nPositions REQUEST AllocColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:red CARD16:green CARD16:blue CARD16:pad2 REQUEST PolyText CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST DeleteProperty CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:property REQUEST ChangeProperty CARD8:reqType CARD8:mode CARD16:length CARD32:window CARD32:property CARD32:type CARD8:format BYTE:pad[3] CARD32:nUnits REQUEST CARD8:reqType CARD8:data CARD16:length REQUEST SetPointerMapping CARD8:reqType CARD8:nElts CARD16:length REQUEST CreateGlyphCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cid CARD32:source CARD32:mask CARD16:sourceChar CARD16:maskChar CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue REQUEST StoreColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap REQUEST PolyText8 CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST FillPoly CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc BYTE:shape BYTE:coordMode CARD16:pad1 REQUEST PolyLine CARD8:reqType BYTE:coordMode CARD16:length CARD32:drawable CARD32:gc REQUEST WarpPointer CARD8:reqType BYTE:pad CARD16:length CARD32:srcWid CARD32:dstWid INT16:srcX INT16:srcY CARD16:srcWidth CARD16:srcHeight INT16:dstX INT16:dstY REQUEST CirculateWindow CARD8:reqType CARD8:direction CARD16:length CARD32:window REQUEST ChangeWindowAttributes CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:valueMask REQUEST ChangeHosts CARD8:reqType BYTE:mode CARD16:length CARD8:hostFamily BYTE:pad CARD16:hostLength REQUEST PolyText16 CARD8:reqType CARD8:pad CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST CopyArea CARD8:reqType BYTE:pad CARD16:length CARD32:srcDrawable CARD32:dstDrawable CARD32:gc INT16:srcX INT16:srcY INT16:dstX INT16:dstY CARD16:width CARD16:height REQUEST CopyGC CARD8:reqType BYTE:pad CARD16:length CARD32:srcGC CARD32:dstGC CARD32:mask REQUEST SetFontPath CARD8:reqType BYTE:pad CARD16:length CARD16:nFonts BYTE:pad1 BYTE:pad2 REQUEST OpenFont CARD8:reqType BYTE:pad CARD16:length CARD32:fid CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST UngrabButton CARD8:reqType CARD8:button CARD16:length CARD32:grabWindow CARD16:modifiers CARD16:pad REQUEST ConfigureWindow CARD8:reqType CARD8:pad CARD16:length CARD32:window CARD16:mask CARD16:pad2 REQUEST ReparentWindow CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:parent INT16:x INT16:y REQUEST ForceScreenSaver CARD8:reqType BYTE:mode CARD16:length REQUEST ChangeMode CARD8:reqType BYTE:mode CARD16:length REQUEST ChangePointerControl CARD8:reqType BYTE:pad CARD16:length INT16:accelNum INT16:accelDenum INT16:threshold BOOL:doAccel BOOL:doThresh REQUEST Bell CARD8:reqType INT8:percent CARD16:length REQUEST ChangeKeyboardControl CARD8:reqType BYTE:pad CARD16:length CARD32:mask REQUEST AllocNamedColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST GetImage CARD8:reqType CARD8:format CARD16:length CARD32:drawable INT16:x INT16:y CARD16:width CARD16:height CARD32:planeMask REQUEST PolyFillArc CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST CreatePixmap CARD8:reqType CARD8:depth CARD16:length CARD32:pid CARD32:drawable CARD16:width CARD16:height REQUEST QueryTextExtents CARD8:reqType BOOL:oddLength CARD16:length CARD32:fid REQUEST GrabKeyboard CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD32:time BYTE:pointerMode BYTE:keyboardMode CARD16:pad REQUEST QueryColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap REQUEST CopyColormapAndFree CARD8:reqType BYTE:pad CARD16:length CARD32:mid CARD32:srcCmap REQUEST ImageText16 CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST PolyRectangle CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST PolySegment CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST TranslateCoords CARD8:reqType BYTE:pad CARD16:length CARD32:srcWid CARD32:dstWid INT16:srcX INT16:srcY REQUEST GrabButton CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:eventMask BYTE:pointerMode BYTE:keyboardMode CARD32:confineTo CARD32:cursor CARD8:button BYTE:pad CARD16:modifiers REQUEST SetSelectionOwner CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:selection CARD32:time REQUEST SetAccessControl CARD8:reqType BYTE:mode CARD16:length REQUEST ChangeKeyboardMapping CARD8:reqType CARD8:keyCodes CARD16:length CARD8:firstKeyCode CARD8:keySymsPerKeyCode CARD16:pad1 REQUEST QueryExtension CARD8:reqType BYTE:pad CARD16:length CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST AllocColorPlanes CARD8:reqType BOOL:contiguous CARD16:length CARD32:cmap CARD16:colors CARD16:red CARD16:green CARD16:blue REQUEST AllocColorCells CARD8:reqType BOOL:contiguous CARD16:length CARD32:cmap CARD16:colors CARD16:planes REQUEST ImageText8 CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST ImageText CARD8:reqType BYTE:nChars CARD16:length CARD32:drawable CARD32:gc INT16:x INT16:y REQUEST PolyPoint CARD8:reqType BYTE:coordMode CARD16:length CARD32:drawable CARD32:gc REQUEST ChangeSaveSet CARD8:reqType BYTE:mode CARD16:length CARD32:window REQUEST QueryBestSize CARD8:reqType CARD8:class CARD16:length CARD32:drawable CARD16:width CARD16:height REQUEST LookupColor CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST PolyArc CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST SetDashes CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD16:dashOffset CARD16:nDashes REQUEST ChangeActivePointerGrab CARD8:reqType BYTE:pad CARD16:length CARD32:cursor CARD32:time CARD16:eventMask CARD16:pad2 REQUEST GrabPointer CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:eventMask BYTE:pointerMode BYTE:keyboardMode CARD32:confineTo CARD32:cursor CARD32:time REQUEST ConvertSelection CARD8:reqType BYTE:pad CARD16:length CARD32:requestor CARD32:selection CARD32:target CARD32:property CARD32:time REQUEST CreateWindow CARD8:reqType CARD8:depth CARD16:length CARD32:wid CARD32:parent INT16:x INT16:y CARD16:width CARD16:height CARD16:borderWidth CARD16:class CARD32:visual CARD32:mask REQUEST PolyFillRectangle CARD8:reqType BYTE:pad CARD16:length CARD32:drawable CARD32:gc REQUEST SetClipRectangles CARD8:reqType BYTE:ordering CARD16:length CARD32:gc INT16:xOrigin INT16:yOrigin REQUEST ListFontsWithInfo CARD8:reqType BYTE:pad CARD16:length CARD16:maxNames CARD16:nbytes REQUEST GetMotionEvents CARD8:reqType BYTE:pad CARD16:length CARD32:window CARD32:start CARD32:stop REQUEST Resource CARD8:reqType BYTE:pad CARD16:length CARD32:id REQUEST StoreNamedColor CARD8:reqType CARD8:flags CARD16:length CARD32:cmap CARD32:pixel CARD16:nbytes BYTE:pad1 BYTE:pad2 REQUEST CopyPlane CARD8:reqType BYTE:pad CARD16:length CARD32:srcDrawable CARD32:dstDrawable CARD32:gc INT16:srcX INT16:srcY INT16:dstX INT16:dstY CARD16:width CARD16:height CARD32:bitPlane REQUEST ListFonts CARD8:reqType BYTE:pad CARD16:length CARD16:maxNames CARD16:nbytes REQUEST UngrabKey CARD8:reqType CARD8:key CARD16:length CARD32:grabWindow CARD16:modifiers CARD16:pad REQUEST GetProperty CARD8:reqType BOOL:delete CARD16:length CARD32:window CARD32:property CARD32:type CARD32:longOffset CARD32:longLength REQUEST RecolorCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cursor CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue REQUEST CreateCursor CARD8:reqType BYTE:pad CARD16:length CARD32:cid CARD32:source CARD32:mask CARD16:foreRed CARD16:foreGreen CARD16:foreBlue CARD16:backRed CARD16:backGreen CARD16:backBlue CARD16:x CARD16:y REQUEST ChangeGC CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD32:mask REQUEST CreateGC CARD8:reqType BYTE:pad CARD16:length CARD32:gc CARD32:drawable CARD32:mask REQUEST SetInputFocus CARD8:reqType CARD8:revertTo CARD16:length CARD32:focus CARD32:time REQUEST GrabKey CARD8:reqType BOOL:ownerEvents CARD16:length CARD32:grabWindow CARD16:modifiers CARD8:key BYTE:pointerMode BYTE:keyboardMode BYTE:pad1 BYTE:pad2 BYTE:pad3 REQUEST ListHosts CARD8:reqType BYTE:pad CARD16:length REQUEST SetScreenSaver CARD8:reqType BYTE:pad CARD16:length INT16:timeout INT16:interval BYTE:preferBlank BYTE:allowExpose CARD16:pad2 REQUEST SetModifierMapping CARD8:reqType CARD8:numKeyPerModifier CARD16:length REQUEST InternAtom CARD8:reqType BOOL:onlyIfExists CARD16:length CARD16:nbytes CARD16:pad REQUEST SetCloseDownMode CARD8:reqType BYTE:mode CARD16:length REQUEST GetKeyboardMapping CARD8:reqType BYTE:pad CARD16:length CARD8:firstKeyCode CARD8:count CARD16:pad1 REQUEST FreeColors CARD8:reqType BYTE:pad CARD16:length CARD32:cmap CARD32:planeMask REQUEST CreateColormap CARD8:reqType BYTE:alloc CARD16:length CARD32:mid CARD32:window CARD32:visual REQUEST PutImage CARD8:reqType CARD8:format CARD16:length CARD32:drawable CARD32:gc CARD16:width CARD16:height INT16:dstX INT16:dstY CARD8:leftPad CARD8:depth CARD16:pad REQUEST ClearArea CARD8:reqType BOOL:exposures CARD16:length CARD32:window INT16:x INT16:y CARD16:width CARD16:height REQUEST AllowEvents CARD8:reqType CARD8:mode CARD16:length CARD32:time REQUEST SendEvent CARD8:reqType BOOL:propagate CARD16:length CARD32:destination CARD32:eventMask REPLY AllocColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:red CARD16:green CARD16:blue CARD16:pad2 CARD32:pixel CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY ListProperties BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nProperties CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryTree BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:root CARD32:parent CARD16:nChildren CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY GetKeyboardControl BYTE:type BOOL:globalAutoRepeat CARD16:sequenceNumber CARD32:length CARD32:ledMask CARD8:keyClickPercent CARD8:bellPercent CARD16:bellPitch CARD16:bellDuration CARD16:pad REPLY SetPointerMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY SetMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetGeometry BYTE:type CARD8:depth CARD16:sequenceNumber CARD32:length CARD32:root INT16:x INT16:y CARD16:width CARD16:height CARD16:borderWidth CARD16:pad1 CARD32:pad2 CARD32:pad3 REPLY QueryPointer BYTE:type BOOL:sameScreen CARD16:sequenceNumber CARD32:length CARD32:root CARD32:child INT16:rootX INT16:rootY INT16:winX INT16:winY CARD16:mask CARD16:pad1 CARD32:pad REPLY AllocNamedColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:pixel CARD16:exactRed CARD16:exactGreen CARD16:exactBlue CARD16:screenRed CARD16:screenGreen CARD16:screenBlue CARD32:pad2 CARD32:pad3 REPLY GetImage BYTE:type CARD8:depth CARD16:sequenceNumber CARD32:length CARD32:visual CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryTextExtents BYTE:type CARD8:drawDirection CARD16:sequenceNumber CARD32:length INT16:fontAscent INT16:fontDescent INT16:overallAscent INT16:overallDescent INT32:overallWidth INT32:overallLeft INT32:overallRight CARD32:pad REPLY GrabKeyboard BYTE:type BYTE:status CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetPointerControl BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:accelNumerator CARD16:accelDenominator CARD16:threshold CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetModifierMapping BYTE:type CARD8:numKeyPerModifier CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListExtensions BYTE:type CARD8:nExtensions CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryColors BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nColors CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY TranslateCoords BYTE:type BOOL:sameScreen CARD16:sequenceNumber CARD32:length CARD32:child INT16:dstX INT16:dstY CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY QueryExtension BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length BOOL:present CARD8:major_opcode CARD8:first_event CARD8:first_error CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY AllocColorPlanes BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPixels CARD16:pad2 CARD32:redMask CARD32:greenMask CARD32:blueMask CARD32:pad3 CARD32:pad4 REPLY AllocColorCells BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPixels CARD16:nMasks CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetFontPath BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nPaths CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetAtomName BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nameLength CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetPointerMapping BYTE:type CARD8:nElts CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY QueryBestSize BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:width CARD16:height CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY LookupColor BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:exactRed CARD16:exactGreen CARD16:exactBlue CARD16:screenRed CARD16:screenGreen CARD16:screenBlue CARD32:pad3 CARD32:pad4 CARD32:pad5 REPLY QueryKeymap BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length REPLY GrabPointer BYTE:type BYTE:status CARD16:sequenceNumber CARD32:length CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListFontsWithInfo BYTE:type CARD8:nameLength CARD16:sequenceNumber CARD32:length xCharInfo:minBounds CARD32:walign1 xCharInfo:maxBounds CARD32:walign2 CARD16:minCharOrByte2 CARD16:maxCharOrByte2 CARD16:defaultChar CARD16:nFontProps CARD8:drawDirection CARD8:minByte1 CARD8:maxByte1 BOOL:allCharsExist INT16:fontAscent INT16:fontDescent CARD32:nReplies REPLY QueryFont BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length xCharInfo:minBounds CARD32:walign1 xCharInfo:maxBounds CARD32:walign2 CARD16:minCharOrByte2 CARD16:maxCharOrByte2 CARD16:defaultChar CARD16:nFontProps CARD8:drawDirection CARD8:minByte1 CARD8:maxByte1 BOOL:allCharsExist INT16:fontAscent INT16:fontDescent CARD32:nCharInfos REPLY GetMotionEvents BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:nEvents CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetWindowAttributes BYTE:type CARD8:backingStore CARD16:sequenceNumber CARD32:length CARD32:visualID CARD16:class CARD8:bitGravity CARD8:winGravity CARD32:backingBitPlanes CARD32:backingPixel BOOL:saveUnder BOOL:mapInstalled CARD8:mapState BOOL:override CARD32:colormap CARD32:allEventMasks CARD32:yourEventMask CARD16:doNotPropagateMask CARD16:pad REPLY GetScreenSaver BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:timeout CARD16:interval BOOL:preferBlanking BOOL:allowExposures CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY ListFonts BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nFonts CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetProperty BYTE:type CARD8:format CARD16:sequenceNumber CARD32:length CARD32:propertyType CARD32:bytesAfter CARD32:nItems CARD32:pad1 CARD32:pad2 CARD32:pad3 REPLY Generic BYTE:type BYTE:data1 CARD16:sequenceNumber CARD32:length CARD32:data00 CARD32:data01 CARD32:data02 CARD32:data03 CARD32:data04 CARD32:data05 REPLY ListHosts BYTE:type BOOL:enabled CARD16:sequenceNumber CARD32:length CARD16:nHosts CARD16:pad1 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY SetModifierMapping BYTE:type CARD8:success CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetSelectionOwner BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:owner CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY InternAtom BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD32:atom CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 REPLY GetKeyboardMapping BYTE:type CARD8:keySymsPerKeyCode CARD16:sequenceNumber CARD32:length CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY ListInstalledColormaps BYTE:type BYTE:pad1 CARD16:sequenceNumber CARD32:length CARD16:nColormaps CARD16:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 REPLY GetInputFocus BYTE:type CARD8:revertTo CARD16:sequenceNumber CARD32:length CARD32:focus CARD32:pad1 CARD32:pad2 CARD32:pad3 CARD32:pad4 CARD32:pad5 STRUCT Depth CARD8:depth CARD8:pad1 CARD16:nVisuals CARD32:pad2 STRUCT WindowRoot CARD32:windowId CARD32:defaultColormap CARD32:whitePixel CARD32:blackPixel CARD32:currentInputMask CARD16:pixWidth CARD16:pixHeight CARD16:mmWidth CARD16:mmHeight CARD16:minInstalledMaps CARD16:maxInstalledMaps CARD32:rootVisualID CARD8:backingStore BOOL:saveUnders CARD8:rootDepth CARD8:nDepths STRUCT TextElt CARD8:len INT8:delta STRUCT rgb CARD16:red CARD16:green CARD16:blue CARD16:pad STRUCT FontProp CARD32:name CARD32:value STRUCT HostEntry CARD8:family BYTE:pad CARD16:length STRUCT ConnSetupPrefix CARD8:success BYTE:lengthReason CARD16:majorVersion CARD16:minorVersion CARD16:length STRUCT Arc INT16:x INT16:y CARD16:width CARD16:height INT16:angle1 INT16:angle2 STRUCT Point INT16:x INT16:y STRUCT VisualType CARD32:visualID CARD8:class CARD8:bitsPerRGB CARD16:colormapEntries CARD32:redMask CARD32:greenMask CARD32:blueMask CARD32:pad STRUCT Error BYTE:type BYTE:errorCode CARD16:sequenceNumber CARD32:resourceID CARD16:minorCode CARD8:majorCode BYTE:pad1 CARD32:pad3 CARD32:pad4 CARD32:pad5 CARD32:pad6 CARD32:pad7 STRUCT PixmapFormat CARD8:depth CARD8:bitsPerPixel CARD8:scanLinePad CARD8:pad1 CARD32:pad2 STRUCT CharInfo INT16:leftSideBearing INT16:rightSideBearing INT16:characterWidth INT16:ascent INT16:descent CARD16:attributes STRUCT Segment INT16:x1 INT16:y1 INT16:x2 INT16:y2 STRUCT ColorItem CARD32:pixel CARD16:red CARD16:green CARD16:blue CARD8:flags CARD8:pad STRUCT Timecoord CARD32:time INT16:x INT16:y STRUCT ConnSetup CARD32:release CARD32:ridBase CARD32:ridMask CARD32:motionBufferSize CARD16:nbytesVendor CARD16:maxRequestSize CARD8:numRoots CARD8:numFormats CARD8:imageByteOrder CARD8:bitmapBitOrder CARD8:bitmapScanlineUnit CARD8:bitmapScanlinePad CARD8:minKeyCode CARD8:maxKeyCode CARD32:pad2 STRUCT Rectangle INT16:x INT16:y CARD16:width CARD16:height STRUCT ConnClientPrefix CARD8:byteOrder BYTE:pad CARD16:majorVersion CARD16:minorVersion CARD16:nbytesAuthProto CARD16:nbytesAuthString CARD16:pad2 STRUCT KeymapEvent BYTE:type BYTE:map[31] python-xlib-0.14+20091101/test/gen/genprottest.py0000755000175000017500000010041710633003257020017 0ustar stewstew#!/usr/bin/env python import sys import os sys.path.insert(1, os.path.join(sys.path[0], '../..')) import types import string import struct from whrandom import randint, choice from Xlib.protocol import request, structs, rq, event from Xlib import X, XK MINI_DEF = (('CARD8', 'reqType'), ('BYTE', 'pad'), ('CARD16', 'length')) RESOURCE_DEF = (('CARD8', 'reqType'), ('BYTE', 'pad'), ('CARD16', 'length'), ('CARD32', 'id')) def read_defs(): global request_defs, reply_defs, struct_defs global mini_request_defs, resource_request_defs global event_defs request_defs = {} mini_request_defs = {} resource_request_defs = {} reply_defs = {} struct_defs = {} event_defs = {} for line in sys.stdin.readlines(): parts = string.split(string.strip(line)) fields = [] for f in parts[2:]: fields.append(string.split(f, ':')) if parts[0] == 'REQUEST': request_defs[parts[1]] = fields elif parts[0] == 'MINIREQUEST': mini_request_defs[parts[1]] = MINI_DEF elif parts[0] == 'RESOURCEREQUEST': resource_request_defs[parts[1]] = RESOURCE_DEF elif parts[0] == 'REPLY': reply_defs[parts[1]] = fields elif parts[0] == 'STRUCT': struct_defs[parts[1]] = fields elif parts[0] == 'EVENT': event_defs[parts[1]] = fields def build(): if struct.unpack('BB', struct.pack('H', 0x0100))[0]: endian = 'be' else: endian = 'le' read_defs() build_request(endian) build_event(endian) def build_request(endian): fc = open('genrequest.c', 'w') fc.write(C_HEADER) reqlist = request.major_codes.items() reqlist.sort(lambda x, y: cmp(x[0], y[0])) genfuncs = [] req_args = {} reply_args = {} for code, req in reqlist: name = req.__name__ creqname = name cdefs = request_defs.get(name) if cdefs is None: cdefs = mini_request_defs.get(name) creqname = '' if cdefs is None: cdefs = resource_request_defs.get(name) creqname = 'Resource' creqname = 'x%sReq' % creqname if cdefs is None: sys.stderr.write('missing def for request: %s\n' % name) else: vardefs = request_var_defs.get(name, [()]) if type(vardefs) is not types.ListType: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: req_args[uname] = gen_func(fc, 'genrequest_' + uname, creqname, 'REQUEST ' + uname, req._request, cdefs, v) except: sys.stderr.write('Error in %s request\n' % uname) raise genfuncs.append('genrequest_' + uname) i = i + 1 if issubclass(req, rq.ReplyRequest): cdefs = reply_defs.get(name) if cdefs is None: sys.stderr.write('missing def for reply: %s\n' % name) else: vardefs = reply_var_defs.get(name, ()) if type(vardefs) is not types.ListType: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: reply_args[uname] = gen_func(fc, 'genreply_' + uname, 'x%sReply' % name, 'REPLY ' + uname, req._reply, cdefs, v) except: sys.stderr.write('Error in %s reply\n' % uname) raise genfuncs.append('genreply_' + uname) i = i + 1 fc.write(''' int main(void) { ''') for gf in genfuncs: fc.write(' %s();\n' % gf) fc.write(''' return 0; } ''') fc.close() os.system('gcc -Wall -g genrequest.c -o genrequest') req_bins = {} reply_bins = {} pc = os.popen('./genrequest', 'r') for line in pc.readlines(): parts = string.split(string.strip(line)) if parts[0] == 'REQUEST': req_bins[parts[1]] = parts[2] elif parts[0] == 'REPLY': reply_bins[parts[1]] = parts[2] fpy = open('test_requests_%s.py' % endian, 'w') os.chmod('test_requests_%s.py' % endian, 0755) if endian == 'be': e = 'Big-endian' v = 1 else: e = 'Little-endian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) for code, req in reqlist: name = req.__name__ fpy.write('\n\nclass Test%s(unittest.TestCase):\n' % name) fpy.write(' def setUp(self):\n') i = 0 reqs = -1 replies = -1 while 1: if i > 0: uname = name + str(i) else: uname = name reqbin = req_bins.get(uname) replybin = reply_bins.get(uname) if reqbin is None and replybin is None: break if reqbin: reqs = i fpy.write(' self.req_args_%d = %s\n' % (i, build_args(req_args[uname]))) fpy.write(' self.req_bin_%d = %s\n\n' % (i, build_bin(reqbin))) if replybin: replies = i fpy.write(' self.reply_args_%d = %s\n' % (i, build_args(reply_args[uname]))) fpy.write(' self.reply_bin_%d = %s\n\n' % (i, build_bin(replybin))) i = i + 1 for i in range(0, reqs + 1): fpy.write(''' def testPackRequest%(n)d(self): bin = apply(request.%(req)s._request.to_binary, (), self.req_args_%(n)d) self.assert_(bin == self.req_bin_%(n)d, tohex(bin)) def testUnpackRequest%(n)d(self): args, remain = request.%(req)s._request.parse_binary(self.req_bin_%(n)d, dummy_display, 1) self.assert_(len(remain) == 0, tohex(remain)) self.assert_(args == self.req_args_%(n)d, args) ''' % { 'req': req.__name__, 'n': i }) for i in range(0, replies + 1): fpy.write(''' def testPackReply%(n)d(self): bin = apply(request.%(req)s._reply.to_binary, (), self.reply_args_%(n)d) self.assert_(bin == self.reply_bin_%(n)d, tohex(bin)) def testUnpackReply%(n)d(self): args, remain = request.%(req)s._reply.parse_binary(self.reply_bin_%(n)d, dummy_display, 1) self.assert_(len(remain) == 0, tohex(remain)) self.assert_(args == self.reply_args_%(n)d, args) ''' % { 'req': req.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": check_endian() unittest.main() ''') def build_event(endian): fc = open('genevent.c', 'w') fc.write(C_HEADER) evtlist = event.event_class.items() evtlist.sort(lambda x, y: cmp(x[0], y[0])) genfuncs = [] evt_args = {} for code, evt in evtlist: # skip events that does not subclass rq.Event immediately, # since those are specializations of the more general ones we # test. if evt.__bases__ != (rq.Event, ): continue # special handling of KeymapNotify, since that # event is so different if evt == event.KeymapNotify: evt_args['KeymapNotify'] = gen_func(fc, 'genevent_KeymapNotify', 'xKeymapEvent', 'EVENT KeymapNotify', evt._fields, (('BYTE', 'type'), ), (31, )) genfuncs.append('genevent_KeymapNotify') continue name = evt.__name__ cdefs = event_defs.get(name) if cdefs is None: sys.stderr.write('missing def for event: %s\n' % name) else: vardefs = event_var_defs.get(name, [()]) if type(vardefs) is not types.ListType: vardefs = [vardefs] i = 0 for v in vardefs: if i > 0: uname = name + str(i) else: uname = name try: evt_args[uname] = gen_func(fc, 'genevent_' + uname, 'xEvent', 'EVENT ' + uname, evt._fields, cdefs, v) except: sys.stderr.write('Error in %s event\n' % uname) raise genfuncs.append('genevent_' + uname) i = i + 1 fc.write(''' int main(void) { ''') for gf in genfuncs: fc.write(' %s();\n' % gf) fc.write(''' return 0; } ''') fc.close() os.system('gcc -Wall -g genevent.c -o genevent') evt_bins = {} pc = os.popen('./genevent', 'r') for line in pc.readlines(): parts = string.split(string.strip(line)) if parts[0] == 'EVENT': evt_bins[parts[1]] = parts[2] fpy = open('test_events_%s.py' % endian, 'w') os.chmod('test_events_%s.py' % endian, 0755) if endian == 'be': e = 'Big-endian' v = 1 else: e = 'Little-endian' v = 0 fpy.write(PY_HEADER % { 'endname': e, 'endvalue': v }) for code, evt in evtlist: if evt.__bases__ != (rq.Event, ): continue name = evt.__name__ fpy.write('\n\nclass Test%s(unittest.TestCase):\n' % name) fpy.write(' def setUp(self):\n') i = 0 evts = -1 while 1: if i > 0: uname = name + str(i) else: uname = name evtbin = evt_bins.get(uname) if evtbin is None: break evts = i fpy.write(' self.evt_args_%d = %s\n' % (i, build_args(evt_args[uname]))) fpy.write(' self.evt_bin_%d = %s\n\n' % (i, build_bin(evtbin))) i = i + 1 for i in range(0, evts + 1): fpy.write(''' def testPack%(n)d(self): bin = apply(event.%(evt)s._fields.to_binary, (), self.evt_args_%(n)d) self.assert_(bin == self.evt_bin_%(n)d, tohex(bin)) def testUnpack%(n)d(self): args, remain = event.%(evt)s._fields.parse_binary(self.evt_bin_%(n)d, dummy_display, 1) self.assert_(len(remain) == 0, tohex(remain)) self.assert_(args == self.evt_args_%(n)d, args) ''' % { 'evt': evt.__name__, 'n': i }) fpy.write(''' if __name__ == "__main__": check_endian() unittest.main() ''') def gen_func(fc, funcname, structname, outputname, pydef, cdef, vardefs): fc.write('''void %s(void) { struct { %s xstruct; ''' % (funcname, structname)) args = {} varfs = {} extra_vars = [] flags = None # structure fields etc i = 0 for f in pydef.var_fields: # # List of something # if isinstance(f, rq.List): # # List of short strings # if f.type is rq.Str: vfstrings = vardefs[i] vflen = 0 vfdata = '' for s in vfstrings: vflen = vflen + 1 + len(s) vfdata = vfdata + chr(len(s)) + s fc.write('unsigned char %s[%d];\n ' % (f.name, pad4(vflen))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfdata), vflen), len(vfstrings), 0) args[f.name] = vfstrings # # List of scalars # elif isinstance(f.type, rq.ScalarObj) \ or isinstance(f.type, rq.ResourceObj): vflen = vardefs[i] if f.type.structcode == 'B': rmin = 128 rmax = 255 deflen = pad4(vflen) ctype = 'CARD8' elif f.type.structcode == 'H': rmin = 32768 rmax = 65536 deflen = vflen + vflen % 2 ctype = 'CARD16' elif f.type.structcode == 'L': rmin = 65536 rmax = 2147483646 deflen = vflen ctype = 'CARD32' else: RuntimeError('oops: %s' % f.type.structcode) def rand(x, rmin = rmin, rmax = rmax): return randint(rmin, rmax) vfdata = map(rand, range(0, vflen)) # # Special case for a few in-line coded lists # if structname in ('xGetKeyboardControlReply', 'xQueryKeymapReply', 'xKeymapEvent'): extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, vflen, string.join(map(str, vfdata), ', '))) varfs[f.name] = ('memcpy(data.xstruct.map, %s_def, sizeof(%s_def));' % (f.name, f.name), vflen, 0) else: fc.write('%s %s[%d];\n ' % (ctype, f.name, deflen)) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, vflen, string.join(map(str, vfdata), ', '))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), vflen, 0) args[f.name] = vfdata # # Special handling of unique Host case # elif f.type is structs.Host: pydata = [{ 'family': X.FamilyInternet, 'name': [ 34, 23, 178, 12 ] }, { 'family': X.FamilyInternet, 'name': [ 130, 236, 254, 15 ] }, ] cdata = [] for p in pydata: cdata.append("{ { %d, 0, 4 }, { %d, %d, %d, %d } }" % ((p['family'], ) + tuple(p['name']))) fc.write('struct { xHostEntry e; CARD8 name[4]; } %s[2];\n ' % f.name) extra_vars.append('struct { xHostEntry e; CARD8 name[4]; } %s_def[%d] = { %s };' % (f.name, len(pydata), string.join(cdata, ', '))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), len(pydata), 0) args[f.name] = pydata # # List of structures # elif isinstance(f.type, rq.Struct): vfname, vflen = vardefs[i] vfdef = struct_defs[vfname] pydata = [] defdata = [] for si in range(0, vflen): d = [] for t, cf in vfdef: if cf[:3] != 'pad': d.append(gen_value(t)) pyd = {} for sj in range(0, len(d)): pyd[f.type.fields[sj].name] = d[sj] pydata.append(pyd) defdata.append('{ ' + string.join(map(str, d), ', ') + ' }') fc.write('x%s %s[%d];\n ' % (vfname, f.name, vflen)) extra_vars.append('x%s %s_def[%d] = { %s };' % (vfname, f.name, vflen, string.join(defdata, ', '))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), vflen, 0) args[f.name] = pydata # # wide-char string # elif isinstance(f, rq.String16): vfstr = vardefs[i] vflen = len(vfstr) fc.write('unsigned char %s[%d];\n ' % (f.name, (vflen + vflen % 2) * 2)) s = '' for c in vfstr: s = s + '\0' + c varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(s), vflen * 2), vflen, 0) args[f.name] = tuple(map(ord, vfstr)) # # byte-char string # elif isinstance(f, rq.String8): vfstr = vardefs[i] vflen = len(vfstr) fc.write('unsigned char %s[%d];\n ' % (f.name, (vflen + (4 - vflen % 4) % 4))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfstr), vflen), vflen, 0) args[f.name] = vfstr # # List of optional values # elif isinstance(f, rq.ValueList): vlcode = [] vlargs = {} flags = 0 for vlf, flag in f.fields: ctype, rmin, rmax, clen = structcode_defs[vlf.structcode] fc.write('%s %s_%s;\n ' % (ctype, f.name, vlf.name)) if clen < 4: fc.write('unsigned char %s_%s_pad[%d];\n ' % (f.name, vlf.name, 4 - clen)) if isinstance(vlf, rq.Set): val = choice(vlf.values) elif isinstance(vlf, rq.Bool): val = choice((0, 1)) else: val = randint(rmin, rmax) vlargs[vlf.name] = val vlcode.append('data.%s_%s = %d;' % (f.name, vlf.name, val)) flags = flags | flag # vlcode.append('data.%s_flags = %d;' % (f.name, flags)) varfs[f.name] = (string.join(vlcode, ' '), 0, 0) args[f.name] = vlargs # # Text/font list, hardwire since they are so rare # elif isinstance(f, rq.TextElements8): if isinstance(f, rq.TextElements16): vfstr = '\x02\x02\x10\x23\x00\x12\xff\x01\x02\x03\x04' ret = [{'delta': 2, 'string': (0x1023, 0x0012)}, 0x01020304] else: vfstr = '\x03\x02zoo\xff\x01\x02\x03\x04\x02\x00ie' ret = [{'delta': 2, 'string': 'zoo'}, 0x01020304, { 'delta': 0, 'string': 'ie'}] fc.write('unsigned char %s[%d];\n ' % (f.name, len(vfstr))) varfs[f.name] = ('memcpy(data.%s, %s, %d);' % (f.name, cstring(vfstr), len(vfstr)), 0, 0) args[f.name] = ret # # Keyboard/modifier mappings # elif isinstance(f, rq.KeyboardMapping) \ or isinstance(f, rq.ModifierMapping): if isinstance(f, rq.KeyboardMapping): rmin = 0 rmax = 2147483646 length = 20 format = 3 ctype = 'CARD32' else: rmin = 0 rmax = 255 length = 8 format = 2 ctype = 'CARD8' pydata = [] cdata = [] for i in range(0, length): x = [] for j in range(0, format): v = randint(rmin, rmax) x.append(v) cdata.append(str(v)) pydata.append(x) fc.write('%s %s[%d];\n ' % (ctype, f.name, len(cdata))) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, len(cdata), string.join(cdata, ', '))) varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) args[f.name] = pydata # # property data # elif isinstance(f, rq.PropertyData): format, data = vardefs[i] length = len(data) if format == 8: ctype = 'CARD8' clen = pad4(length) cdata = cstring(data) elif format == 16: ctype = 'CARD16' clen = length + length % 2 cdata = string.join(map(str, data), ', ') elif format == 32: ctype = 'CARD32' clen = length cdata = string.join(map(str, data), ', ') if not isinstance(f, rq.FixedPropertyData): fc.write('%s %s[%d];\n ' % (ctype, f.name, clen)) extra_vars.append('%s %s_def[%d] = { %s };' % (ctype, f.name, length, cdata)) if not isinstance(f, rq.FixedPropertyData): varfs[f.name] = ('memcpy(data.%s, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) else: varfs[f.name] = ('assert(sizeof(%s_def) == 20); memcpy(data.xstruct.u.clientMessage.u.b.bytes, %s_def, sizeof(%s_def));' % (f.name, f.name, f.name), length, format) args[f.name] = (format, data) # # Event # elif isinstance(f, rq.EventField): ev = event.Expose(window = gen_value('CARD32'), x = gen_value('CARD16'), y = gen_value('CARD16'), width = gen_value('CARD16'), height = gen_value('CARD16'), count = gen_value('CARD16')) cdata = cstring(ev._binary) # fc.write('unsigned char %s[32];\n ' % f.name) extra_vars.append('unsigned char %s_def[32] = %s;' % (f.name, cdata)) varfs[f.name] = ('memcpy(&data.xstruct.event, %s_def, sizeof(%s_def));' % (f.name, f.name), 0, 0) args[f.name] = ev else: raise RuntimeError('oops: %s.%s' % (funcname, f.name)) i = i + 1 fc.write('\n } data;\n') for v in extra_vars: fc.write(' %s\n' % v) fc.write(''' memset(&data, 0, sizeof(data)); ''') pyi = 0 ci = 0 while ci < len(cdef): try: pyf = pydef.fields[pyi] except IndexError: pyf = None cf = cdef[ci] t, f = cf pyi = pyi + 1 ci = ci + 1 if f[:3] == 'pad' or f[:6] == 'walign': if not isinstance(pyf, rq.Pad): pyi = pyi - 1 # special case for value list mask elif (f == 'mask' or f == 'valueMask') and flags is not None: fc.write(' data.xstruct.%s = %d;\n' % (f, flags)) elif isinstance(pyf, rq.ConstantField): fc.write(' data.xstruct.%s = %d;\n' % (f, pyf.value)) elif isinstance(pyf, rq.RequestLength): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') fc.write(' data.xstruct.length = sizeof(data) / 4;\n') elif isinstance(pyf, rq.ReplyLength): assert f == 'length' fc.write(' assert(sizeof(data) % 4 == 0);\n') fc.write(' assert(sizeof(data) >= 32);\n') fc.write(' data.xstruct.length = (sizeof(data) - 32) / 4;\n') elif isinstance(pyf, rq.LengthOf): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][1])) elif isinstance(pyf, rq.OddLength): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][1] % 2)) elif isinstance(pyf, rq.Format): fc.write(' data.xstruct.%s = %d;\n' % (f, varfs[pyf.name][2])) elif isinstance(pyf, rq.Set): val = choice(pyf.values) fc.write(' data.xstruct.%s = %d;\n' % (f, val)) args[pyf.name] = val elif t == 'xCharInfo': d = [] for ct, cf in struct_defs['CharInfo']: if cf[:3] != 'pad': d.append(gen_value(ct)) pyd = {} for sj in range(0, len(d)): pyd[pyf.type.fields[sj].name] = d[sj] fc.write('{ %s def = { %s };\n ' % (t, string.join(map(str, d), ', '))) fc.write('memcpy(&data.xstruct.%s, &def, sizeof(def)); }\n ' % f) args[pyf.name] = pyd else: val = gen_value(t) fc.write(' data.xstruct.%s = %d;\n' % (f, val)) args[pyf.name] = val for code, length, format in varfs.values(): fc.write(' %s\n' % code); fc.write(''' output("%s", &data, sizeof(data)); } ''' % outputname) return args def gen_value(t): if t == 'INT8': val = randint(-128, -1) elif t == 'INT16': val = randint(-32768, -256) elif t == 'INT32': val = randint(-2147483647, -65536) elif t == 'CARD8' or t == 'BYTE': val = randint(128, 255) elif t == 'CARD16': val = randint(256, 65535) elif t == 'CARD32': val = randint(65536, 2147483646) elif t == 'BOOL': val = randint(0, 1) else: raise RuntimeError('unknown type: %s' % t) return val def pad4(l): return l + (4 - l % 4) % 4 def cstring(s): return '"' + string.join(map(lambda c: '\\x%x' % ord(c), s), '') + '"' def build_args(args): kwlist = [] for kw, val in args.items(): kwlist.append(" '%s': %s,\n" % (kw, repr(val))) return '{\n' + string.join(kwlist, '') + ' }' def build_bin(bin): bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("'%s'" % bins[i]) return string.join(bins2, ' \\\n ') request_var_defs = { 'InternAtom': ('fuzzy_prop', ), 'ChangeProperty': [((8, ''), ), ((8, 'foo'), ), ((8, 'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), ((32, []), ), ((32, [1, 2, 3]), ) ], 'OpenFont': ('foofont', ), 'QueryTextExtents': ('foo', ), 'ListFonts': ('bhazr', ), 'ListFontsWithInfo': ('bhazr2', ), 'SetFontPath': [(['foo', 'bar', 'gazonk'], ), ([], ) ], 'SetDashes': (9, ), 'SetClipRectangles': [(('Rectangle', 2), ), (('Rectangle', 0), ) ], 'PolyPoint': (('Point', 3), ), 'PolyLine': (('Point', 5), ), 'PolySegment': (('Segment', 1), ), 'PolyRectangle': (('Rectangle', 3), ), 'PolyArc': (('Arc', 3), ), 'FillPoly': (('Point', 3), ), 'PolyFillRectangle': (('Rectangle', 2), ), 'PolyFillArc': (('Arc', 1), ), 'PutImage': ('bit map data', ), 'ImageText8': ('showme', ), 'ImageText16': ('showmore', ), 'AllocNamedColor': ('octarin', ), 'FreeColors': (17, ), 'StoreColors': (('ColorItem', 4), ), 'StoreNamedColor': ('blue', ), 'QueryColors': [(8, ), (0, ) ], 'LookupColor': ('octarin', ), 'QueryExtension': ('XTRA', ), 'ChangeHosts': (4, ), 'RotateProperties': (12, ), 'SetPointerMapping': (5, ), } reply_var_defs = { 'QueryTree': (7, ), 'GetAtomName': ('WM_CLASS', ), 'GetProperty': [((8, ''), ), ((8, 'foo'), ), ((8, 'zoom'), ), ((16, []), ), ((16, [1, 2, 3]), ), ((16, [1, 2, 3, 4]), ), ((32, []), ), ((32, [1, 2, 3]), ) ], 'ListProperties': (23, ), 'GetMotionEvents': (('Timecoord', 5), ), 'QueryKeymap': (32, ), 'QueryFont': (('FontProp', 1), ('CharInfo', 3)), 'ListFonts': (['fie', 'fuzzy', 'foozooom'], ), 'ListFontsWithInfo': (('FontProp', 1), 'fontfont'), 'GetFontPath': [(['path1', 'path2232'], ), ([], ) ], 'GetImage': ('this is real ly imag e b-map', ), 'ListInstalledColormaps': (2, ), 'AllocColorCells': [(17, 3), (0, 0) ], 'AllocColorPlanes': (4, ), 'QueryColors': (('rgb', 5), ), 'ListExtensions': (['XTRA', 'XTRA-II'], ), 'GetKeyboardControl': (32, ), 'GetPointerMapping': (5, ), # '': (, ), } event_var_defs = { 'ClientMessage': [((8, '01234567890123456789'), ), ((16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), ), ((32, [1, 2, 3, 4, 5]), ) ], } structcode_defs = { 'b': ('INT8', -128, -1, 1), 'B': ('CARD8', 128, 255, 1), 'h': ('INT16', -32768, -1, 2), 'H': ('CARD16', 32768, 65536, 2), 'l': ('INT32', -2147483647, -1, 4), 'L': ('CARD32', 65536, 2147483646, 4), } C_HEADER = r''' #include #include #include #include void output(char *name, void *data, int length) { unsigned char *d = (unsigned char *) data; printf("%s ", name); while (length-- > 0) { if (0 && isgraph(*d)) putchar(*d); else printf("\\x%02x", *d); d++; } putchar('\n'); } ''' PY_HEADER = r'''#!/usr/bin/env python import sys, os sys.path.insert(1, os.path.join(sys.path[0], '..')) import string import unittest from Xlib.protocol import request, rq, event import Xlib.protocol.event import struct import array class CmpArray: def __init__(self, *args, **kws): self.array = apply(array.array, args, kws) def __len__(self): return len(self.array) def __getslice__(self, x, y): return list(self.array[x:y]) def __getattr__(self, attr): return getattr(self.array, attr) def __cmp__(self, other): return cmp(self.array.tolist(), other) rq.array = CmpArray def tohex(bin): bin = string.join(map(lambda c: '\\x%%02x' %% ord(c), bin), '') bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%%s' '%%s'" %% (bins[i], bins[i + 1])) except IndexError: bins2.append("'%%s'" %% bins[i]) return string.join(bins2, ' \\\n ') class DummyDisplay: def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() def check_endian(): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != %(endvalue)d: sys.stderr.write('%(endname)s tests, skipping on this system.\n') sys.exit(0) ''' if __name__ == '__main__': build() python-xlib-0.14+20091101/test/gen/genprotocol.awk0000644000175000017500000000422607436416254020140 0ustar stewstew# Feed cc -E /usr/include/X11/Xproto.h into this BEGIN { in_struct = 0; types[BOOL] = types[BYTE] = 1; types[INT8] = types[CARD8] = 1; types[INT16] = types[CARD16] = 1; types[INT32] = types[CARD32] = 1; } in_struct == 1 && $1 == "}" && $2 ~ /x.*;/ { name = substr($2, 2, length($2) - 2); memlist = ""; for (i = 0; i < memcount; i++) memlist = memlist " " members[i]; # print name ", " memlist if (name ~ /Req$/) requests[substr(name, 1, length(name) - 3)] = memlist; else if (name ~ /Reply$/) replies[substr(name, 1, length(name) - 5)] = memlist; else structs[name] = memlist; delete members; in_struct = 0; } in_struct == 2 && $1 == "}" && $2 == "xEvent;" { in_struct = 0; } in_struct == 1 && $1 != "}" { fcount = split($0, f, "[ \t,;]+"); if (fcount > 0) { if (f[1] == "") i = 2; else i = 1; if (next_type == "") { type = f[i]; i++; } else { type = next_type; } if ($0 ~ /;[ \t]*$/) { next_type = ""; } else { next_type = type; } for (; i < fcount; i++) { members[memcount] = type ":" f[i]; memcount++; } } } /^typedef struct.*\{/ { if (in_struct) { print "typedef struct while in_struct!"; exit 1; } next_type = ""; in_struct = 1; memcount = 0; # hack to skip _xEvent if ($3 == "_xEvent") in_struct = 2; } /^typedef x.* x.*;/ { if (in_struct) { print "typedef xFoo xBar; while in_struct!"; exit 1; } src = substr($2, 2); dest = substr($3, 2, length($3) - 2); if (src ~ /Req$/) memlist = requests[substr(src, 1, length(src) - 3)]; else if (src ~ /Reply$/) memlist = replies[substr(src, 1, length(src) - 5)]; else memlist = structs[src]; if (dest ~ /Req$/) requests[substr(dest, 1, length(dest) - 3)] = memlist; else if (dest ~ /Reply$/) replies[substr(dest, 1, length(dest) - 5)] = memlist; else structs[dest] = memlist; } END { for (x in requests) print "REQUEST " x " " requests[x]; for (x in replies) print "REPLY " x " " replies[x]; for (x in structs) print "STRUCT " x " " structs[x]; } python-xlib-0.14+20091101/test/gen/eventdef0000644000175000017500000001212407436416254016620 0ustar stewstewEVENT KeyButtonPointer BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.keyButtonPointer.time CARD32:u.keyButtonPointer.root CARD32:u.keyButtonPointer.event CARD32:u.keyButtonPointer.child INT16:u.keyButtonPointer.rootX INT16:u.keyButtonPointer.rootY INT16:u.keyButtonPointer.eventX INT16:u.keyButtonPointer.eventY CARD16:u.keyButtonPointer.state BOOL:u.keyButtonPointer.sameScreen EVENT EnterLeave BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.enterLeave.time CARD32:u.enterLeave.root CARD32:u.enterLeave.event CARD32:u.enterLeave.child INT16:u.enterLeave.rootX INT16:u.enterLeave.rootY INT16:u.enterLeave.eventX INT16:u.enterLeave.eventY CARD16:u.enterLeave.state BYTE:u.enterLeave.mode BYTE:u.enterLeave.flags EVENT Focus BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.focus.window BYTE:u.focus.mode EVENT Expose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.expose.window CARD16:u.expose.x CARD16:u.expose.y CARD16:u.expose.width CARD16:u.expose.height CARD16:u.expose.count EVENT GraphicsExpose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.graphicsExposure.drawable CARD16:u.graphicsExposure.x CARD16:u.graphicsExposure.y CARD16:u.graphicsExposure.width CARD16:u.graphicsExposure.height CARD16:u.graphicsExposure.minorEvent CARD16:u.graphicsExposure.count BYTE:u.graphicsExposure.majorEvent EVENT NoExpose BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.noExposure.drawable CARD16:u.noExposure.minorEvent BYTE:u.noExposure.majorEvent EVENT VisibilityNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.visibility.window CARD8:u.visibility.state EVENT CreateNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.createNotify.parent CARD32:u.createNotify.window INT16:u.createNotify.x INT16:u.createNotify.y CARD16:u.createNotify.width CARD16:u.createNotify.height CARD16:u.createNotify.borderWidth BOOL:u.createNotify.override EVENT DestroyNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.destroyNotify.event CARD32:u.destroyNotify.window EVENT UnmapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.unmapNotify.event CARD32:u.unmapNotify.window BOOL:u.unmapNotify.fromConfigure EVENT MapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.mapNotify.event CARD32:u.mapNotify.window BOOL:u.mapNotify.override EVENT MapRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.mapRequest.parent CARD32:u.mapRequest.window EVENT ReparentNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.reparent.event CARD32:u.reparent.window CARD32:u.reparent.parent INT16:u.reparent.x INT16:u.reparent.y BOOL:u.reparent.override EVENT ConfigureNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.configureNotify.event CARD32:u.configureNotify.window CARD32:u.configureNotify.aboveSibling INT16:u.configureNotify.x INT16:u.configureNotify.y CARD16:u.configureNotify.width CARD16:u.configureNotify.height CARD16:u.configureNotify.borderWidth BOOL:u.configureNotify.override EVENT ConfigureRequest BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.configureRequest.parent CARD32:u.configureRequest.window CARD32:u.configureRequest.sibling INT16:u.configureRequest.x INT16:u.configureRequest.y CARD16:u.configureRequest.width CARD16:u.configureRequest.height CARD16:u.configureRequest.borderWidth CARD16:u.configureRequest.valueMask EVENT GravityNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.gravity.event CARD32:u.gravity.window INT16:u.gravity.x INT16:u.gravity.y EVENT ResizeRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.resizeRequest.window CARD16:u.resizeRequest.width CARD16:u.resizeRequest.height EVENT Circulate BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.circulate.event CARD32:u.circulate.window CARD32:u.circulate.parent BYTE:u.circulate.place EVENT PropertyNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.property.window CARD32:u.property.atom CARD32:u.property.time BYTE:u.property.state EVENT SelectionClear BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionClear.time CARD32:u.selectionClear.window CARD32:u.selectionClear.atom EVENT SelectionRequest BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionRequest.time CARD32:u.selectionRequest.owner CARD32:u.selectionRequest.requestor CARD32:u.selectionRequest.selection CARD32:u.selectionRequest.target CARD32:u.selectionRequest.property EVENT SelectionNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.selectionNotify.time CARD32:u.selectionNotify.requestor CARD32:u.selectionNotify.selection CARD32:u.selectionNotify.target CARD32:u.selectionNotify.property EVENT ColormapNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD32:u.colormap.window CARD32:u.colormap.colormap BOOL:u.colormap.new BYTE:u.colormap.state EVENT MappingNotify BYTE:u.u.type BYTE:pad CARD16:u.u.sequenceNumber CARD8:u.mappingNotify.request CARD8:u.mappingNotify.firstKeyCode CARD8:u.mappingNotify.count EVENT ClientMessage BYTE:u.u.type BYTE:u.u.detail CARD16:u.u.sequenceNumber CARD32:u.clientMessage.window CARD32:u.clientMessage.u.l.type python-xlib-0.14+20091101/test/test_requests_le.py0000755000175000017500000057600210633003257020271 0ustar stewstew#!/usr/bin/env python import sys, os sys.path.insert(1, os.path.join(sys.path[0], '..')) import string import unittest from Xlib.protocol import request, rq, event import Xlib.protocol.event import struct import array class CmpArray: def __init__(self, *args, **kws): self.array = apply(array.array, args, kws) def __len__(self): return len(self.array) def __getslice__(self, x, y): return list(self.array[x:y]) def __getattr__(self, attr): return getattr(self.array, attr) def __cmp__(self, other): return cmp(self.array.tolist(), other) rq.array = CmpArray def tohex(bin): bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '') bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("'%s'" % bins[i]) return string.join(bins2, ' \\\n ') class DummyDisplay: def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() def check_endian(): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 0: sys.stderr.write('Little-endian tests, skipping on this system.\n') sys.exit(0) class TestCreateWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'wid': 632893089, 'parent': 563083824, 'visual': 811875917, 'height': 62043, 'width': 55071, 'depth': 198, 'attrs': {'cursor': 788158760, 'override_redirect': 1, 'bit_gravity': 6, 'event_mask': 894192179, 'border_pixel': 1365270572, 'background_pixel': 712927020, 'save_under': 0, 'colormap': 980005049, 'do_not_propagate_mask': 667770563, 'backing_store': 1, 'win_gravity': 6, 'backing_planes': 885526468, 'border_pixmap': 513882421, 'backing_pixel': 1693821982, 'background_pixmap': 1314139736}, 'y': -29423, 'x': -5822, 'border_width': 29625, 'window_class': 2, } self.req_bin_0 = '\x01\xc6\x17\x00' '\xa1\x2e\xb9\x25' \ '\x30\xfa\x8f\x21' '\x42\xe9\x11\x8d' \ '\x1f\xd7\x5b\xf2' '\xb9\x73\x02\x00' \ '\x4d\x3e\x64\x30' '\xff\x7f\x00\x00' \ '\x58\x2e\x54\x4e' '\x2c\x67\x7e\x2a' \ '\x35\x39\xa1\x1e' '\x2c\x60\x60\x51' \ '\x06\x00\x00\x00' '\x06\x00\x00\x00' \ '\x01\x00\x00\x00' '\xc4\x0f\xc8\x34' \ '\x1e\xac\xf5\x64' '\x01\x00\x00\x00' \ '\x00\x00\x00\x00' '\x33\x4a\x4c\x35' \ '\xc3\x5e\xcd\x27' '\xb9\xb0\x69\x3a' \ '\x28\x59\xfa\x2e' def testPackRequest0(self): bin = apply(request.CreateWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeWindowAttributes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 560274578, 'attrs': {'cursor': 1238338372, 'override_redirect': 0, 'bit_gravity': 6, 'event_mask': 1980992429, 'border_pixel': 310964771, 'background_pixel': 1268171782, 'save_under': 1, 'colormap': 171538239, 'do_not_propagate_mask': 135558419, 'backing_store': 2, 'win_gravity': 10, 'backing_planes': 252687930, 'border_pixmap': 287169917, 'backing_pixel': 1114685309, 'background_pixmap': 2004887498}, } self.req_bin_0 = '\x02\x00\x12\x00' '\x92\x1c\x65\x21' \ '\xff\x7f\x00\x00' '\xca\x27\x80\x77' \ '\x06\xc4\x96\x4b' '\x7d\xdd\x1d\x11' \ '\x23\xf2\x88\x12' '\x06\x00\x00\x00' \ '\x0a\x00\x00\x00' '\x02\x00\x00\x00' \ '\x3a\xb6\x0f\x0f' '\x7d\xbf\x70\x42' \ '\x00\x00\x00\x00' '\x01\x00\x00\x00' \ '\xad\x8b\x13\x76' '\x13\x75\x14\x08' \ '\x3f\x77\x39\x0a' '\x44\x8b\xcf\x49' def testPackRequest0(self): bin = apply(request.ChangeWindowAttributes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetWindowAttributes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1672572666, } self.req_bin_0 = '\x03\x00\x02\x00' '\xfa\x6e\xb1\x63' self.reply_args_0 = { 'do_not_propagate_mask': 33915, 'your_event_mask': 172607058, 'override_redirect': 0, 'bit_gravity': 128, 'all_event_masks': 1036583348, 'save_under': 1, 'visual': 1419731381, 'map_state': 169, 'win_class': 16168, 'backing_bit_planes': 849532878, 'backing_store': 215, 'win_gravity': 140, 'map_is_installed': 1, 'backing_pixel': 933754009, 'sequence_number': 38504, 'colormap': 56062036, } self.reply_bin_0 = '\x01\xd7\x68\x96' '\x03\x00\x00\x00' \ '\xb5\x61\x9f\x54' '\x28\x3f\x80\x8c' \ '\xce\xd7\xa2\x32' '\x99\xf4\xa7\x37' \ '\x01\x01\xa9\x00' '\x54\x70\x57\x03' \ '\xb4\x01\xc9\x3d' '\x52\xc6\x49\x0a' \ '\x7b\x84\x00\x00' def testPackRequest0(self): bin = apply(request.GetWindowAttributes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetWindowAttributes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetWindowAttributes._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetWindowAttributes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestDestroyWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 533632985, } self.req_bin_0 = '\x04\x00\x02\x00' '\xd9\x97\xce\x1f' def testPackRequest0(self): bin = apply(request.DestroyWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DestroyWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestDestroySubWindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 490680451, } self.req_bin_0 = '\x05\x00\x02\x00' '\x83\x30\x3f\x1d' def testPackRequest0(self): bin = apply(request.DestroySubWindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DestroySubWindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeSaveSet(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1974200014, 'mode': 0, } self.req_bin_0 = '\x06\x00\x02\x00' '\xce\xe6\xab\x75' def testPackRequest0(self): bin = apply(request.ChangeSaveSet._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeSaveSet._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestReparentWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'y': -12763, 'x': -18160, 'window': 2127670410, 'parent': 1913134105, } self.req_bin_0 = '\x07\x00\x04\x00' '\x8a\xac\xd1\x7e' \ '\x19\x1c\x08\x72' '\x10\xb9\x25\xce' def testPackRequest0(self): bin = apply(request.ReparentWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ReparentWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestMapWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 962670079, } self.req_bin_0 = '\x08\x00\x02\x00' '\xff\x2d\x61\x39' def testPackRequest0(self): bin = apply(request.MapWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.MapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestMapSubwindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 447820952, } self.req_bin_0 = '\x09\x00\x02\x00' '\x98\x34\xb1\x1a' def testPackRequest0(self): bin = apply(request.MapSubwindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.MapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUnmapWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1130502889, } self.req_bin_0 = '\x0a\x00\x02\x00' '\xe9\x1a\x62\x43' def testPackRequest0(self): bin = apply(request.UnmapWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UnmapWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUnmapSubwindows(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 2009442907, } self.req_bin_0 = '\x0b\x00\x02\x00' '\x5b\xaa\xc5\x77' def testPackRequest0(self): bin = apply(request.UnmapSubwindows._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UnmapSubwindows._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestConfigureWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 2092974410, 'attrs': {'sibling': 1102940930, 'width': 52077, 'y': -11332, 'x': -11514, 'border_width': -6900, 'stack_mode': 4, 'height': 62050}, } self.req_bin_0 = '\x0c\x00\x0a\x00' '\x4a\x41\xc0\x7c' \ '\x7f\x00\x00\x00' '\x06\xd3\x00\x00' \ '\xbc\xd3\x00\x00' '\x6d\xcb\x00\x00' \ '\x62\xf2\x00\x00' '\x0c\xe5\x00\x00' \ '\x02\x8b\xbd\x41' '\x04\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ConfigureWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ConfigureWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCirculateWindow(unittest.TestCase): def setUp(self): self.req_args_0 = { 'direction': 0, 'window': 1132872732, } self.req_bin_0 = '\x0d\x00\x02\x00' '\x1c\x44\x86\x43' def testPackRequest0(self): bin = apply(request.CirculateWindow._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CirculateWindow._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetGeometry(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 2036121058, } self.req_bin_0 = '\x0e\x00\x02\x00' '\xe2\xbd\x5c\x79' self.reply_args_0 = { 'width': 65264, 'depth': 253, 'y': -12126, 'x': -29040, 'border_width': 19896, 'root': 493091314, 'sequence_number': 36173, 'height': 9014, } self.reply_bin_0 = '\x01\xfd\x4d\x8d' '\x00\x00\x00\x00' \ '\xf2\xf9\x63\x1d' '\x90\x8e\xa2\xd0' \ '\xf0\xfe\x36\x23' '\xb8\x4d\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetGeometry._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetGeometry._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetGeometry._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetGeometry._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryTree(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 884880831, } self.req_bin_0 = '\x0f\x00\x02\x00' '\xbf\x35\xbe\x34' self.reply_args_0 = { 'parent': 701348115, 'root': 400550453, 'children': [1089242139, 925689046, 1668140638, 775016596, 1024466546, 1245533043, 1733661379], 'sequence_number': 10033, } self.reply_bin_0 = '\x01\x00\x31\x27' '\x07\x00\x00\x00' \ '\x35\xea\xdf\x17' '\x13\xb9\xcd\x29' \ '\x07\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x1b\x84\xec\x40' '\xd6\xe4\x2c\x37' \ '\x5e\xce\x6d\x63' '\x94\xd0\x31\x2e' \ '\x72\x1e\x10\x3d' '\x73\x53\x3d\x4a' \ '\xc3\x92\x55\x67' def testPackRequest0(self): bin = apply(request.QueryTree._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryTree._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryTree._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryTree._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestInternAtom(unittest.TestCase): def setUp(self): self.req_args_0 = { 'name': 'fuzzy_prop', 'only_if_exists': 0, } self.req_bin_0 = '\x10\x00\x05\x00' '\x0a\x00\x00\x00' \ '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \ '\x6f\x70\x00\x00' self.reply_args_0 = { 'sequence_number': 14401, 'atom': 1112752381, } self.reply_bin_0 = '\x01\x00\x41\x38' '\x00\x00\x00\x00' \ '\xfd\x40\x53\x42' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.InternAtom._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.InternAtom._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.InternAtom._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.InternAtom._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetAtomName(unittest.TestCase): def setUp(self): self.req_args_0 = { 'atom': 1234624354, } self.req_bin_0 = '\x11\x00\x02\x00' '\x62\xdf\x96\x49' self.reply_args_0 = { 'name': 'WM_CLASS', 'sequence_number': 2504, } self.reply_bin_0 = '\x01\x00\xc8\x09' '\x02\x00\x00\x00' \ '\x08\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53' def testPackRequest0(self): bin = apply(request.GetAtomName._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetAtomName._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetAtomName._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetAtomName._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'type': 1211092921, 'window': 1252285733, 'property': 237459721, 'data': (8, ''), 'mode': 2, } self.req_bin_0 = '\x12\x02\x06\x00' '\x25\x5d\xa4\x4a' \ '\x09\x59\x27\x0e' '\xb9\xcf\x2f\x48' \ '\x08\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_1 = { 'type': 347282449, 'window': 25619481, 'property': 633953573, 'data': (8, 'foo'), 'mode': 1, } self.req_bin_1 = '\x12\x01\x07\x00' '\x19\xec\x86\x01' \ '\x25\x5d\xc9\x25' '\x11\x1c\xb3\x14' \ '\x08\x00\x00\x00' '\x03\x00\x00\x00' \ '\x66\x6f\x6f\x00' self.req_args_2 = { 'type': 1524334051, 'window': 481797824, 'property': 658642629, 'data': (8, 'zoom'), 'mode': 1, } self.req_bin_2 = '\x12\x01\x07\x00' '\xc0\xa6\xb7\x1c' \ '\xc5\x16\x42\x27' '\xe3\x7d\xdb\x5a' \ '\x08\x00\x00\x00' '\x04\x00\x00\x00' \ '\x7a\x6f\x6f\x6d' self.req_args_3 = { 'type': 1895805524, 'window': 211607059, 'property': 27240430, 'data': (16, []), 'mode': 2, } self.req_bin_3 = '\x12\x02\x06\x00' '\x13\xde\x9c\x0c' \ '\xee\xa7\x9f\x01' '\x54\xb2\xff\x70' \ '\x10\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_4 = { 'type': 549788841, 'window': 1498238012, 'property': 1869628209, 'data': (16, [1, 2, 3]), 'mode': 0, } self.req_bin_4 = '\x12\x00\x08\x00' '\x3c\x4c\x4d\x59' \ '\x31\x43\x70\x6f' '\xa9\x1c\xc5\x20' \ '\x10\x00\x00\x00' '\x03\x00\x00\x00' \ '\x01\x00\x02\x00' '\x03\x00\x00\x00' self.req_args_5 = { 'type': 1083661140, 'window': 2019310438, 'property': 394292367, 'data': (16, [1, 2, 3, 4]), 'mode': 2, } self.req_bin_5 = '\x12\x02\x08\x00' '\x66\x3b\x5c\x78' \ '\x8f\x6c\x80\x17' '\x54\x5b\x97\x40' \ '\x10\x00\x00\x00' '\x04\x00\x00\x00' \ '\x01\x00\x02\x00' '\x03\x00\x04\x00' self.req_args_6 = { 'type': 761479544, 'window': 1274166929, 'property': 1743863777, 'data': (32, []), 'mode': 2, } self.req_bin_6 = '\x12\x02\x06\x00' '\x91\x3e\xf2\x4b' \ '\xe1\x3f\xf1\x67' '\x78\x41\x63\x2d' \ '\x20\x00\x00\x00' '\x00\x00\x00\x00' self.req_args_7 = { 'type': 956119085, 'window': 1018715281, 'property': 686054590, 'data': (32, [1, 2, 3]), 'mode': 1, } self.req_bin_7 = '\x12\x01\x09\x00' '\x91\x5c\xb8\x3c' \ '\xbe\x5c\xe4\x28' '\x2d\x38\xfd\x38' \ '\x20\x00\x00\x00' '\x03\x00\x00\x00' \ '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ '\x03\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) def testPackRequest2(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_2) try: assert bin == self.req_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest2(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_2 except AssertionError: raise AssertionError(args) def testPackRequest3(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_3) try: assert bin == self.req_bin_3 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest3(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_3, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_3 except AssertionError: raise AssertionError(args) def testPackRequest4(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_4) try: assert bin == self.req_bin_4 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest4(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_4, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_4 except AssertionError: raise AssertionError(args) def testPackRequest5(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_5) try: assert bin == self.req_bin_5 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest5(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_5, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_5 except AssertionError: raise AssertionError(args) def testPackRequest6(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_6) try: assert bin == self.req_bin_6 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest6(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_6, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_6 except AssertionError: raise AssertionError(args) def testPackRequest7(self): bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_7) try: assert bin == self.req_bin_7 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest7(self): args, remain = request.ChangeProperty._request.parse_binary(self.req_bin_7, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_7 except AssertionError: raise AssertionError(args) class TestDeleteProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1858113940, 'property': 754854074, } self.req_bin_0 = '\x13\x00\x03\x00' '\x94\x91\xc0\x6e' \ '\xba\x28\xfe\x2c' def testPackRequest0(self): bin = apply(request.DeleteProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.DeleteProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetProperty(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1675634394, 'long_offset': 11483536, 'property': 1943700626, 'type': 223769899, 'long_length': 1748032051, 'delete': 0, } self.req_bin_0 = '\x14\x00\x06\x00' '\xda\x26\xe0\x63' \ '\x92\x84\xda\x73' '\x2b\x75\x56\x0d' \ '\x90\x39\xaf\x00' '\x33\xda\x30\x68' self.reply_args_0 = { 'bytes_after': 1264377294, 'property_type': 1306970370, 'sequence_number': 34281, 'value': (8, ''), } self.reply_bin_0 = '\x01\x08\xe9\x85' '\x00\x00\x00\x00' \ '\x02\xc9\xe6\x4d' '\xce\xdd\x5c\x4b' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_1 = { 'bytes_after': 902042689, 'property_type': 1846820627, 'sequence_number': 50371, 'value': (8, 'foo'), } self.reply_bin_1 = '\x01\x08\xc3\xc4' '\x01\x00\x00\x00' \ '\x13\x3f\x14\x6e' '\x41\x14\xc4\x35' \ '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x66\x6f\x6f\x00' self.reply_args_2 = { 'bytes_after': 1782597051, 'property_type': 1613677639, 'sequence_number': 58679, 'value': (8, 'zoom'), } self.reply_bin_2 = '\x01\x08\x37\xe5' '\x01\x00\x00\x00' \ '\x47\xc4\x2e\x60' '\xbb\x45\x40\x6a' \ '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x7a\x6f\x6f\x6d' self.reply_args_3 = { 'bytes_after': 1107167742, 'property_type': 1964967674, 'sequence_number': 49647, 'value': (16, []), } self.reply_bin_3 = '\x01\x10\xef\xc1' '\x00\x00\x00\x00' \ '\xfa\x06\x1f\x75' '\xfe\x09\xfe\x41' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_4 = { 'bytes_after': 1602466976, 'property_type': 638663972, 'sequence_number': 58268, 'value': (16, [1, 2, 3]), } self.reply_bin_4 = '\x01\x10\x9c\xe3' '\x02\x00\x00\x00' \ '\x24\x3d\x11\x26' '\xa0\xb4\x83\x5f' \ '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x01\x00\x02\x00' '\x03\x00\x00\x00' self.reply_args_5 = { 'bytes_after': 651542717, 'property_type': 947428838, 'sequence_number': 26901, 'value': (16, [1, 2, 3, 4]), } self.reply_bin_5 = '\x01\x10\x15\x69' '\x02\x00\x00\x00' \ '\xe6\x9d\x78\x38' '\xbd\xc0\xd5\x26' \ '\x04\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x01\x00\x02\x00' '\x03\x00\x04\x00' self.reply_args_6 = { 'bytes_after': 602498418, 'property_type': 43558782, 'sequence_number': 11175, 'value': (32, []), } self.reply_bin_6 = '\x01\x20\xa7\x2b' '\x00\x00\x00\x00' \ '\x7e\xa7\x98\x02' '\x72\x65\xe9\x23' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' self.reply_args_7 = { 'bytes_after': 1661909208, 'property_type': 607057672, 'sequence_number': 4347, 'value': (32, [1, 2, 3]), } self.reply_bin_7 = '\x01\x20\xfb\x10' '\x03\x00\x00\x00' \ '\x08\xf7\x2e\x24' '\xd8\xb8\x0e\x63' \ '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ '\x03\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetProperty._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetProperty._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) def testPackReply2(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_2) try: assert bin == self.reply_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply2(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_2 except AssertionError: raise AssertionError(args) def testPackReply3(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_3) try: assert bin == self.reply_bin_3 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply3(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_3, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_3 except AssertionError: raise AssertionError(args) def testPackReply4(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_4) try: assert bin == self.reply_bin_4 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply4(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_4, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_4 except AssertionError: raise AssertionError(args) def testPackReply5(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_5) try: assert bin == self.reply_bin_5 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply5(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_5, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_5 except AssertionError: raise AssertionError(args) def testPackReply6(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_6) try: assert bin == self.reply_bin_6 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply6(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_6, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_6 except AssertionError: raise AssertionError(args) def testPackReply7(self): bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_7) try: assert bin == self.reply_bin_7 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply7(self): args, remain = request.GetProperty._reply.parse_binary(self.reply_bin_7, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_7 except AssertionError: raise AssertionError(args) class TestListProperties(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1002132678, } self.req_bin_0 = '\x15\x00\x02\x00' '\xc6\x54\xbb\x3b' self.reply_args_0 = { 'sequence_number': 58554, 'atoms': [497337753, 1561366096, 1429910722, 371682445, 1693790956, 124266489, 819023111, 1575252239, 1958056613, 76461795, 2044963121, 1187630009, 890357857, 639310702, 1708479530, 336050724, 1163834063, 1164094286, 1626309474, 136351014, 1163110454, 1416739018, 1380223836], } self.reply_bin_0 = '\x01\x00\xba\xe4' '\x17\x00\x00\x00' \ '\x17\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x99\xc5\xa4\x1d' '\x50\x8e\x10\x5d' \ '\xc2\xb4\x3a\x55' '\x8d\x6c\x27\x16' \ '\xec\x32\xf5\x64' '\xf9\x27\x68\x07' \ '\x07\x4d\xd1\x30' '\x0f\x71\xe4\x5d' \ '\xa5\x92\xb5\x74' '\xe3\xb6\x8e\x04' \ '\x31\xa9\xe3\x79' '\xb9\xcb\xc9\x46' \ '\x61\xc8\x11\x35' '\x6e\x1b\x1b\x26' \ '\x2a\x54\xd5\x65' '\x24\xba\x07\x14' \ '\xcf\xb2\x5e\x45' '\x4e\xab\x62\x45' \ '\x62\x83\xef\x60' '\x26\x8d\x20\x08' \ '\x36\xa8\x53\x45' '\xca\xb8\x71\x54' \ '\x5c\x8b\x44\x52' def testPackRequest0(self): bin = apply(request.ListProperties._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListProperties._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListProperties._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetSelectionOwner(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1573750861, 'selection': 984224380, 'time': 2112448956, } self.req_bin_0 = '\x16\x00\x04\x00' '\x4d\x88\xcd\x5d' \ '\x7c\x12\xaa\x3a' '\xbc\x69\xe9\x7d' def testPackRequest0(self): bin = apply(request.SetSelectionOwner._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetSelectionOwner(unittest.TestCase): def setUp(self): self.req_args_0 = { 'selection': 1209066471, } self.req_bin_0 = '\x17\x00\x02\x00' '\xe7\xe3\x10\x48' self.reply_args_0 = { 'owner': 1608499874, 'sequence_number': 40856, } self.reply_bin_0 = '\x01\x00\x98\x9f' '\x00\x00\x00\x00' \ '\xa2\xc2\xdf\x5f' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetSelectionOwner._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetSelectionOwner._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetSelectionOwner._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetSelectionOwner._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestConvertSelection(unittest.TestCase): def setUp(self): self.req_args_0 = { 'property': 116271887, 'requestor': 163844177, 'selection': 246355390, 'target': 1621875689, 'time': 385931637, } self.req_bin_0 = '\x18\x00\x06\x00' '\x51\x10\xc4\x09' \ '\xbe\x15\xaf\x0e' '\xe9\xdb\xab\x60' \ '\x0f\x2b\xee\x06' '\x75\xd9\x00\x17' def testPackRequest0(self): bin = apply(request.ConvertSelection._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ConvertSelection._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSendEvent(unittest.TestCase): def setUp(self): self.req_args_0 = { 'event_mask': 985979728, 'destination': 1646910168, 'propagate': 1, 'event': Xlib.protocol.event.Expose(count = 7721, width = 18606, window = 1339231972, y = 45287, x = 46510, type = 12, sequence_number = 0, height = 44735), } self.req_bin_0 = '\x19\x01\x0b\x00' '\xd8\xda\x29\x62' \ '\x50\xdb\xc4\x3a' '\x0c\x00\x00\x00' \ '\xe4\x0e\xd3\x4f' '\xae\xb5\xe7\xb0' \ '\xae\x48\xbf\xae' '\x29\x1e\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SendEvent._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SendEvent._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 1773330151, 'keyboard_mode': 0, 'pointer_mode': 1, 'event_mask': 27410, 'confine_to': 1526915530, 'time': 1195309735, 'grab_window': 1295558486, 'owner_events': 1, } self.req_bin_0 = '\x1a\x01\x06\x00' '\x56\xa7\x38\x4d' \ '\x12\x6b\x01\x00' '\xca\xe1\x02\x5b' \ '\xe7\xde\xb2\x69' '\xa7\xfa\x3e\x47' self.reply_args_0 = { 'status': 166, 'sequence_number': 9454, } self.reply_bin_0 = '\x01\xa6\xee\x24' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GrabPointer._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GrabPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestUngrabPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 1647345145, } self.req_bin_0 = '\x1b\x00\x02\x00' '\xf9\x7d\x30\x62' def testPackRequest0(self): bin = apply(request.UngrabPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabButton(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 1510380761, 'keyboard_mode': 0, 'modifiers': 62613, 'pointer_mode': 1, 'event_mask': 23716, 'confine_to': 2062912931, 'button': 169, 'grab_window': 2055413885, 'owner_events': 0, } self.req_bin_0 = '\x1c\x00\x06\x00' '\x7d\x20\x83\x7a' \ '\xa4\x5c\x01\x00' '\xa3\x8d\xf5\x7a' \ '\xd9\x94\x06\x5a' '\xa9\x00\x95\xf4' def testPackRequest0(self): bin = apply(request.GrabButton._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabButton(unittest.TestCase): def setUp(self): self.req_args_0 = { 'button': 220, 'modifiers': 32389, 'grab_window': 1891977189, } self.req_bin_0 = '\x1d\xdc\x03\x00' '\xe5\x47\xc5\x70' \ '\x85\x7e\x00\x00' def testPackRequest0(self): bin = apply(request.UngrabButton._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabButton._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeActivePointerGrab(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 777967884, 'event_mask': 12743, 'time': 197998305, } self.req_bin_0 = '\x1e\x00\x04\x00' '\x0c\xd9\x5e\x2e' \ '\xe1\x36\xcd\x0b' '\xc7\x31\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeActivePointerGrab._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeActivePointerGrab._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabKeyboard(unittest.TestCase): def setUp(self): self.req_args_0 = { 'keyboard_mode': 1, 'time': 1696403859, 'pointer_mode': 0, 'grab_window': 316814295, 'owner_events': 0, } self.req_bin_0 = '\x1f\x00\x04\x00' '\xd7\x33\xe2\x12' \ '\x93\x11\x1d\x65' '\x00\x01\x00\x00' self.reply_args_0 = { 'status': 239, 'sequence_number': 46747, } self.reply_bin_0 = '\x01\xef\x9b\xb6' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabKeyboard._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GrabKeyboard._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GrabKeyboard._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestUngrabKeyboard(unittest.TestCase): def setUp(self): self.req_args_0 = { 'time': 4211611, } self.req_bin_0 = '\x20\x00\x02\x00' '\x9b\x43\x40\x00' def testPackRequest0(self): bin = apply(request.UngrabKeyboard._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabKeyboard._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabKey(unittest.TestCase): def setUp(self): self.req_args_0 = { 'keyboard_mode': 0, 'modifiers': 62007, 'key': 175, 'pointer_mode': 0, 'grab_window': 882662093, 'owner_events': 1, } self.req_bin_0 = '\x21\x01\x04\x00' '\xcd\x5a\x9c\x34' \ '\x37\xf2\xaf\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GrabKey._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabKey(unittest.TestCase): def setUp(self): self.req_args_0 = { 'modifiers': 18590, 'grab_window': 1389213966, 'key': 141, } self.req_bin_0 = '\x22\x8d\x03\x00' '\x0e\xb9\xcd\x52' \ '\x9e\x48\x00\x00' def testPackRequest0(self): bin = apply(request.UngrabKey._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabKey._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestAllowEvents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 7, 'time': 1088990319, } self.req_bin_0 = '\x23\x07\x02\x00' '\x6f\xac\xe8\x40' def testPackRequest0(self): bin = apply(request.AllowEvents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllowEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGrabServer(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x24\x00\x01\x00' def testPackRequest0(self): bin = apply(request.GrabServer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUngrabServer(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x25\x00\x01\x00' def testPackRequest0(self): bin = apply(request.UngrabServer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UngrabServer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 358895460, } self.req_bin_0 = '\x26\x00\x02\x00' '\x64\x4f\x64\x15' self.reply_args_0 = { 'same_screen': 1, 'child': 2139990686, 'win_x': -30717, 'root_y': -18418, 'root_x': -2403, 'root': 1853596468, 'mask': 14486, 'sequence_number': 29530, 'win_y': -19690, } self.reply_bin_0 = '\x01\x01\x5a\x73' '\x00\x00\x00\x00' \ '\x34\xa3\x7b\x6e' '\x9e\xaa\x8d\x7f' \ '\x9d\xf6\x0e\xb8' '\x03\x88\x16\xb3' \ '\x96\x38\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryPointer._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryPointer._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetMotionEvents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'start': 2110367101, 'window': 528148429, 'stop': 1808786083, } self.req_bin_0 = '\x27\x00\x04\x00' '\xcd\xe7\x7a\x1f' \ '\x7d\xa5\xc9\x7d' '\xa3\xe2\xcf\x6b' self.reply_args_0 = { 'events': [{'y': -23108, 'x': -3461, 'time': 984326273}, {'y': -4096, 'x': -4908, 'time': 488459157}, {'y': -29782, 'x': -8325, 'time': 1162935901}, {'y': -26418, 'x': -10559, 'time': 275816904}, {'y': -3941, 'x': -2216, 'time': 656439277}], 'sequence_number': 42652, } self.reply_bin_0 = '\x01\x00\x9c\xa6' '\x0a\x00\x00\x00' \ '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x81\xa0\xab\x3a' '\x7b\xf2\xbc\xa5' \ '\x95\x4b\x1d\x1d' '\xd4\xec\x00\xf0' \ '\x5d\xfe\x50\x45' '\x7b\xdf\xaa\x8b' \ '\xc8\xa1\x70\x10' '\xc1\xd6\xce\x98' \ '\xed\x77\x20\x27' '\x58\xf7\x9b\xf0' def testPackRequest0(self): bin = apply(request.GetMotionEvents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetMotionEvents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetMotionEvents._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetMotionEvents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestTranslateCoords(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dst_wid': 246042608, 'src_wid': 1251919501, 'src_x': -18176, 'src_y': -309, } self.req_bin_0 = '\x28\x00\x04\x00' '\x8d\xc6\x9e\x4a' \ '\xf0\x4f\xaa\x0e' '\x00\xb9\xcb\xfe' self.reply_args_0 = { 'y': -24269, 'x': -29750, 'sequence_number': 39515, 'same_screen': 0, 'child': 1548917071, } self.reply_bin_0 = '\x01\x00\x5b\x9a' '\x00\x00\x00\x00' \ '\x4f\x99\x52\x5c' '\xca\x8b\x33\xa1' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.TranslateCoords._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.TranslateCoords._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.TranslateCoords._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.TranslateCoords._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestWarpPointer(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_x': -1322, 'dst_x': -15518, 'src_width': 45129, 'src_height': 8451, 'src_y': -13238, 'dst_y': -26121, 'dst_window': 2139748563, 'src_window': 1945176770, } self.req_bin_0 = '\x29\x00\x06\x00' '\xc2\x0a\xf1\x73' \ '\xd3\xf8\x89\x7f' '\xd6\xfa\x4a\xcc' \ '\x49\xb0\x03\x21' '\x62\xc3\xf7\x99' def testPackRequest0(self): bin = apply(request.WarpPointer._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.WarpPointer._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetInputFocus(unittest.TestCase): def setUp(self): self.req_args_0 = { 'revert_to': 0, 'focus': 1068495705, 'time': 342883486, } self.req_bin_0 = '\x2a\x00\x03\x00' '\x59\xf3\xaf\x3f' \ '\x9e\xfc\x6f\x14' def testPackRequest0(self): bin = apply(request.SetInputFocus._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetInputFocus(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x2b\x00\x01\x00' self.reply_args_0 = { 'revert_to': 129, 'focus': 1884243837, 'sequence_number': 9052, } self.reply_bin_0 = '\x01\x81\x5c\x23' '\x00\x00\x00\x00' \ '\x7d\x47\x4f\x70' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetInputFocus._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetInputFocus._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetInputFocus._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetInputFocus._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryKeymap(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x2c\x00\x01\x00' self.reply_args_0 = { 'map': [175, 212, 207, 139, 156, 192, 230, 219, 136, 198, 152, 156, 229, 233, 221, 209, 131, 229, 209, 249, 130, 189, 183, 135, 238, 149, 131, 204, 162, 229, 149, 246], 'sequence_number': 19383, } self.reply_bin_0 = '\x01\x00\xb7\x4b' '\x02\x00\x00\x00' \ '\xaf\xd4\xcf\x8b' '\x9c\xc0\xe6\xdb' \ '\x88\xc6\x98\x9c' '\xe5\xe9\xdd\xd1' \ '\x83\xe5\xd1\xf9' '\x82\xbd\xb7\x87' \ '\xee\x95\x83\xcc' '\xa2\xe5\x95\xf6' def testPackRequest0(self): bin = apply(request.QueryKeymap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryKeymap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryKeymap._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryKeymap._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestOpenFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'name': 'foofont', 'fid': 1809550053, } self.req_bin_0 = '\x2d\x00\x05\x00' '\xe5\x8a\xdb\x6b' \ '\x07\x00\x00\x00' '\x66\x6f\x6f\x66' \ '\x6f\x6e\x74\x00' def testPackRequest0(self): bin = apply(request.OpenFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.OpenFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCloseFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 405865016, } self.req_bin_0 = '\x2e\x00\x02\x00' '\x38\x02\x31\x18' def testPackRequest0(self): bin = apply(request.CloseFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CloseFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryFont(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 173413537, } self.req_bin_0 = '\x2f\x00\x02\x00' '\xa1\x14\x56\x0a' self.reply_args_0 = { 'max_bounds': {'left_side_bearing': -27346, 'descent': -13574, 'right_side_bearing': -29649, 'attributes': 58157, 'character_width': -6055, 'ascent': -4810}, 'all_chars_exist': 0, 'font_ascent': -15846, 'font_descent': -913, 'draw_direction': 165, 'min_char_or_byte2': 53512, 'default_char': 28435, 'max_char_or_byte2': 48394, 'min_bounds': {'left_side_bearing': -8151, 'descent': -28819, 'right_side_bearing': -31752, 'attributes': 52666, 'character_width': -19612, 'ascent': -9876}, 'char_infos': [{'left_side_bearing': -20738, 'descent': -15296, 'right_side_bearing': -2753, 'attributes': 64507, 'character_width': -12227, 'ascent': -13881}, {'left_side_bearing': -10754, 'descent': -1625, 'right_side_bearing': -9647, 'attributes': 29864, 'character_width': -26871, 'ascent': -11229}, {'left_side_bearing': -30834, 'descent': -16816, 'right_side_bearing': -27729, 'attributes': 56962, 'character_width': -4251, 'ascent': -12215}], 'max_byte1': 219, 'min_byte1': 195, 'properties': [{'name': 515636466, 'value': 1798456662}], 'sequence_number': 52469, } self.reply_bin_0 = '\x01\x00\xf5\xcc' '\x12\x00\x00\x00' \ '\x29\xe0\xf8\x83' '\x64\xb3\x6c\xd9' \ '\x6d\x8f\xba\xcd' '\x00\x00\x00\x00' \ '\x2e\x95\x2f\x8c' '\x59\xe8\x36\xed' \ '\xfa\xca\x2d\xe3' '\x00\x00\x00\x00' \ '\x08\xd1\x0a\xbd' '\x13\x6f\x01\x00' \ '\xa5\xc3\xdb\x00' '\x1a\xc2\x6f\xfc' \ '\x03\x00\x00\x00' '\xf2\xfc\xbb\x1e' \ '\x56\x45\x32\x6b' '\xfe\xae\x3f\xf5' \ '\x3d\xd0\xc7\xc9' '\x40\xc4\xfb\xfb' \ '\xfe\xd5\x51\xda' '\x09\x97\x23\xd4' \ '\xa7\xf9\xa8\x74' '\x8e\x87\xaf\x93' \ '\x65\xef\x49\xd0' '\x50\xbe\x82\xde' def testPackRequest0(self): bin = apply(request.QueryFont._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryFont._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryFont._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryFont._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryTextExtents(unittest.TestCase): def setUp(self): self.req_args_0 = { 'font': 1637171782, 'string': (102, 111, 111), } self.req_bin_0 = '\x30\x01\x04\x00' '\x46\x42\x95\x61' \ '\x00\x66\x00\x6f' '\x00\x6f\x00\x00' self.reply_args_0 = { 'font_descent': -10581, 'overall_left': -1212859291, 'draw_direction': 195, 'overall_right': -813911398, 'overall_descent': -19862, 'overall_ascent': -32654, 'font_ascent': -22971, 'sequence_number': 6206, 'overall_width': -127705892, } self.reply_bin_0 = '\x01\xc3\x3e\x18' '\x00\x00\x00\x00' \ '\x45\xa6\xab\xd6' '\x72\x80\x6a\xb2' \ '\xdc\x5c\x63\xf8' '\x65\x3c\xb5\xb7' \ '\x9a\xb2\x7c\xcf' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryTextExtents._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryTextExtents._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryTextExtents._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryTextExtents._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListFonts(unittest.TestCase): def setUp(self): self.req_args_0 = { 'pattern': 'bhazr', 'max_names': 57427, } self.req_bin_0 = '\x31\x00\x04\x00' '\x53\xe0\x05\x00' \ '\x62\x68\x61\x7a' '\x72\x00\x00\x00' self.reply_args_0 = { 'fonts': ['fie', 'fuzzy', 'foozooom'], 'sequence_number': 39409, } self.reply_bin_0 = '\x01\x00\xf1\x99' '\x05\x00\x00\x00' \ '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \ '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \ '\x6f\x6f\x6d\x00' def testPackRequest0(self): bin = apply(request.ListFonts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListFonts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListFonts._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListFonts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListFontsWithInfo(unittest.TestCase): def setUp(self): self.req_args_0 = { 'pattern': 'bhazr2', 'max_names': 52288, } self.req_bin_0 = '\x32\x00\x04\x00' '\x40\xcc\x06\x00' \ '\x62\x68\x61\x7a' '\x72\x32\x00\x00' self.reply_args_0 = { 'max_bounds': {'left_side_bearing': -9255, 'descent': -26305, 'right_side_bearing': -6756, 'attributes': 49084, 'character_width': -4462, 'ascent': -3529}, 'all_chars_exist': 1, 'font_ascent': -26930, 'name': 'fontfont', 'replies_hint': 1755082535, 'font_descent': -25033, 'draw_direction': 229, 'min_char_or_byte2': 65093, 'default_char': 39019, 'max_char_or_byte2': 45170, 'min_bounds': {'left_side_bearing': -8350, 'descent': -16956, 'right_side_bearing': -19578, 'attributes': 27352, 'character_width': -20897, 'ascent': -9972}, 'max_byte1': 221, 'min_byte1': 158, 'properties': [{'name': 213588122, 'value': 1789263183}], 'sequence_number': 43812, } self.reply_bin_0 = '\x01\x08\x24\xab' '\x0b\x00\x00\x00' \ '\x62\xdf\x86\xb3' '\x5f\xae\x0c\xd9' \ '\xc4\xbd\xd8\x6a' '\x00\x00\x00\x00' \ '\xd9\xdb\x9c\xe5' '\x92\xee\x37\xf2' \ '\x3f\x99\xbc\xbf' '\x00\x00\x00\x00' \ '\x45\xfe\x72\xb0' '\x6b\x98\x01\x00' \ '\xe5\x9e\xdd\x01' '\xce\x96\x37\x9e' \ '\x27\x6f\x9c\x68' '\x9a\x18\xbb\x0c' \ '\x4f\xfd\xa5\x6a' '\x66\x6f\x6e\x74' \ '\x66\x6f\x6e\x74' def testPackRequest0(self): bin = apply(request.ListFontsWithInfo._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListFontsWithInfo._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListFontsWithInfo._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListFontsWithInfo._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetFontPath(unittest.TestCase): def setUp(self): self.req_args_0 = { 'path': ['foo', 'bar', 'gazonk'], } self.req_bin_0 = '\x33\x00\x06\x00' '\x03\x00\x00\x00' \ '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \ '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00' self.req_args_1 = { 'path': [], } self.req_bin_1 = '\x33\x00\x02\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.SetFontPath._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) class TestGetFontPath(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x34\x00\x01\x00' self.reply_args_0 = { 'paths': ['path1', 'path2232'], 'sequence_number': 17086, } self.reply_bin_0 = '\x01\x00\xbe\x42' '\x04\x00\x00\x00' \ '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x05\x70\x61\x74' '\x68\x31\x08\x70' \ '\x61\x74\x68\x32' '\x32\x33\x32\x00' self.reply_args_1 = { 'paths': [], 'sequence_number': 8511, } self.reply_bin_1 = '\x01\x00\x3f\x21' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetFontPath._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetFontPath._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.GetFontPath._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) class TestCreatePixmap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'width': 32332, 'depth': 179, 'pid': 847631690, 'drawable': 1358709134, 'height': 16464, } self.req_bin_0 = '\x35\xb3\x04\x00' '\x4a\xd5\x85\x32' \ '\x8e\x41\xfc\x50' '\x4c\x7e\x50\x40' def testPackRequest0(self): bin = apply(request.CreatePixmap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreatePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreePixmap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'pixmap': 1323266674, } self.req_bin_0 = '\x36\x00\x02\x00' '\x72\x72\xdf\x4e' def testPackRequest0(self): bin = apply(request.FreePixmap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreePixmap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 830249906, 'attrs': {'function': 14, 'foreground': 814230008, 'background': 2072616911, 'clip_x_origin': -6987, 'subwindow_mode': 0, 'cap_style': 1, 'fill_style': 3, 'tile_stipple_y_origin': -25870, 'font': 264499208, 'graphics_exposures': 0, 'join_style': 2, 'line_width': 36600, 'stipple': 870974399, 'dash_offset': 49599, 'clip_y_origin': -5712, 'tile_stipple_x_origin': -32365, 'arc_mode': 0, 'tile': 1597988019, 'line_style': 2, 'plane_mask': 1650697305, 'clip_mask': 402937862, 'fill_rule': 0, 'dashes': 136}, 'cid': 779296774, } self.req_bin_0 = '\x37\x00\x1b\x00' '\x06\x20\x73\x2e' \ '\xb2\x9b\x7c\x31' '\xff\xff\x7f\x00' \ '\x0e\x00\x00\x00' '\x59\xa4\x63\x62' \ '\xf8\x29\x88\x30' '\xcf\x9f\x89\x7b' \ '\xf8\x8e\x00\x00' '\x02\x00\x00\x00' \ '\x01\x00\x00\x00' '\x02\x00\x00\x00' \ '\x03\x00\x00\x00' '\x00\x00\x00\x00' \ '\xb3\x5c\x3f\x5f' '\xbf\x03\xea\x33' \ '\x93\x81\x00\x00' '\xf2\x9a\x00\x00' \ '\x08\xf0\xc3\x0f' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\xb5\xe4\x00\x00' \ '\xb0\xe9\x00\x00' '\x06\x58\x04\x18' \ '\xbf\xc1\x00\x00' '\x88\x00\x00\x00' \ '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.CreateGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangeGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 1996372624, 'attrs': {'function': 15, 'foreground': 1817174045, 'background': 840850119, 'clip_x_origin': -28415, 'subwindow_mode': 1, 'cap_style': 0, 'fill_style': 0, 'tile_stipple_y_origin': -24832, 'font': 240535139, 'graphics_exposures': 1, 'join_style': 2, 'line_width': 64290, 'stipple': 1739313208, 'dash_offset': 53189, 'clip_y_origin': -2802, 'tile_stipple_x_origin': -4548, 'arc_mode': 1, 'tile': 1091199324, 'line_style': 2, 'plane_mask': 1403123174, 'clip_mask': 1604118463, 'fill_rule': 1, 'dashes': 186}, } self.req_bin_0 = '\x38\x00\x1a\x00' '\x90\x3a\xfe\x76' \ '\xff\xff\x7f\x00' '\x0f\x00\x00\x00' \ '\xe6\xf5\xa1\x53' '\x1d\xe0\x4f\x6c' \ '\xc7\x5a\x1e\x32' '\x22\xfb\x00\x00' \ '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ '\x01\x00\x00\x00' '\x5c\x61\x0a\x41' \ '\x38\xd0\xab\x67' '\x3c\xee\x00\x00' \ '\x00\x9f\x00\x00' '\x63\x46\x56\x0e' \ '\x01\x00\x00\x00' '\x01\x00\x00\x00' \ '\x01\x91\x00\x00' '\x0e\xf5\x00\x00' \ '\xbf\xe7\x9c\x5f' '\xc5\xcf\x00\x00' \ '\xba\x00\x00\x00' '\x01\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_gc': 1605257018, 'dst_gc': 2046321491, 'mask': 996538407, } self.req_bin_0 = '\x39\x00\x04\x00' '\x3a\x47\xae\x5f' \ '\x53\x63\xf8\x79' '\x27\xf8\x65\x3b' def testPackRequest0(self): bin = apply(request.CopyGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetDashes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dash_offset': 34958, 'gc': 2119954025, 'dashes': [146, 217, 181, 229, 212, 175, 201, 251, 248], } self.req_bin_0 = '\x3a\x00\x06\x00' '\x69\xee\x5b\x7e' \ '\x8e\x88\x09\x00' '\x92\xd9\xb5\xe5' \ '\xd4\xaf\xc9\xfb' '\xf8\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetDashes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetDashes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetClipRectangles(unittest.TestCase): def setUp(self): self.req_args_0 = { 'ordering': 3, 'gc': 2028835270, 'y_origin': -15522, 'rectangles': [{'y': -27524, 'x': -27245, 'height': 31014, 'width': 52432}, {'y': -8991, 'x': -11302, 'height': 9053, 'width': 11072}], 'x_origin': -26003, } self.req_bin_0 = '\x3b\x03\x07\x00' '\xc6\x91\xed\x78' \ '\x6d\x9a\x5e\xc3' '\x93\x95\x7c\x94' \ '\xd0\xcc\x26\x79' '\xda\xd3\xe1\xdc' \ '\x40\x2b\x5d\x23' self.req_args_1 = { 'ordering': 1, 'gc': 155607949, 'y_origin': -32694, 'rectangles': [], 'x_origin': -23382, } self.req_bin_1 = '\x3b\x01\x03\x00' '\x8d\x63\x46\x09' \ '\xaa\xa4\x4a\x80' def testPackRequest0(self): bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.SetClipRectangles._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) class TestFreeGC(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 533809208, } self.req_bin_0 = '\x3c\x00\x02\x00' '\x38\x48\xd1\x1f' def testPackRequest0(self): bin = apply(request.FreeGC._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeGC._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestClearArea(unittest.TestCase): def setUp(self): self.req_args_0 = { 'width': 25049, 'window': 451215820, 'y': -6435, 'x': -30623, 'exposures': 0, 'height': 27400, } self.req_bin_0 = '\x3d\x00\x04\x00' '\xcc\x01\xe5\x1a' \ '\x61\x88\xdd\xe6' '\xd9\x61\x08\x6b' def testPackRequest0(self): bin = apply(request.ClearArea._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ClearArea._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyArea(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dst_y': -10208, 'dst_x': -3325, 'gc': 544091206, 'src_x': -14979, 'src_y': -25188, 'dst_drawable': 1518430886, 'height': 46849, 'width': 46860, 'src_drawable': 197047820, } self.req_bin_0 = '\x3e\x00\x07\x00' '\x0c\xb6\xbe\x0b' \ '\xa6\x6a\x81\x5a' '\x46\x2c\x6e\x20' \ '\x7d\xc5\x9c\x9d' '\x03\xf3\x20\xd8' \ '\x0c\xb7\x01\xb7' def testPackRequest0(self): bin = apply(request.CopyArea._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyArea._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyPlane(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dst_y': -24783, 'dst_x': -17393, 'bit_plane': 121248642, 'gc': 2016534076, 'src_x': -15677, 'src_y': -24535, 'dst_drawable': 626526507, 'height': 9260, 'width': 12445, 'src_drawable': 1825271175, } self.req_bin_0 = '\x3f\x00\x08\x00' '\x87\x6d\xcb\x6c' \ '\x2b\x09\x58\x25' '\x3c\xde\x31\x78' \ '\xc3\xc2\x29\xa0' '\x0f\xbc\x31\x9f' \ '\x9d\x30\x2c\x24' '\x82\x1b\x3a\x07' def testPackRequest0(self): bin = apply(request.CopyPlane._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyPlane._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyPoint(unittest.TestCase): def setUp(self): self.req_args_0 = { 'coord_mode': 0, 'drawable': 1127406891, 'points': [{'y': -18047, 'x': -19763}, {'y': -5351, 'x': -20174}, {'y': -10573, 'x': -29362}], 'gc': 1752128743, } self.req_bin_0 = '\x40\x00\x06\x00' '\x2b\xdd\x32\x43' \ '\xe7\x5c\x6f\x68' '\xcd\xb2\x81\xb9' \ '\x32\xb1\x19\xeb' '\x4e\x8d\xb3\xd6' def testPackRequest0(self): bin = apply(request.PolyPoint._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyPoint._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyLine(unittest.TestCase): def setUp(self): self.req_args_0 = { 'coord_mode': 1, 'drawable': 1354888255, 'points': [{'y': -22360, 'x': -25237}, {'y': -21145, 'x': -28948}, {'y': -16928, 'x': -3515}, {'y': -25838, 'x': -12335}, {'y': -31134, 'x': -12944}], 'gc': 1308624032, } self.req_bin_0 = '\x41\x01\x08\x00' '\x3f\xf4\xc1\x50' \ '\xa0\x04\x00\x4e' '\x6b\x9d\xa8\xa8' \ '\xec\x8e\x67\xad' '\x45\xf2\xe0\xbd' \ '\xd1\xcf\x12\x9b' '\x70\xcd\x62\x86' def testPackRequest0(self): bin = apply(request.PolyLine._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyLine._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolySegment(unittest.TestCase): def setUp(self): self.req_args_0 = { 'segments': [{'y1': -3160, 'x2': -5139, 'x1': -2249, 'y2': -26872}], 'gc': 2022424938, 'drawable': 158182613, } self.req_bin_0 = '\x42\x00\x05\x00' '\xd5\xac\x6d\x09' \ '\x6a\xc1\x8b\x78' '\x37\xf7\xa8\xf3' \ '\xed\xeb\x08\x97' def testPackRequest0(self): bin = apply(request.PolySegment._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolySegment._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyRectangle(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 1036376211, 'drawable': 2136753875, 'rectangles': [{'y': -29358, 'x': -6957, 'height': 19230, 'width': 32377}, {'y': -23694, 'x': -2777, 'height': 48827, 'width': 42548}, {'y': -22773, 'x': -12641, 'height': 9809, 'width': 30955}], } self.req_bin_0 = '\x43\x00\x09\x00' '\xd3\x46\x5c\x7f' \ '\x93\xd8\xc5\x3d' '\xd3\xe4\x52\x8d' \ '\x79\x7e\x1e\x4b' '\x27\xf5\x72\xa3' \ '\x34\xa6\xbb\xbe' '\x9f\xce\x0b\xa7' \ '\xeb\x78\x51\x26' def testPackRequest0(self): bin = apply(request.PolyRectangle._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyArc(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 2066514582, 'gc': 956699423, 'arcs': [{'width': 36714, 'angle1': -22260, 'angle2': -28493, 'y': -394, 'x': -6756, 'height': 63498}, {'width': 31212, 'angle1': -5166, 'angle2': -19039, 'y': -11179, 'x': -20569, 'height': 27113}, {'width': 62033, 'angle1': -18595, 'angle2': -26291, 'y': -8396, 'x': -7987, 'height': 11428}], } self.req_bin_0 = '\x44\x00\x0c\x00' '\x96\x82\x2c\x7b' \ '\x1f\x13\x06\x39' '\x9c\xe5\x76\xfe' \ '\x6a\x8f\x0a\xf8' '\x0c\xa9\xb3\x90' \ '\xa7\xaf\x55\xd4' '\xec\x79\xe9\x69' \ '\xd2\xeb\xa1\xb5' '\xcd\xe0\x34\xdf' \ '\x51\xf2\xa4\x2c' '\x5d\xb7\x4d\x99' def testPackRequest0(self): bin = apply(request.PolyArc._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyArc._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFillPoly(unittest.TestCase): def setUp(self): self.req_args_0 = { 'coord_mode': 1, 'drawable': 526750870, 'points': [{'y': -765, 'x': -11821}, {'y': -10853, 'x': -1907}, {'y': -29710, 'x': -468}], 'gc': 112110920, 'shape': 0, } self.req_bin_0 = '\x45\x00\x07\x00' '\x96\x94\x65\x1f' \ '\x48\xad\xae\x06' '\x00\x01\x00\x00' \ '\xd3\xd1\x03\xfd' '\x8d\xf8\x9b\xd5' \ '\x2c\xfe\xf2\x8b' def testPackRequest0(self): bin = apply(request.FillPoly._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FillPoly._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyFillRectangle(unittest.TestCase): def setUp(self): self.req_args_0 = { 'gc': 468793444, 'drawable': 878946804, 'rectangles': [{'y': -29169, 'x': -18095, 'height': 15301, 'width': 12078}, {'y': -7148, 'x': -18997, 'height': 7501, 'width': 17120}], } self.req_bin_0 = '\x46\x00\x07\x00' '\xf4\xa9\x63\x34' \ '\x64\x38\xf1\x1b' '\x51\xb9\x0f\x8e' \ '\x2e\x2f\xc5\x3b' '\xcb\xb5\x14\xe4' \ '\xe0\x42\x4d\x1d' def testPackRequest0(self): bin = apply(request.PolyFillRectangle._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyFillRectangle._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyFillArc(unittest.TestCase): def setUp(self): self.req_args_0 = { 'drawable': 1286339124, 'gc': 1256983120, 'arcs': [{'width': 62526, 'angle1': -17496, 'angle2': -20949, 'y': -21843, 'x': -31746, 'height': 59073}], } self.req_bin_0 = '\x47\x00\x06\x00' '\x34\xfa\xab\x4c' \ '\x50\x0a\xec\x4a' '\xfe\x83\xad\xaa' \ '\x3e\xf4\xc1\xe6' '\xa8\xbb\x2b\xae' def testPackRequest0(self): bin = apply(request.PolyFillArc._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyFillArc._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPutImage(unittest.TestCase): def setUp(self): self.req_args_0 = { 'dst_y': -18744, 'width': 39512, 'left_pad': 222, 'gc': 1858057277, 'dst_x': -9189, 'format': 2, 'drawable': 935710750, 'data': 'bit map data', 'depth': 218, 'height': 16464, } self.req_bin_0 = '\x48\x02\x09\x00' '\x1e\xd0\xc5\x37' \ '\x3d\xb4\xbf\x6e' '\x58\x9a\x50\x40' \ '\x1b\xdc\xc8\xb6' '\xde\xda\x00\x00' \ '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \ '\x64\x61\x74\x61' def testPackRequest0(self): bin = apply(request.PutImage._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PutImage._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetImage(unittest.TestCase): def setUp(self): self.req_args_0 = { 'width': 47689, 'format': 1, 'y': -2692, 'x': -32705, 'drawable': 377616775, 'plane_mask': 849117586, 'height': 24480, } self.req_bin_0 = '\x49\x01\x05\x00' '\x87\xf9\x81\x16' \ '\x3f\x80\x7c\xf5' '\x49\xba\xa0\x5f' \ '\x92\x81\x9c\x32' self.reply_args_0 = { 'depth': 249, 'data': 'this is real ly imag e b-map', 'visual': 141686402, 'sequence_number': 47197, } self.reply_bin_0 = '\x01\xf9\x5d\xb8' '\x07\x00\x00\x00' \ '\x82\xf6\x71\x08' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x74\x68\x69\x73' '\x20\x69\x73\x20' \ '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \ '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \ '\x2d\x6d\x61\x70' def testPackRequest0(self): bin = apply(request.GetImage._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetImage._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetImage._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetImage._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestPolyText8(unittest.TestCase): def setUp(self): self.req_args_0 = { 'y': -7036, 'items': [{'string': 'zoo', 'delta': 2}, 16909060, {'string': 'ie', 'delta': 0}], 'drawable': 1736403224, 'gc': 1348241590, 'x': -27139, } self.req_bin_0 = '\x4a\x00\x08\x00' '\x18\x69\x7f\x67' \ '\xb6\x88\x5c\x50' '\xfd\x95\x84\xe4' \ '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \ '\x03\x04\x02\x00' '\x69\x65\x00\x00' def testPackRequest0(self): bin = apply(request.PolyText8._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyText8._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestPolyText16(unittest.TestCase): def setUp(self): self.req_args_0 = { 'y': -10535, 'items': [{'string': (4131, 18), 'delta': 2}, 16909060], 'drawable': 1669371472, 'gc': 327278878, 'x': -31319, } self.req_bin_0 = '\x4b\x00\x07\x00' '\x50\x96\x80\x63' \ '\x1e\xe1\x81\x13' '\xa9\x85\xd9\xd6' \ '\x02\x02\x10\x23' '\x00\x12\xff\x01' \ '\x02\x03\x04\x00' def testPackRequest0(self): bin = apply(request.PolyText16._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.PolyText16._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestImageText8(unittest.TestCase): def setUp(self): self.req_args_0 = { 'y': -3727, 'x': -15149, 'drawable': 2131605072, 'gc': 581816261, 'string': 'showme', } self.req_bin_0 = '\x4c\x06\x06\x00' '\x50\xb6\x0d\x7f' \ '\xc5\xcf\xad\x22' '\xd3\xc4\x71\xf1' \ '\x73\x68\x6f\x77' '\x6d\x65\x00\x00' def testPackRequest0(self): bin = apply(request.ImageText8._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ImageText8._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestImageText16(unittest.TestCase): def setUp(self): self.req_args_0 = { 'y': -1074, 'x': -2847, 'drawable': 1442818198, 'gc': 145495998, 'string': (115, 104, 111, 119, 109, 111, 114, 101), } self.req_bin_0 = '\x4d\x08\x08\x00' '\x96\xa8\xff\x55' \ '\xbe\x17\xac\x08' '\xe1\xf4\xce\xfb' \ '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \ '\x00\x6d\x00\x6f' '\x00\x72\x00\x65' def testPackRequest0(self): bin = apply(request.ImageText16._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ImageText16._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'alloc': 0, 'window': 1386427589, 'visual': 1165319270, 'mid': 1982619692, } self.req_bin_0 = '\x4e\x00\x04\x00' '\x2c\x60\x2c\x76' \ '\xc5\x34\xa3\x52' '\x66\x5c\x75\x45' def testPackRequest0(self): bin = apply(request.CreateColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreeColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1948229362, } self.req_bin_0 = '\x4f\x00\x02\x00' '\xf2\x9e\x1f\x74' def testPackRequest0(self): bin = apply(request.FreeColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCopyColormapAndFree(unittest.TestCase): def setUp(self): self.req_args_0 = { 'src_cmap': 836376231, 'mid': 1781544437, } self.req_bin_0 = '\x50\x00\x03\x00' '\xf5\x35\x30\x6a' \ '\xa7\x16\xda\x31' def testPackRequest0(self): bin = apply(request.CopyColormapAndFree._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CopyColormapAndFree._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestInstallColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1065317214, } self.req_bin_0 = '\x51\x00\x02\x00' '\x5e\x73\x7f\x3f' def testPackRequest0(self): bin = apply(request.InstallColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.InstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestUninstallColormap(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1636916558, } self.req_bin_0 = '\x52\x00\x02\x00' '\x4e\x5d\x91\x61' def testPackRequest0(self): bin = apply(request.UninstallColormap._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.UninstallColormap._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestListInstalledColormaps(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 198767900, } self.req_bin_0 = '\x53\x00\x02\x00' '\x1c\xf5\xd8\x0b' self.reply_args_0 = { 'cmaps': [6854304, 441133660], 'sequence_number': 56438, } self.reply_bin_0 = '\x01\x00\x76\xdc' '\x02\x00\x00\x00' \ '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\xa0\x96\x68\x00' '\x5c\x2a\x4b\x1a' def testPackRequest0(self): bin = apply(request.ListInstalledColormaps._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListInstalledColormaps._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListInstalledColormaps._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListInstalledColormaps._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'blue': 57892, 'cmap': 1775908575, 'green': 61383, 'red': 8870, } self.req_bin_0 = '\x54\x00\x04\x00' '\xdf\x36\xda\x69' \ '\xa6\x22\xc7\xef' '\x24\xe2\x00\x00' self.reply_args_0 = { 'blue': 22111, 'green': 27536, 'red': 54369, 'sequence_number': 52666, 'pixel': 1186287049, } self.reply_bin_0 = '\x01\x00\xba\xcd' '\x00\x00\x00\x00' \ '\x61\xd4\x90\x6b' '\x5f\x56\x00\x00' \ '\xc9\x4d\xb5\x46' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocNamedColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 695059054, 'name': 'octarin', } self.req_bin_0 = '\x55\x00\x05\x00' '\x6e\xc2\x6d\x29' \ '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ '\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_red': 45174, 'screen_blue': 21718, 'exact_green': 45002, 'exact_blue': 55971, 'screen_green': 47979, 'screen_red': 60497, 'sequence_number': 38835, 'pixel': 580415589, } self.reply_bin_0 = '\x01\x00\xb3\x97' '\x00\x00\x00\x00' \ '\x65\x70\x98\x22' '\x76\xb0\xca\xaf' \ '\xa3\xda\x51\xec' '\x6b\xbb\xd6\x54' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocNamedColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocNamedColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocNamedColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestAllocColorCells(unittest.TestCase): def setUp(self): self.req_args_0 = { 'contiguous': 1, 'cmap': 2071194037, 'colors': 16292, 'planes': 14978, } self.req_bin_0 = '\x56\x01\x03\x00' '\xb5\xe9\x73\x7b' \ '\xa4\x3f\x82\x3a' self.reply_args_0 = { 'pixels': [1664874569, 198876857, 135035151, 1499807858, 600240169, 1403510863, 757170725, 929995606, 155550883, 642439566, 971734621, 1359474267, 609593319, 669993327, 1837906914, 1355959290, 835285748], 'masks': [50898278, 362272940, 1106373487], 'sequence_number': 57786, } self.reply_bin_0 = '\x01\x00\xba\xe1' '\x14\x00\x00\x00' \ '\x11\x00\x03\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x49\xf8\x3b\x63' '\xb9\x9e\xda\x0b' \ '\x0f\x79\x0c\x08' '\x72\x40\x65\x59' \ '\x29\xf0\xc6\x23' '\x4f\xe0\xa7\x53' \ '\x25\x82\x21\x2d' '\x56\x9b\x6e\x37' \ '\xa3\x84\x45\x09' '\x8e\xd9\x4a\x26' \ '\x5d\x7e\xeb\x39' '\x5b\xee\x07\x51' \ '\xe7\xa7\x55\x24' '\x6f\x49\xef\x27' \ '\xe2\x3b\x8c\x6d' '\xfa\x4b\xd2\x50' \ '\xf4\x72\xc9\x31' '\x66\xa5\x08\x03' \ '\xac\xd8\x97\x15' '\x6f\xeb\xf1\x41' self.reply_args_1 = { 'pixels': [], 'masks': [], 'sequence_number': 49324, } self.reply_bin_1 = '\x01\x00\xac\xc0' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.AllocColorCells._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColorCells._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) def testPackReply1(self): bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_1) try: assert bin == self.reply_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply1(self): args, remain = request.AllocColorCells._reply.parse_binary(self.reply_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_1 except AssertionError: raise AssertionError(args) class TestAllocColorPlanes(unittest.TestCase): def setUp(self): self.req_args_0 = { 'blue': 34241, 'colors': 11903, 'cmap': 2107895767, 'green': 33790, 'contiguous': 1, 'red': 37700, } self.req_bin_0 = '\x57\x01\x04\x00' '\xd7\xef\xa3\x7d' \ '\x7f\x2e\x44\x93' '\xfe\x83\xc1\x85' self.reply_args_0 = { 'red_mask': 931105404, 'blue_mask': 874671906, 'pixels': [1675913921, 1252164172, 37816631, 1472651082], 'sequence_number': 17565, 'green_mask': 1072565720, } self.reply_bin_0 = '\x01\x00\x9d\x44' '\x04\x00\x00\x00' \ '\x04\x00\x00\x00' '\x7c\x8a\x7f\x37' \ '\xd8\x0d\xee\x3f' '\x22\x6f\x22\x34' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\xc1\x6a\xe4\x63' '\x4c\x82\xa2\x4a' \ '\x37\x09\x41\x02' '\x4a\xdf\xc6\x57' def testPackRequest0(self): bin = apply(request.AllocColorPlanes._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.AllocColorPlanes._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.AllocColorPlanes._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.AllocColorPlanes._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestFreeColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 32694046, 'plane_mask': 1074378407, 'pixels': [2014216051, 1664038241, 1220941033, 1378294408, 197757808, 793595544, 1289781247, 713684847, 1724469541, 1432124373, 1426727603, 1787792301, 406458839, 1918513211, 441394489, 988895943, 146997744], } self.req_bin_0 = '\x58\x00\x14\x00' '\x1e\xdf\xf2\x01' \ '\xa7\xb6\x09\x40' '\x73\x7f\x0e\x78' \ '\x61\x35\x2f\x63' '\xe9\x14\xc6\x48' \ '\x88\x1a\x27\x52' '\x70\x8b\xc9\x0b' \ '\x98\x4e\x4d\x2f' '\xff\x7f\xe0\x4c' \ '\x6f\xf7\x89\x2a' '\x25\x51\xc9\x66' \ '\xd5\x7b\x5c\x55' '\xb3\x22\x0a\x55' \ '\xad\x8b\x8f\x6a' '\xd7\x11\x3a\x18' \ '\x3b\x30\x5a\x72' '\x39\x25\x4f\x1a' \ '\xc7\x5a\xf1\x3a' '\xf0\x01\xc3\x08' def testPackRequest0(self): bin = apply(request.FreeColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestStoreColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'items': [{'blue': 3577, 'flags': 221, 'green': 15650, 'pixel': 330879354, 'red': 30294}, {'blue': 18226, 'flags': 219, 'green': 45614, 'pixel': 302874221, 'red': 54265}, {'blue': 32215, 'flags': 160, 'green': 48737, 'pixel': 1699694808, 'red': 60115}, {'blue': 28524, 'flags': 209, 'green': 37615, 'pixel': 710550693, 'red': 50488}], 'cmap': 1791140577, } self.req_bin_0 = '\x59\x00\x0e\x00' '\xe1\xa2\xc2\x6a' \ '\x7a\xd1\xb8\x13' '\x56\x76\x22\x3d' \ '\xf9\x0d\xdd\x00' '\x6d\x7e\x0d\x12' \ '\xf9\xd3\x2e\xb2' '\x32\x47\xdb\x00' \ '\xd8\x48\x4f\x65' '\xd3\xea\x61\xbe' \ '\xd7\x7d\xa0\x00' '\xa5\x24\x5a\x2a' \ '\x38\xc5\xef\x92' '\x6c\x6f\xd1\x00' def testPackRequest0(self): bin = apply(request.StoreColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.StoreColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestStoreNamedColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 869324276, 'flags': 169, 'name': 'blue', 'pixel': 413175613, } self.req_bin_0 = '\x5a\xa9\x05\x00' '\xf4\xd5\xd0\x33' \ '\x3d\x8f\xa0\x18' '\x04\x00\x00\x00' \ '\x62\x6c\x75\x65' def testPackRequest0(self): bin = apply(request.StoreNamedColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.StoreNamedColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryColors(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 1750052450, 'pixels': [1673396539, 1897675292, 1453845591, 816818886, 897340342, 1782049962, 796231465, 722380604], } self.req_bin_0 = '\x5b\x00\x0a\x00' '\x62\xae\x4f\x68' \ '\x3b\x01\xbe\x63' '\x1c\x3a\x1c\x71' \ '\x57\xec\xa7\x56' '\xc6\xaa\xaf\x30' \ '\xb6\x53\x7c\x35' '\xaa\xec\x37\x6a' \ '\x29\x87\x75\x2f' '\x3c\xa7\x0e\x2b' self.reply_args_0 = { 'colors': [{'blue': 63820, 'green': 60107, 'red': 62261}, {'blue': 54480, 'green': 48839, 'red': 10033}, {'blue': 31765, 'green': 31737, 'red': 43117}, {'blue': 50953, 'green': 52009, 'red': 14234}, {'blue': 55150, 'green': 30330, 'red': 55956}], 'sequence_number': 10895, } self.reply_bin_0 = '\x01\x00\x8f\x2a' '\x0a\x00\x00\x00' \ '\x05\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x35\xf3\xcb\xea' '\x4c\xf9\x00\x00' \ '\x31\x27\xc7\xbe' '\xd0\xd4\x00\x00' \ '\x6d\xa8\xf9\x7b' '\x15\x7c\x00\x00' \ '\x9a\x37\x29\xcb' '\x09\xc7\x00\x00' \ '\x94\xda\x7a\x76' '\x6e\xd7\x00\x00' self.req_args_1 = { 'cmap': 340337174, 'pixels': [], } self.req_bin_1 = '\x5b\x00\x02\x00' '\x16\x22\x49\x14' def testPackRequest0(self): bin = apply(request.QueryColors._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackRequest1(self): bin = apply(request.QueryColors._request.to_binary, (), self.req_args_1) try: assert bin == self.req_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest1(self): args, remain = request.QueryColors._request.parse_binary(self.req_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_1 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryColors._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryColors._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestLookupColor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cmap': 2120409969, 'name': 'octarin', } self.req_bin_0 = '\x5c\x00\x05\x00' '\x71\xe3\x62\x7e' \ '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \ '\x72\x69\x6e\x00' self.reply_args_0 = { 'exact_red': 63730, 'screen_blue': 9467, 'exact_green': 24400, 'exact_blue': 27493, 'screen_green': 15878, 'screen_red': 26587, 'sequence_number': 2933, } self.reply_bin_0 = '\x01\x00\x75\x0b' '\x00\x00\x00\x00' \ '\xf2\xf8\x50\x5f' '\x65\x6b\xdb\x67' \ '\x06\x3e\xfb\x24' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.LookupColor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.LookupColor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.LookupColor._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.LookupColor._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestCreateCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'fore_blue': 45533, 'cid': 1389570470, 'fore_green': 32059, 'mask': 1475520754, 'back_blue': 7481, 'fore_red': 42911, 'source': 2060548957, 'back_green': 9237, 'y': 31911, 'x': 731, 'back_red': 30886, } self.req_bin_0 = '\x5d\x00\x08\x00' '\xa6\x29\xd3\x52' \ '\x5d\x7b\xd1\x7a' '\xf2\xa8\xf2\x57' \ '\x9f\xa7\x3b\x7d' '\xdd\xb1\xa6\x78' \ '\x15\x24\x39\x1d' '\xdb\x02\xa7\x7c' def testPackRequest0(self): bin = apply(request.CreateCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestCreateGlyphCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'fore_blue': 25271, 'mask_char': 19164, 'cid': 1841424177, 'mask': 277453392, 'fore_green': 51196, 'fore_red': 9195, 'source': 21529898, 'back_green': 55277, 'back_blue': 7419, 'source_char': 50271, 'back_red': 13590, } self.req_bin_0 = '\x5e\x00\x08\x00' '\x31\xe7\xc1\x6d' \ '\x2a\x85\x48\x01' '\x50\x9a\x89\x10' \ '\x5f\xc4\xdc\x4a' '\xeb\x23\xfc\xc7' \ '\xb7\x62\x16\x35' '\xed\xd7\xfb\x1c' def testPackRequest0(self): bin = apply(request.CreateGlyphCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.CreateGlyphCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestFreeCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 830435200, } self.req_bin_0 = '\x5f\x00\x02\x00' '\x80\x6f\x7f\x31' def testPackRequest0(self): bin = apply(request.FreeCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.FreeCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestRecolorCursor(unittest.TestCase): def setUp(self): self.req_args_0 = { 'cursor': 602252227, 'back_red': 6018, 'fore_blue': 64036, 'back_green': 49024, 'back_blue': 15439, 'fore_green': 39148, 'fore_red': 48154, } self.req_bin_0 = '\x60\x00\x05\x00' '\xc3\xa3\xe5\x23' \ '\x1a\xbc\xec\x98' '\x24\xfa\x82\x17' \ '\x80\xbf\x4f\x3c' def testPackRequest0(self): bin = apply(request.RecolorCursor._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.RecolorCursor._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestQueryBestSize(unittest.TestCase): def setUp(self): self.req_args_0 = { 'width': 52832, 'item_class': 1, 'drawable': 1606665099, 'height': 4701, } self.req_bin_0 = '\x61\x01\x03\x00' '\x8b\xc3\xc3\x5f' \ '\x60\xce\x5d\x12' self.reply_args_0 = { 'width': 33709, 'sequence_number': 43788, 'height': 12826, } self.reply_bin_0 = '\x01\x00\x0c\xab' '\x00\x00\x00\x00' \ '\xad\x83\x1a\x32' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryBestSize._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryBestSize._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryBestSize._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryBestSize._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestQueryExtension(unittest.TestCase): def setUp(self): self.req_args_0 = { 'name': 'XTRA', } self.req_bin_0 = '\x62\x00\x03\x00' '\x04\x00\x00\x00' \ '\x58\x54\x52\x41' self.reply_args_0 = { 'first_event': 163, 'first_error': 166, 'major_opcode': 215, 'present': 1, 'sequence_number': 3124, } self.reply_bin_0 = '\x01\x00\x34\x0c' '\x00\x00\x00\x00' \ '\x01\xd7\xa3\xa6' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.QueryExtension._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.QueryExtension._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.QueryExtension._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.QueryExtension._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestListExtensions(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x63\x00\x01\x00' self.reply_args_0 = { 'names': ['XTRA', 'XTRA-II'], 'sequence_number': 21122, } self.reply_bin_0 = '\x01\x02\x82\x52' '\x04\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x04\x58\x54\x52' '\x41\x07\x58\x54' \ '\x52\x41\x2d\x49' '\x49\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ListExtensions._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListExtensions._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListExtensions._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListExtensions._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeKeyboardMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'first_keycode': 131, 'keysyms': [[1479273593, 495399194, 1752874714], [183124138, 826800766, 542058728], [519501686, 1358630902, 1051542205], [1363902850, 52079613, 1721268402], [2124568309, 323328202, 1426344655], [1775218167, 1821828429, 1704892958], [1784543283, 783698836, 1882907069], [1165130550, 1276086917, 957090966], [1623553701, 77158667, 420399405], [790514637, 1104383431, 1645303152], [879499287, 349457843, 1313813953], [367336866, 1207824094, 514125338], [767413913, 135340640, 756292967], [475442692, 2076098223, 1252936842], [964050497, 2006979633, 948353974], [1923834215, 1061136894, 1319606154], [1186538913, 1770176901, 715354628], [1470481551, 403222608, 252019996], [260033548, 1553379907, 1096456683], [2027881549, 1992616114, 382810564]], } self.req_bin_0 = '\x64\x14\x3e\x00' '\x83\x03\x00\x00' \ '\x79\xec\x2b\x58' '\x1a\x31\x87\x1d' \ '\xda\xbe\x7a\x68' '\xaa\x40\xea\x0a' \ '\x7e\xfa\x47\x31' '\xe8\x28\x4f\x20' \ '\x76\xf7\xf6\x1e' '\xf6\x0f\xfb\x50' \ '\xbd\x42\xad\x3e' '\x82\x81\x4b\x51' \ '\xfd\xab\x1a\x03' '\xb2\x78\x98\x66' \ '\xf5\x56\xa2\x7e' '\xca\x98\x45\x13' \ '\xcf\x4a\x04\x55' '\xf7\xad\xcf\x69' \ '\x4d\xe5\x96\x6c' '\x1e\x9a\x9e\x65' \ '\x33\xf8\x5d\x6a' '\x94\x4b\xb6\x2e' \ '\xbd\xe1\x3a\x70' '\x36\x7b\x72\x45' \ '\x85\x8a\x0f\x4c' '\x96\x0c\x0c\x39' \ '\xa5\x76\xc5\x60' '\x0b\x59\x99\x04' \ '\x2d\xc9\x0e\x19' '\xcd\x4b\x1e\x2f' \ '\xc7\x8d\xd3\x41' '\x70\x55\x11\x62' \ '\x17\x18\x6c\x34' '\xb3\x4d\xd4\x14' \ '\xc1\x35\x4f\x4e' '\xa2\x1d\xe5\x15' \ '\xde\xee\xfd\x47' '\x1a\xee\xa4\x1e' \ '\x99\xce\xbd\x2d' '\x60\x22\x11\x08' \ '\x67\x1d\x14\x2d' '\x04\xae\x56\x1c' \ '\xaf\xbe\xbe\x7b' '\x8a\x4c\xae\x4a' \ '\x41\x3e\x76\x39' '\x31\x14\xa0\x77' \ '\xb6\xbb\x86\x38' '\x67\x61\xab\x72' \ '\xfe\xa9\x3f\x3f' '\x8a\x97\xa7\x4e' \ '\xa1\x25\xb9\x46' '\x85\xc1\x82\x69' \ '\x04\x72\xa3\x2a' '\x8f\xc4\xa5\x57' \ '\x50\xb0\x08\x18' '\x1c\x85\x05\x0f' \ '\x0c\xcc\x7f\x0f' '\x43\xb2\x96\x5c' \ '\xeb\x99\x5a\x41' '\x4d\x04\xdf\x78' \ '\xb2\xe8\xc4\x76' '\xc4\x39\xd1\x16' def testPackRequest0(self): bin = apply(request.ChangeKeyboardMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetKeyboardMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'first_keycode': 174, 'count': 233, } self.req_bin_0 = '\x65\x00\x02\x00' '\xae\xe9\x00\x00' self.reply_args_0 = { 'keysyms': [[536700486, 90972970, 1834434734], [604690854, 1612992766, 1785113276], [1258017014, 814047417, 79874791], [1752913778, 2069894554, 1342993084], [691283205, 2002270597, 1552550365], [1427239047, 80222814, 380890249], [932130695, 1233544402, 1343201446], [850296480, 830996690, 1219102856], [1427529259, 1334110395, 1423305447], [925543758, 1154246092, 389857513], [782217983, 1673349321, 296773941], [904384636, 788791004, 1427343811], [578056967, 1628142600, 882651915], [1727003528, 1202959768, 59536638], [932784259, 453243643, 1846802632], [1527858524, 2055184942, 1534128611], [134086768, 909769847, 323736641], [2080620639, 1573387975, 566724688], [1393924270, 1408645244, 1610610798], [391612329, 341605408, 484634403]], 'sequence_number': 27901, } self.reply_bin_0 = '\x01\x03\xfd\x6c' '\x3c\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x46\x66\xfd\x1f' '\x2a\x23\x6c\x05' \ '\xae\x40\x57\x6d' '\xa6\xd9\x0a\x24' \ '\xfe\x50\x24\x60' '\xbc\xaa\x66\x6a' \ '\xf6\xd0\xfb\x4a' '\xb9\x60\x85\x30' \ '\xe7\xca\xc2\x04' '\x72\x57\x7b\x68' \ '\x9a\x15\x60\x7b' '\xbc\x72\x0c\x50' \ '\x05\x25\x34\x29' '\x85\x39\x58\x77' \ '\xdd\x09\x8a\x5c' '\x87\xf0\x11\x55' \ '\x5e\x1a\xc8\x04' '\x89\xec\xb3\x16' \ '\x87\x2f\x8f\x37' '\xd2\x64\x86\x49' \ '\xa6\xa0\x0f\x50' '\xa0\x7e\xae\x32' \ '\xd2\x00\x88\x31' '\x88\x08\xaa\x48' \ '\x2b\x5e\x16\x55' '\xbb\xe8\x84\x4f' \ '\xe7\xea\xd5\x54' '\x4e\xad\x2a\x37' \ '\xcc\x65\xcc\x44' '\xe9\xc0\x3c\x17' \ '\xff\xb2\x9f\x2e' '\xc9\x48\xbd\x63' \ '\x35\x69\xb0\x11' '\x7c\xd0\xe7\x35' \ '\xdc\xfe\x03\x2f' '\xc3\x89\x13\x55' \ '\x07\x73\x74\x22' '\x08\x7c\x0b\x61' \ '\x0b\x33\x9c\x34' '\x88\xfb\xef\x66' \ '\x98\xb5\xb3\x47' '\xfe\x74\x8c\x03' \ '\x83\x28\x99\x37' '\xfb\xf2\x03\x1b' \ '\xc8\xf8\x13\x6e' '\x5c\x45\x11\x5b' \ '\x2e\xa2\x7f\x7a' '\xe3\xf1\x70\x5b' \ '\x70\x00\xfe\x07' '\x77\xfc\x39\x36' \ '\x41\xd4\x4b\x13' '\x5f\xc0\x03\x7c' \ '\xc7\xfe\xc7\x5d' '\x50\x88\xc7\x21' \ '\xae\x98\x15\x53' '\x7c\x38\xf6\x53' \ '\x6e\xf8\xff\x5f' '\xa9\x87\x57\x17' \ '\x20\x7c\x5c\x14' '\x23\xef\xe2\x1c' def testPackRequest0(self): bin = apply(request.GetKeyboardMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetKeyboardMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetKeyboardMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetKeyboardMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeKeyboardControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'attrs': {'led': 241, 'key': 193, 'bell_duration': -19485, 'auto_repeat_mode': 0, 'bell_pitch': -13220, 'key_click_percent': -3, 'bell_percent': -74, 'led_mode': 1}, } self.req_bin_0 = '\x66\x00\x0a\x00' '\xff\x00\x00\x00' \ '\xfd\x00\x00\x00' '\xb6\x00\x00\x00' \ '\x5c\xcc\x00\x00' '\xe3\xb3\x00\x00' \ '\xf1\x00\x00\x00' '\x01\x00\x00\x00' \ '\xc1\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.ChangeKeyboardControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetKeyboardControl(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x67\x00\x01\x00' self.reply_args_0 = { 'led_mask': 1389423883, 'global_auto_repeat': 1, 'auto_repeats': [129, 211, 180, 202, 218, 145, 129, 136, 137, 165, 210, 160, 229, 223, 226, 130, 197, 233, 187, 166, 211, 241, 173, 183, 184, 216, 216, 218, 182, 224, 175, 210], 'bell_pitch': 27576, 'bell_duration': 26314, 'bell_percent': 130, 'sequence_number': 62321, 'key_click_percent': 140, } self.reply_bin_0 = '\x01\x01\x71\xf3' '\x05\x00\x00\x00' \ '\x0b\xed\xd0\x52' '\x8c\x82\xb8\x6b' \ '\xca\x66\x00\x00' '\x81\xd3\xb4\xca' \ '\xda\x91\x81\x88' '\x89\xa5\xd2\xa0' \ '\xe5\xdf\xe2\x82' '\xc5\xe9\xbb\xa6' \ '\xd3\xf1\xad\xb7' '\xb8\xd8\xd8\xda' \ '\xb6\xe0\xaf\xd2' def testPackRequest0(self): bin = apply(request.GetKeyboardControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetKeyboardControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetKeyboardControl._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetKeyboardControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestBell(unittest.TestCase): def setUp(self): self.req_args_0 = { 'percent': -14, } self.req_bin_0 = '\x68\xf2\x01\x00' def testPackRequest0(self): bin = apply(request.Bell._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.Bell._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestChangePointerControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'accel_num': -5554, 'threshold': -10566, 'do_accel': 1, 'accel_denum': -24572, 'do_thresh': 1, } self.req_bin_0 = '\x69\x00\x03\x00' '\x4e\xea\x04\xa0' \ '\xba\xd6\x01\x01' def testPackRequest0(self): bin = apply(request.ChangePointerControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangePointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetPointerControl(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6a\x00\x01\x00' self.reply_args_0 = { 'accel_num': 11888, 'threshold': 36822, 'sequence_number': 62480, 'accel_denom': 46073, } self.reply_bin_0 = '\x01\x00\x10\xf4' '\x00\x00\x00\x00' \ '\x70\x2e\xf9\xb3' '\xd6\x8f\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetPointerControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetPointerControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetPointerControl._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetPointerControl._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { 'prefer_blank': 1, 'interval': -19218, 'timeout': -2423, 'allow_exposures': 2, } self.req_bin_0 = '\x6b\x00\x03\x00' '\x89\xf6\xee\xb4' \ '\x01\x02\x00\x00' def testPackRequest0(self): bin = apply(request.SetScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestGetScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6c\x00\x01\x00' self.reply_args_0 = { 'interval': 51464, 'prefer_blanking': 1, 'timeout': 5207, 'sequence_number': 45153, 'allow_exposures': 1, } self.reply_bin_0 = '\x01\x00\x61\xb0' '\x00\x00\x00\x00' \ '\x57\x14\x08\xc9' '\x01\x01\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetScreenSaver._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetScreenSaver._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestChangeHosts(unittest.TestCase): def setUp(self): self.req_args_0 = { 'host': [150, 200, 205, 182], 'mode': 0, 'host_family': 0, } self.req_bin_0 = '\x6d\x00\x03\x00' '\x00\x00\x04\x00' \ '\x96\xc8\xcd\xb6' def testPackRequest0(self): bin = apply(request.ChangeHosts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ChangeHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestListHosts(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x6e\x00\x01\x00' self.reply_args_0 = { 'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}], 'mode': 1, 'sequence_number': 33455, } self.reply_bin_0 = '\x01\x01\xaf\x82' '\x04\x00\x00\x00' \ '\x02\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x04\x00' '\x22\x17\xb2\x0c' \ '\x00\x00\x04\x00' '\x82\xec\xfe\x0f' def testPackRequest0(self): bin = apply(request.ListHosts._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ListHosts._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.ListHosts._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.ListHosts._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetAccessControl(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = '\x6f\x01\x01\x00' def testPackRequest0(self): bin = apply(request.SetAccessControl._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetAccessControl._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetCloseDownMode(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = '\x70\x01\x01\x00' def testPackRequest0(self): bin = apply(request.SetCloseDownMode._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetCloseDownMode._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestKillClient(unittest.TestCase): def setUp(self): self.req_args_0 = { 'resource': 1900634441, } self.req_bin_0 = '\x71\x00\x02\x00' '\x49\x61\x49\x71' def testPackRequest0(self): bin = apply(request.KillClient._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.KillClient._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestRotateProperties(unittest.TestCase): def setUp(self): self.req_args_0 = { 'window': 1149115389, 'properties': [194806244, 1444715269, 486779871, 1850032482, 1083061497, 786546027, 807635511, 1716883082, 80335197, 1654299, 1459844212, 850673646], 'delta': -27029, } self.req_bin_0 = '\x72\x00\x0f\x00' '\xfd\x1b\x7e\x44' \ '\x0c\x00\x6b\x96' '\xe4\x81\x9c\x0b' \ '\x05\x9b\x1c\x56' '\xdf\xab\x03\x1d' \ '\x62\x41\x45\x6e' '\xf9\x34\x8e\x40' \ '\x6b\xbd\xe1\x2e' '\x37\x8a\x23\x30' \ '\x8a\x8e\x55\x66' '\x5d\xd1\xc9\x04' \ '\x1b\x3e\x19\x00' '\x74\x74\x03\x57' \ '\xee\x3f\xb4\x32' def testPackRequest0(self): bin = apply(request.RotateProperties._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.RotateProperties._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestForceScreenSaver(unittest.TestCase): def setUp(self): self.req_args_0 = { 'mode': 1, } self.req_bin_0 = '\x73\x01\x01\x00' def testPackRequest0(self): bin = apply(request.ForceScreenSaver._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.ForceScreenSaver._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) class TestSetPointerMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'map': [130, 178, 229, 218, 178], } self.req_bin_0 = '\x74\x05\x03\x00' '\x82\xb2\xe5\xda' \ '\xb2\x00\x00\x00' self.reply_args_0 = { 'status': 145, 'sequence_number': 57045, } self.reply_bin_0 = '\x01\x91\xd5\xde' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetPointerMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.SetPointerMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.SetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetPointerMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x75\x00\x01\x00' self.reply_args_0 = { 'map': [248, 185, 227, 157, 133], 'sequence_number': 20072, } self.reply_bin_0 = '\x01\x05\x68\x4e' '\x02\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\xf8\xb9\xe3\x9d' '\x85\x00\x00\x00' def testPackRequest0(self): bin = apply(request.GetPointerMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetPointerMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetPointerMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetPointerMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestSetModifierMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { 'keycodes': [[6, 191], [94, 123], [46, 94], [104, 116], [132, 158], [35, 75], [128, 63], [135, 221]], } self.req_bin_0 = '\x76\x02\x05\x00' '\x06\xbf\x5e\x7b' \ '\x2e\x5e\x68\x74' '\x84\x9e\x23\x4b' \ '\x80\x3f\x87\xdd' self.reply_args_0 = { 'status': 149, 'sequence_number': 26757, } self.reply_bin_0 = '\x01\x95\x85\x68' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPackRequest0(self): bin = apply(request.SetModifierMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.SetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.SetModifierMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.SetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestGetModifierMapping(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x77\x00\x01\x00' self.reply_args_0 = { 'keycodes': [[85, 162], [139, 194], [12, 107], [120, 193], [26, 40], [125, 221], [27, 0], [220, 78]], 'sequence_number': 17677, } self.reply_bin_0 = '\x01\x02\x0d\x45' '\x04\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x55\xa2\x8b\xc2' '\x0c\x6b\x78\xc1' \ '\x1a\x28\x7d\xdd' '\x1b\x00\xdc\x4e' def testPackRequest0(self): bin = apply(request.GetModifierMapping._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.GetModifierMapping._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) def testPackReply0(self): bin = apply(request.GetModifierMapping._reply.to_binary, (), self.reply_args_0) try: assert bin == self.reply_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackReply0(self): args, remain = request.GetModifierMapping._reply.parse_binary(self.reply_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.reply_args_0 except AssertionError: raise AssertionError(args) class TestNoOperation(unittest.TestCase): def setUp(self): self.req_args_0 = { } self.req_bin_0 = '\x7f\x00\x01\x00' def testPackRequest0(self): bin = apply(request.NoOperation._request.to_binary, (), self.req_args_0) try: assert bin == self.req_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpackRequest0(self): args, remain = request.NoOperation._request.parse_binary(self.req_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.req_args_0 except AssertionError: raise AssertionError(args) if __name__ == "__main__": check_endian() unittest.main() python-xlib-0.14+20091101/test/test_events_be.py0000755000175000017500000007032210633003257017702 0ustar stewstew#!/usr/bin/env python import sys, os sys.path.insert(1, os.path.join(sys.path[0], '..')) import string import unittest from Xlib.protocol import request, rq, event import Xlib.protocol.event import struct import array class CmpArray: def __init__(self, *args, **kws): self.array = apply(array.array, args, kws) def __len__(self): return len(self.array) def __getslice__(self, x, y): return list(self.array[x:y]) def __getattr__(self, attr): return getattr(self.array, attr) def __cmp__(self, other): return cmp(self.array.tolist(), other) rq.array = CmpArray def tohex(bin): bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '') bins = [] for i in range(0, len(bin), 16): bins.append(bin[i:i+16]) bins2 = [] for i in range(0, len(bins), 2): try: bins2.append("'%s' '%s'" % (bins[i], bins[i + 1])) except IndexError: bins2.append("'%s'" % bins[i]) return string.join(bins2, ' \\\n ') class DummyDisplay: def get_resource_class(self, x): return None event_classes = Xlib.protocol.event.event_class dummy_display = DummyDisplay() def check_endian(): if struct.unpack('BB', struct.pack('H', 0x0100))[0] != 1: sys.stderr.write('Big-endian tests, skipping on this system.\n') sys.exit(0) class TestKeymapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'type': 154, 'data': [160, 192, 133, 223, 245, 128, 133, 188, 208, 142, 202, 142, 218, 238, 145, 150, 211, 150, 165, 230, 149, 162, 139, 159, 135, 255, 246, 202, 232, 185, 164], } self.evt_bin_0 = '\x9a\xa0\xc0\x85' '\xdf\xf5\x80\x85' \ '\xbc\xd0\x8e\xca' '\x8e\xda\xee\x91' \ '\x96\xd3\x96\xa5' '\xe6\x95\xa2\x8b' \ '\x9f\x87\xff\xf6' '\xca\xe8\xb9\xa4' def testPack0(self): bin = apply(event.KeymapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.KeymapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'height': 22214, 'sequence_number': 56268, 'type': 254, 'x': 16974, 'y': 19752, 'window': 1381709156, 'width': 26369, 'count': 60118, } self.evt_bin_0 = '\xfe\x00\xdb\xcc' '\x52\x5b\x35\x64' \ '\x42\x4e\x4d\x28' '\x67\x01\x56\xc6' \ '\xea\xd6\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.Expose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.Expose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestGraphicsExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'height': 352, 'sequence_number': 6380, 'type': 242, 'drawable': 820411264, 'x': 57593, 'y': 41762, 'major_event': 216, 'count': 63321, 'width': 58556, 'minor_event': 22632, } self.evt_bin_0 = '\xf2\x00\x18\xec' '\x30\xe6\x7b\x80' \ '\xe0\xf9\xa3\x22' '\xe4\xbc\x01\x60' \ '\x58\x68\xf7\x59' '\xd8\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.GraphicsExpose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.GraphicsExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestNoExpose(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 46171, 'major_event': 242, 'type': 187, 'window': 1319843810, 'minor_event': 45687, } self.evt_bin_0 = '\xbb\x00\xb4\x5b' '\x4e\xab\x37\xe2' \ '\xb2\x77\xf2\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.NoExpose._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.NoExpose._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestVisibilityNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'state': 238, 'sequence_number': 52805, 'type': 242, 'window': 1543431298, } self.evt_bin_0 = '\xf2\x00\xce\x45' '\x5b\xfe\xe4\x82' \ '\xee\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.VisibilityNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.VisibilityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestCreateNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'height': 15506, 'sequence_number': 8253, 'type': 255, 'border_width': 53414, 'x': -31204, 'y': -23908, 'override': 1, 'parent': 654326356, 'window': 8505372, 'width': 8871, } self.evt_bin_0 = '\xff\x00\x20\x3d' '\x27\x00\x3a\x54' \ '\x00\x81\xc8\x1c' '\x86\x1c\xa2\x9c' \ '\x22\xa7\x3c\x92' '\xd0\xa6\x01\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.CreateNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.CreateNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestDestroyNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 49137, 'event': 408289937, 'type': 223, 'window': 1716558237, } self.evt_bin_0 = '\xdf\x00\xbf\xf1' '\x18\x56\x02\x91' \ '\x66\x50\x99\x9d' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.DestroyNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.DestroyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestUnmapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'from_configure': 0, 'sequence_number': 4412, 'event': 1122103072, 'type': 217, 'window': 1455493798, } self.evt_bin_0 = '\xd9\x00\x11\x3c' '\x42\xe1\xef\x20' \ '\x56\xc1\x12\xa6' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.UnmapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.UnmapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestMapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 65096, 'event': 328610268, 'type': 228, 'window': 1882369959, 'override': 0, } self.evt_bin_0 = '\xe4\x00\xfe\x48' '\x13\x96\x31\xdc' \ '\x70\x32\xaf\xa7' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestMapRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'parent': 1664235152, 'sequence_number': 51552, 'type': 171, 'window': 488763730, } self.evt_bin_0 = '\xab\x00\xc9\x60' '\x63\x32\x36\x90' \ '\x1d\x21\xf1\x52' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MapRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MapRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestReparentNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 9256, 'event': 2000272853, 'type': 229, 'override': 1, 'x': -28587, 'y': -11597, 'parent': 912114770, 'window': 1142506827, } self.evt_bin_0 = '\xe5\x00\x24\x28' '\x77\x39\xbd\xd5' \ '\x44\x19\x45\x4b' '\x36\x5d\xc4\x52' \ '\x90\x55\xd2\xb3' '\x01\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ReparentNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ReparentNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestConfigureNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'height': 16243, 'sequence_number': 62364, 'event': 1373455462, 'type': 191, 'border_width': 7244, 'x': -12771, 'y': -15228, 'override': 1, 'above_sibling': 1099666850, 'window': 2046157981, 'width': 8604, } self.evt_bin_0 = '\xbf\x00\xf3\x9c' '\x51\xdd\x44\x66' \ '\x79\xf5\xe4\x9d' '\x41\x8b\x95\xa2' \ '\xce\x1d\xc4\x84' '\x21\x9c\x3f\x73' \ '\x1c\x4c\x01\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ConfigureNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ConfigureNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestConfigureRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 31377, 'value_mask': 19345, 'type': 156, 'border_width': 54779, 'x': -18191, 'y': -17663, 'window': 1231046739, 'width': 51620, 'height': 47094, 'sibling': 1154714518, 'stack_mode': 199, 'parent': 176713389, } self.evt_bin_0 = '\x9c\xc7\x7a\x91' '\x0a\x88\x6e\xad' \ '\x49\x60\x48\x53' '\x44\xd3\x8b\x96' \ '\xb8\xf1\xbb\x01' '\xc9\xa4\xb7\xf6' \ '\xd5\xfb\x4b\x91' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ConfigureRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ConfigureRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestGravityNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 43376, 'event': 641536677, 'type': 192, 'window': 51697690, 'x': -21924, 'y': -4866, } self.evt_bin_0 = '\xc0\x00\xa9\x70' '\x26\x3d\x12\xa5' \ '\x03\x14\xd8\x1a' '\xaa\x5c\xec\xfe' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.GravityNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.GravityNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestResizeRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'height': 59752, 'sequence_number': 21348, 'type': 149, 'window': 1698104652, 'width': 41494, } self.evt_bin_0 = '\x95\x00\x53\x64' '\x65\x37\x05\x4c' \ '\xa2\x16\xe9\x68' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ResizeRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ResizeRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestPropertyNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'atom': 762586168, 'sequence_number': 29670, 'time': 1791118117, 'type': 188, 'state': 181, 'window': 334365400, } self.evt_bin_0 = '\xbc\x00\x73\xe6' '\x13\xee\x02\xd8' \ '\x2d\x74\x24\x38' '\x6a\xc2\x4b\x25' \ '\xb5\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.PropertyNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.PropertyNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionClear(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'time': 578079299, 'sequence_number': 13691, 'atom': 1385452659, 'type': 170, 'window': 355039782, } self.evt_bin_0 = '\xaa\x00\x35\x7b' '\x22\x74\xca\x43' \ '\x15\x29\x7a\x26' '\x52\x94\x54\x73' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionClear._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionClear._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionRequest(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 13254, 'type': 162, 'property': 397160681, 'owner': 2075837783, 'time': 1154635674, 'target': 1312534659, 'selection': 1972323175, 'requestor': 178195168, } self.evt_bin_0 = '\xa2\x00\x33\xc6' '\x44\xd2\x57\x9a' \ '\x7b\xba\xc5\x57' '\x0a\x9f\x0a\xe0' \ '\x75\x8f\x43\x67' '\x4e\x3b\xb0\x83' \ '\x17\xac\x30\xe9' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionRequest._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionRequest._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestSelectionNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 39736, 'type': 199, 'property': 302372755, 'time': 882192222, 'target': 2131462701, 'selection': 781895626, 'requestor': 1242076588, } self.evt_bin_0 = '\xc7\x00\x9b\x38' '\x34\x95\x2f\x5e' \ '\x4a\x08\x95\xac' '\x2e\x9a\xc7\xca' \ '\x7f\x0b\x8a\x2d' '\x12\x05\xd7\x93' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.SelectionNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.SelectionNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestColormapNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'state': 209, 'sequence_number': 62902, 'colormap': 300799750, 'type': 233, 'window': 1591667531, 'new': 1, } self.evt_bin_0 = '\xe9\x00\xf5\xb6' '\x5e\xde\xeb\x4b' \ '\x11\xed\xd7\x06' '\x01\xd1\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.ColormapNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ColormapNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) class TestClientMessage(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 48712, 'data': (8, '01234567890123456789'), 'type': 245, 'client_type': 1340394836, 'window': 1256861040, } self.evt_bin_0 = '\xf5\x08\xbe\x48' '\x4a\xea\x2d\x70' \ '\x4f\xe4\xcd\x54' '\x30\x31\x32\x33' \ '\x34\x35\x36\x37' '\x38\x39\x30\x31' \ '\x32\x33\x34\x35' '\x36\x37\x38\x39' self.evt_args_1 = { 'sequence_number': 62804, 'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 'type': 250, 'client_type': 214585025, 'window': 151327338, } self.evt_bin_1 = '\xfa\x10\xf5\x54' '\x09\x05\x12\x6a' \ '\x0c\xca\x4e\xc1' '\x00\x01\x00\x02' \ '\x00\x03\x00\x04' '\x00\x05\x00\x06' \ '\x00\x07\x00\x08' '\x00\x09\x00\x0a' self.evt_args_2 = { 'sequence_number': 3122, 'data': (32, [1, 2, 3, 4, 5]), 'type': 243, 'client_type': 698151018, 'window': 725159371, } self.evt_bin_2 = '\xf3\x20\x0c\x32' '\x2b\x39\x0d\xcb' \ '\x29\x9c\xf0\x6a' '\x00\x00\x00\x01' \ '\x00\x00\x00\x02' '\x00\x00\x00\x03' \ '\x00\x00\x00\x04' '\x00\x00\x00\x05' def testPack0(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) def testPack1(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_1) try: assert bin == self.evt_bin_1 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack1(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_1, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_1 except AssertionError: raise AssertionError(args) def testPack2(self): bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_2) try: assert bin == self.evt_bin_2 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack2(self): args, remain = event.ClientMessage._fields.parse_binary(self.evt_bin_2, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_2 except AssertionError: raise AssertionError(args) class TestMappingNotify(unittest.TestCase): def setUp(self): self.evt_args_0 = { 'sequence_number': 53541, 'count': 151, 'request': 141, 'type': 252, 'first_keycode': 218, } self.evt_bin_0 = '\xfc\x00\xd1\x25' '\x8d\xda\x97\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' \ '\x00\x00\x00\x00' '\x00\x00\x00\x00' def testPack0(self): bin = apply(event.MappingNotify._fields.to_binary, (), self.evt_args_0) try: assert bin == self.evt_bin_0 except AssertionError: raise AssertionError(tohex(bin)) def testUnpack0(self): args, remain = event.MappingNotify._fields.parse_binary(self.evt_bin_0, dummy_display, 1) try: assert len(remain) == 0 except AssertionError: raise AssertionError(tohex(remain)) try: assert args == self.evt_args_0 except AssertionError: raise AssertionError(args) if __name__ == "__main__": check_endian() unittest.main() python-xlib-0.14+20091101/setup.py0000644000175000017500000000077710633003257015056 0ustar stewstew# Distutils script for python-xlib from distutils.core import setup import Xlib setup(name = 'python-xlib', version = Xlib.__version_string__, description = "Python X Library", url = 'http://python-xlib.sourceforge.net/', author = 'Peter Liljenberg', author_email = 'petli@ctrl-c.liu.se', packages = [ 'Xlib', 'Xlib.ext', 'Xlib.keysymdef', 'Xlib.protocol', 'Xlib.support', 'Xlib.xobject' ], ) python-xlib-0.14+20091101/README0000644000175000017500000000736010700264700014214 0ustar stewstew The Python X Library *** Copyright The main part of the code is Copyright (C) 2000-2002 Peter Liljenberg Some contributed code is copyrighted by the contributors, in these cases that is indicated in the source files in question. The Python X Library is released under GPL, see the file COPYING for details. *** Requirements The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Pythons 1.5.2, 2.0 - 2.5. *** Installation The Python Xlib uses the standard distutils to make installation easy. Distutils is shipped with Python 1.6 and newer. Python 1.5.2 users must download and install distutils before Python Xlib can be installed. Distutils can be downloaded from http://www.python.org/sigs/distutils-sig/. Install Python Xlib by running this command: python setup.py install Installation can be modified with the normal install options, see the documentation of distutils for details. Alternatively, you can run programs from the distribution directory, or changing the module path in programs. There's a simple example program, implemented twice using both the high-level interface and the low-level protocol. *** Introduction The Python X Library is intended to be a fully functional X client library for Python programs. It is written entirely in Python, in contrast to earlier X libraries for Python (the ancient X extension and the newer plxlib) which were interfaces to the C Xlib. This is possible to do since X client programs communicate with the X server via the X protocol. The communication takes place over TCP/IP, Unix sockets, DECnet or any other streaming network protocol. The C Xlib is merely an interface to this protocol, providing functions suitable for a C environment. There are three advantages of implementing a pure Python library: * Integration: The library can make use of the wonderful object system in Python, providing an easy-to-use class hierarchy. * Portability: The library will be usable on (almost) any computer which have Python installed. A C interface could be problematic to port to non-Unix systems, such as MS Windows or OpenVMS. * Maintainability: It is much easier to develop and debug native Python modules than modules written in C. *** Project status The low-level protocol is complete, implementing client-side X11R6. The high-level object oriented interface is also fully functional. It is possible to write client applications with the library. Currently, the only real application using Python Xlib is the window manager PLWM, starting with version 2.0. There is a resource database implementation, ICCCM support and a framework for adding X extension code. Currently only the XTEST extension has been implemented. There are most likely still bugs, but the library is at least stable enough to run PLWM. A continously bigger part of the library is covered by regression tests, improving stability. The documentation is still quite rudimentary, but should be of some help for people programming with the Xlib. X beginners should first find some general texts on X. A very good starting point is http://www.rahul.net/kenton/xsites.html See the file TODO for a detailed list of what is missing, approximately ordered by importance. *** Contact information Author email: Peter Liljenberg Mailing list: http://sourceforge.net/mail/?group_id=10350 The Python X Library is a SourceForged project. The project page is http://sourceforge.net/projects/python-xlib/. Source is available from that page as tar.gz-releases and from the CVS tree. There isn't any real web page yet, only a derivative of this file. It is located at http://python-xlib.sourceforge.net/. It now also features the documentation for downloading or browsing. python-xlib-0.14+20091101/Xlib/0000755000175000017500000000000011273361453014235 5ustar stewstewpython-xlib-0.14+20091101/Xlib/protocol/0000755000175000017500000000000011273361453016076 5ustar stewstewpython-xlib-0.14+20091101/Xlib/protocol/display.py0000644000175000017500000010050210770020473020106 0ustar stewstew# -*- coding: latin-1 -*- # # Xlib.protocol.display -- core display communication # # Copyright (C) 2000-2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Standard modules import sys import select import struct import errno import socket # Xlib modules from Xlib import error from Xlib.support import lock, connect # Xlib.protocol modules import rq import event class Display: resource_classes = {} extension_major_opcodes = {} error_classes = error.xerror_class.copy() event_classes = event.event_class.copy() def __init__(self, display = None): name, host, displayno, screenno = connect.get_display(display) self.display_name = name self.default_screen = screenno self.socket = connect.get_socket(name, host, displayno) auth_name, auth_data = connect.get_auth(self.socket, name, host, displayno) # Internal structures for communication, grouped # by their function and locks # Socket error indicator, set when the socket is closed # in one way or another self.socket_error_lock = lock.allocate_lock() self.socket_error = None # Event queue self.event_queue_read_lock = lock.allocate_lock() self.event_queue_write_lock = lock.allocate_lock() self.event_queue = [] # Unsent request queue and sequence number counter self.request_queue_lock = lock.allocate_lock() self.request_serial = 1 self.request_queue = [] # Send-and-recieve loop, see function send_and_recive # for a detailed explanation self.send_recv_lock = lock.allocate_lock() self.send_active = 0 self.recv_active = 0 self.event_waiting = 0 self.event_wait_lock = lock.allocate_lock() self.request_waiting = 0 self.request_wait_lock = lock.allocate_lock() # Data used by the send-and-recieve loop self.sent_requests = [] self.request_length = 0 self.data_send = '' self.data_recv = '' self.data_sent_bytes = 0 # Resource ID structures self.resource_id_lock = lock.allocate_lock() self.resource_ids = {} self.last_resource_id = 0 # Use an default error handler, one which just prints the error self.error_handler = None # Right, now we're all set up for the connection setup # request with the server. # Figure out which endianess the hardware uses self.big_endian = struct.unpack('BB', struct.pack('H', 0x0100))[0] if self.big_endian: order = 0x42 else: order = 0x6c # Send connection setup r = ConnectionSetupRequest(self, byte_order = order, protocol_major = 11, protocol_minor = 0, auth_prot_name = auth_name, auth_prot_data = auth_data) # Did connection fail? if r.status != 1: raise error.DisplayConnectionError(self.display_name, r.reason) # Set up remaining info self.info = r self.default_screen = min(self.default_screen, len(self.info.roots) - 1) # # Public interface # def get_display_name(self): return self.display_name def get_default_screen(self): return self.default_screen def fileno(self): self.check_for_error() return self.socket.fileno() def next_event(self): self.check_for_error() # Main lock, so that only one thread at a time performs the # event waiting code. This at least guarantees that the first # thread calling next_event() will get the next event, although # no order is guaranteed among other threads calling next_event() # while the first is blocking. self.event_queue_read_lock.acquire() # Lock event queue, so we can check if it is empty self.event_queue_write_lock.acquire() # We have too loop until we get an event, as # we might be woken up when there is no event. while not self.event_queue: # Lock send_recv so no send_and_recieve # can start or stop while we're checking # whether there are one active. self.send_recv_lock.acquire() # Release event queue to allow an send_and_recv to # insert any now. self.event_queue_write_lock.release() # Call send_and_recv, which will return when # something has occured self.send_and_recv(event = 1) # Before looping around, lock the event queue against # modifications. self.event_queue_write_lock.acquire() # Whiew, we have an event! Remove it from # the event queue and relaese its write lock. event = self.event_queue[0] del self.event_queue[0] self.event_queue_write_lock.release() # Finally, allow any other threads which have called next_event() # while we were waiting to proceed. self.event_queue_read_lock.release() # And return the event! return event def pending_events(self): self.check_for_error() # Make a send_and_recv pass, receiving any events self.send_recv_lock.acquire() self.send_and_recv(recv = 1) # Lock the queue, get the event count, and unlock again. self.event_queue_write_lock.acquire() count = len(self.event_queue) self.event_queue_write_lock.release() return count def flush(self): self.check_for_error() self.send_recv_lock.acquire() self.send_and_recv(flush = 1) def close(self): self.flush() self.close_internal('client') def set_error_handler(self, handler): self.error_handler = handler def allocate_resource_id(self): """id = d.allocate_resource_id() Allocate a new X resource id number ID. Raises ResourceIDError if there are no free resource ids. """ self.resource_id_lock.acquire() try: i = self.last_resource_id while self.resource_ids.has_key(i): i = i + 1 if i > self.info.resource_id_mask: i = 0 if i == self.last_resource_id: raise error.ResourceIDError('out of resource ids') self.resource_ids[i] = None self.last_resource_id = i return self.info.resource_id_base | i finally: self.resource_id_lock.release() def free_resource_id(self, rid): """d.free_resource_id(rid) Free resource id RID. Attempts to free a resource id which isn't allocated by us are ignored. """ self.resource_id_lock.acquire() try: i = rid & self.info.resource_id_mask # Attempting to free a resource id outside our range if rid - i != self.info.resource_id_base: return None try: del self.resource_ids[i] except KeyError: pass finally: self.resource_id_lock.release() def get_resource_class(self, class_name, default = None): """class = d.get_resource_class(class_name, default = None) Return the class to be used for X resource objects of type CLASS_NAME, or DEFAULT if no such class is set. """ return self.resource_classes.get(class_name, default) def set_extension_major(self, extname, major): self.extension_major_opcodes[extname] = major def get_extension_major(self, extname): return self.extension_major_opcodes[extname] def add_extension_event(self, code, evt): self.event_classes[code] = evt def add_extension_error(self, code, err): self.error_classes[code] = err # # Private functions # def check_for_error(self): self.socket_error_lock.acquire() err = self.socket_error self.socket_error_lock.release() if err: raise err def send_request(self, request, wait_for_response): if self.socket_error: raise self.socket_error self.request_queue_lock.acquire() request._serial = self.request_serial self.request_serial = (self.request_serial + 1) % 65536 self.request_queue.append((request, wait_for_response)) qlen = len(self.request_queue) self.request_queue_lock.release() # if qlen > 10: # self.flush() def close_internal(self, whom): # Clear out data structures self.request_queue = None self.sent_requests = None self.event_queue = None self.data_send = None self.data_recv = None # Close the connection self.socket.close() # Set a connection closed indicator self.socket_error_lock.acquire() self.socket_error = error.ConnectionClosedError(whom) self.socket_error_lock.release() def send_and_recv(self, flush = None, event = None, request = None, recv = None): """send_and_recv(flush = None, event = None, request = None, recv = None) Perform I/O, or wait for some other thread to do it for us. send_recv_lock MUST be LOCKED when send_and_recv is called. It will be UNLOCKED at return. Exactly or one of the parameters flush, event, request and recv must be set to control the return condition. To attempt to send all requests in the queue, flush should be true. Will return immediately if another thread is already doing send_and_recv. To wait for an event to be recieved, event should be true. To wait for a response to a certain request (either an error or a response), request should be set the that request's serial number. To just read any pending data from the server, recv should be true. It is not guaranteed that the return condition has been fulfilled when the function returns, so the caller has to loop until it is finished. """ # We go to sleep if there is already a thread doing what we # want to do: # If flushing, we want to send # If waiting for a response to a request, we want to send # (to ensure that the request was sent - we alway recv # when we get to the main loop, but sending is the important # thing here) # If waiting for an event, we want to recv # If just trying to receive anything we can, we want to recv if (((flush or request is not None) and self.send_active) or ((event or recv) and self.recv_active)): # Signal that we are waiting for something. These locks # together with the *_waiting variables are used as # semaphores. When an event or a request response arrives, # it will zero the *_waiting and unlock the lock. The # locks will also be unlocked when an active send_and_recv # finishes to signal the other waiting threads that one of # them has to take over the send_and_recv function. # All this makes these locks and variables a part of the # send_and_recv control logic, and hence must be modified # only when we have the send_recv_lock locked. if event: wait_lock = self.event_wait_lock if not self.event_waiting: self.event_waiting = 1 wait_lock.acquire() elif request is not None: wait_lock = self.request_wait_lock if not self.request_waiting: self.request_waiting = 1 wait_lock.acquire() # Release send_recv, allowing a send_and_recive # to terminate or other threads to queue up self.send_recv_lock.release() # Return immediately if flushing, even if that # might mean that not necessarily all requests # have been sent. if flush or recv: return # Wait for something to happen, as the wait locks are # unlocked either when what we wait for has arrived (not # necessarily the exact object we're waiting for, though), # or when an active send_and_recv exits. # Release it immediately afterwards as we're only using # the lock for synchonization. Since we're not modifying # event_waiting or request_waiting here we don't have # to lock send_and_recv_lock. In fact, we can't do that # or we trigger a dead-lock. wait_lock.acquire() wait_lock.release() # Return to caller to let it check whether it has # got the data it was waiting for return # There's no thread doing what we need to do. Find out exactly # what to do # There must always be some thread recieving data, but it must not # necessarily be us if not self.recv_active: recieving = 1 self.recv_active = 1 else: recieving = 0 flush_bytes = None sending = 0 # Loop, recieving and sending data. while 1: # We might want to start sending data if sending or not self.send_active: # Turn all requests on request queue into binary form # and append them to self.data_send self.request_queue_lock.acquire() for req, wait in self.request_queue: self.data_send = self.data_send + req._binary if wait: self.sent_requests.append(req) del self.request_queue[:] self.request_queue_lock.release() # If there now is data to send, mark us as senders if self.data_send: self.send_active = 1 sending = 1 else: self.send_active = 0 sending = 0 # We've done all setup, so release the lock and start waiting # for the network to fire up self.send_recv_lock.release() # If we're flushing, figure out how many bytes we # have to send so that we're not caught in an interminable # loop if other threads continuously append requests. if flush and flush_bytes is None: flush_bytes = self.data_sent_bytes + len(self.data_send) try: # We're only checking for the socket to be writable # if we're the sending thread. We always check for it # to become readable: either we are the recieving thread # and should take care of the data, or the recieving thread # might finish recieving after having read the data if sending: writeset = [self.socket] else: writeset = [] # Timeout immediately if we're only checking for # something to read or if we're flushing, otherwise block if recv or flush: timeout = 0 else: timeout = None rs, ws, es = select.select([self.socket], writeset, [], timeout) # Ignore errors caused by a signal recieved while blocking. # All other errors are re-raised. except select.error, err: if err[0] != errno.EINTR: raise err # We must lock send_and_recv before we can loop to # the start of the loop self.send_recv_lock.acquire() continue # Socket is ready for sending data, send as much as possible. if ws: try: i = self.socket.send(self.data_send) except socket.error, err: self.close_internal('server: %s' % err[1]) raise self.socket_error self.data_send = self.data_send[i:] self.data_sent_bytes = self.data_sent_bytes + i # There is data to read gotreq = 0 if rs: # We're the recieving thread, parse the data if recieving: try: bytes_recv = self.socket.recv(2048) except socket.error, err: self.close_internal('server: %s' % err[1]) raise self.socket_error if not bytes_recv: # Clear up, set a connection closed indicator and raise it self.close_internal('server') raise self.socket_error self.data_recv = self.data_recv + bytes_recv gotreq = self.parse_response(request) # Otherwise return, allowing the calling thread to figure # out if it has got the data it needs else: # We must be a sending thread if we're here, so reset # that indicator. self.send_recv_lock.acquire() self.send_active = 0 self.send_recv_lock.release() # And return to the caller return # There are three different end of send-recv-loop conditions. # However, we don't leave the loop immediately, instead we # try to send and recieve any data that might be left. We # do this by giving a timeout of 0 to select to poll # the socket. # When flushing: all requests have been sent if flush and flush_bytes >= self.data_sent_bytes: break # When waiting for an event: an event has been read if event and self.event_queue: break # When processing a certain request: got its reply if request is not None and gotreq: break # Always break if we just want to recieve as much as possible if recv: break # Else there's may still data which must be sent, or # we haven't got the data we waited for. Lock and loop self.send_recv_lock.acquire() # We have accomplished the callers request. # Record that there are now no active send_and_recv, # and wake up all waiting thread self.send_recv_lock.acquire() if sending: self.send_active = 0 if recieving: self.recv_active = 0 if self.event_waiting: self.event_waiting = 0 self.event_wait_lock.release() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() def parse_response(self, request): """Internal method. Parse data recieved from server. If REQUEST is not None true is returned if the request with that serial number was recieved, otherwise false is returned. If REQUEST is -1, we're parsing the server connection setup response. """ if request == -1: return self.parse_connection_setup() # Parse ordinary server response gotreq = 0 while 1: # Are we're waiting for additional data for a request response? if self.request_length: if len(self.data_recv) < self.request_length: return gotreq else: gotreq = self.parse_request_response(request) or gotreq # Every response is at least 32 bytes long, so don't bother # until we have recieved that much if len(self.data_recv) < 32: return gotreq # Check the first byte to find out what kind of response it is rtype = ord(self.data_recv[0]) # Error resposne if rtype == 0: gotreq = self.parse_error_response(request) or gotreq # Request response elif rtype == 1: # Set reply length, and loop around to see if # we have got the full response rlen = int(struct.unpack('=L', self.data_recv[4:8])[0]) self.request_length = 32 + rlen * 4 # Else event response else: self.parse_event_response(rtype) def parse_error_response(self, request): # Code is second byte code = ord(self.data_recv[1]) # Fetch error class estruct = self.error_classes.get(code, error.XError) e = estruct(self, self.data_recv[:32]) self.data_recv = buffer(self.data_recv, 32) # print 'recv Error:', e req = self.get_waiting_request(e.sequence_number) # Error for a request whose response we are waiting for, # or which have an error handler. However, if the error # handler indicates that it hasn't taken care of the # error, pass it on to the default error handler if req and req._set_error(e): # If this was a ReplyRequest, unlock any threads waiting # for a request to finish if isinstance(req, rq.ReplyRequest): self.send_recv_lock.acquire() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() return request == e.sequence_number # Else call the error handler else: if self.error_handler: rq.call_error_handler(self.error_handler, e, None) else: self.default_error_handler(e) return 0 def default_error_handler(self, err): sys.stderr.write('X protocol error:\n%s\n' % err) def parse_request_response(self, request): req = self.get_waiting_replyrequest() # Sequence number is always data[2:4] # Do sanity check before trying to parse the data sno = struct.unpack('=H', self.data_recv[2:4])[0] if sno != req._serial: raise RuntimeError("Expected reply for request %s, but got %s. Can't happen!" % (req._serial, sno)) req._parse_response(self.data_recv[:self.request_length]) # print 'recv Request:', req self.data_recv = buffer(self.data_recv, self.request_length) self.request_length = 0 # Unlock any response waiting threads self.send_recv_lock.acquire() if self.request_waiting: self.request_waiting = 0 self.request_wait_lock.release() self.send_recv_lock.release() return req.sequence_number == request def parse_event_response(self, etype): # Skip bit 8 at lookup, that is set if this event came from an # SendEvent estruct = self.event_classes.get(etype & 0x7f, event.AnyEvent) e = estruct(display = self, binarydata = self.data_recv[:32]) self.data_recv = buffer(self.data_recv, 32) # Drop all requests having an error handler, # but which obviously succeded. # Decrement it by one, so that we don't remove the request # that generated these events, if there is such a one. # Bug reported by Ilpo Nyyssönen self.get_waiting_request((e.sequence_number - 1) % 65536) # print 'recv Event:', e # Insert the event into the queue self.event_queue_write_lock.acquire() self.event_queue.append(e) self.event_queue_write_lock.release() # Unlock any event waiting threads self.send_recv_lock.acquire() if self.event_waiting: self.event_waiting = 0 self.event_wait_lock.release() self.send_recv_lock.release() def get_waiting_request(self, sno): if not self.sent_requests: return None # Normalize sequence numbers, even if they have wrapped. # This ensures that # sno <= last_serial # and # self.sent_requests[0]._serial <= last_serial if self.sent_requests[0]._serial > self.request_serial: last_serial = self.request_serial + 65536 if sno < self.request_serial: sno = sno + 65536 else: last_serial = self.request_serial if sno > self.request_serial: sno = sno - 65536 # No matching events at all if sno < self.sent_requests[0]._serial: return None # Find last req <= sno req = None reqpos = len(self.sent_requests) adj = 0 last = 0 for i in range(0, len(self.sent_requests)): rno = self.sent_requests[i]._serial + adj # Did serial numbers just wrap around? if rno < last: adj = 65536 rno = rno + adj last = rno if sno == rno: req = self.sent_requests[i] reqpos = i + 1 break elif sno < rno: req = None reqpos = i break # Delete all request such as req <= sno del self.sent_requests[:reqpos] return req def get_waiting_replyrequest(self): for i in range(0, len(self.sent_requests)): if hasattr(self.sent_requests[i], '_reply'): req = self.sent_requests[i] del self.sent_requests[:i + 1] return req # Reply for an unknown request? No, that can't happen. else: raise RuntimeError("Request reply to unknown request. Can't happen!") def parse_connection_setup(self): """Internal function used to parse connection setup response. """ # Only the ConnectionSetupRequest has been sent so far r = self.sent_requests[0] while 1: # print 'data_send:', repr(self.data_send) # print 'data_recv:', repr(self.data_recv) if r._data: alen = r._data['additional_length'] * 4 # The full response haven't arrived yet if len(self.data_recv) < alen: return 0 # Connection failed or further authentication is needed. # Set reason to the reason string if r._data['status'] != 1: r._data['reason'] = self.data_recv[:r._data['reason_length']] # Else connection succeeded, parse the reply else: x, d = r._success_reply.parse_binary(self.data_recv[:alen], self, rawdict = 1) r._data.update(x) del self.sent_requests[0] self.data_recv = self.data_recv[alen:] return 1 else: # The base reply is 8 bytes long if len(self.data_recv) < 8: return 0 r._data, d = r._reply.parse_binary(self.data_recv[:8], self, rawdict = 1) self.data_recv = self.data_recv[8:] # Loop around to see if we have got the additional data # already PixmapFormat = rq.Struct( rq.Card8('depth'), rq.Card8('bits_per_pixel'), rq.Card8('scanline_pad'), rq.Pad(5) ) VisualType = rq.Struct ( rq.Card32('visual_id'), rq.Card8('visual_class'), rq.Card8('bits_per_rgb_value'), rq.Card16('colormap_entries'), rq.Card32('red_mask'), rq.Card32('green_mask'), rq.Card32('blue_mask'), rq.Pad(4) ) Depth = rq.Struct( rq.Card8('depth'), rq.Pad(1), rq.LengthOf('visuals', 2), rq.Pad(4), rq.List('visuals', VisualType) ) Screen = rq.Struct( rq.Window('root'), rq.Colormap('default_colormap'), rq.Card32('white_pixel'), rq.Card32('black_pixel'), rq.Card32('current_input_mask'), rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_mms'), rq.Card16('height_in_mms'), rq.Card16('min_installed_maps'), rq.Card16('max_installed_maps'), rq.Card32('root_visual'), rq.Card8('backing_store'), rq.Card8('save_unders'), rq.Card8('root_depth'), rq.LengthOf('allowed_depths', 1), rq.List('allowed_depths', Depth) ) class ConnectionSetupRequest(rq.GetAttrData): _request = rq.Struct( rq.Set('byte_order', 1, (0x42, 0x6c)), rq.Pad(1), rq.Card16('protocol_major'), rq.Card16('protocol_minor'), rq.LengthOf('auth_prot_name', 2), rq.LengthOf('auth_prot_data', 2), rq.Pad(2), rq.String8('auth_prot_name'), rq.String8('auth_prot_data') ) _reply = rq.Struct ( rq.Card8('status'), rq.Card8('reason_length'), rq.Card16('protocol_major'), rq.Card16('protocol_minor'), rq.Card16('additional_length') ) _success_reply = rq.Struct( rq.Card32('release_number'), rq.Card32('resource_id_base'), rq.Card32('resource_id_mask'), rq.Card32('motion_buffer_size'), rq.LengthOf('vendor', 2), rq.Card16('max_request_length'), rq.LengthOf('roots', 1), rq.LengthOf('pixmap_formats', 1), rq.Card8('image_byte_order'), rq.Card8('bitmap_format_bit_order'), rq.Card8('bitmap_format_scanline_unit'), rq.Card8('bitmap_format_scanline_pad'), rq.Card8('min_keycode'), rq.Card8('max_keycode'), rq.Pad(4), rq.String8('vendor'), rq.List('pixmap_formats', PixmapFormat), rq.List('roots', Screen), ) def __init__(self, display, *args, **keys): self._binary = apply(self._request.to_binary, args, keys) self._data = None # Don't bother about locking, since no other threads have # access to the display yet display.request_queue.append((self, 1)) # However, we must lock send_and_recv, but we don't have # to loop. display.send_recv_lock.acquire() display.send_and_recv(request = -1) python-xlib-0.14+20091101/Xlib/protocol/rq.py0000644000175000017500000013021311031706774017073 0ustar stewstew# Xlib.protocol.rq -- structure primitives for request, events and errors # # Copyright (C) 2000-2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Standard modules import sys import traceback import struct import string from array import array import types import new # Xlib modules from Xlib import X from Xlib.support import lock class BadDataError(Exception): pass # These are struct codes, we know their byte sizes signed_codes = { 1: 'b', 2: 'h', 4: 'l' } unsigned_codes = { 1: 'B', 2: 'H', 4: 'L' } # Unfortunately, we don't know the array sizes of B, H and L, since # these use the underlying architecture's size for a char, short and # long. Therefore we probe for their sizes, and additionally create # a mapping that translates from struct codes to array codes. # # Bleah. array_unsigned_codes = { } struct_to_array_codes = { } for c in 'bhil': size = array(c).itemsize array_unsigned_codes[size] = string.upper(c) try: struct_to_array_codes[signed_codes[size]] = c struct_to_array_codes[unsigned_codes[size]] = string.upper(c) except KeyError: pass # print array_unsigned_codes, struct_to_array_codes class Field: """Field objects represent the data fields of a Struct. Field objects must have the following attributes: name -- the field name, or None structcode -- the struct codes representing this field structvalues -- the number of values encodes by structcode Additionally, these attributes should either be None or real methods: check_value -- check a value before it is converted to binary parse_value -- parse a value after it has been converted from binary If one of these attributes are None, no check or additional parsings will be done one values when converting to or from binary form. Otherwise, the methods should have the following behaviour: newval = check_value(val) Check that VAL is legal when converting to binary form. The value can also be converted to another Python value. In any case, return the possibly new value. NEWVAL should be a single Python value if structvalues is 1, a tuple of structvalues elements otherwise. newval = parse_value(val, display) VAL is an unpacked Python value, which now can be further refined. DISPLAY is the current Display object. Return the new value. VAL will be a single value if structvalues is 1, a tuple of structvalues elements otherwise. If `structcode' is None the Field must have the method f.parse_binary_value() instead. See its documentation string for details. """ name = None default = None structcode = None structvalues = 0 check_value = None parse_value = None keyword_args = 0 def __init__(self): pass def parse_binary_value(self, data, display, length, format): """value, remaindata = f.parse_binary_value(data, display, length, format) Decode a value for this field from the binary string DATA. If there are a LengthField and/or a FormatField connected to this field, their values will be LENGTH and FORMAT, respectively. If there are no such fields the parameters will be None. DISPLAY is the display involved, which is really only used by the Resource fields. The decoded value is returned as VALUE, and the remaining part of DATA shold be returned as REMAINDATA. """ raise RuntimeError('Neither structcode or parse_binary_value provided for %s' % self) class Pad(Field): def __init__(self, size): self.size = size self.value = '\0' * size self.structcode = '%dx' % size self.structvalues = 0 class ConstantField(Field): def __init__(self, value): self.value = value class Opcode(ConstantField): structcode = 'B' structvalues = 1 class ReplyCode(ConstantField): structcode = 'B' structvalues = 1 def __init__(self): self.value = 1 class LengthField(Field): """A LengthField stores the length of some other Field whose size may vary, e.g. List and String8. Its name should be the same as the name of the field whose size it stores. The lf.get_binary_value() method of LengthFields is not used, instead a lf.get_binary_length() should be provided. Unless LengthField.get_binary_length() is overridden in child classes, there should also be a lf.calc_length(). """ structcode = 'L' structvalues = 1 def calc_length(self, length): """newlen = lf.calc_length(length) Return a new length NEWLEN based on the provided LENGTH. """ return length class TotalLengthField(LengthField): pass class RequestLength(TotalLengthField): structcode = 'H' structvalues = 1 def calc_length(self, length): return length / 4 class ReplyLength(TotalLengthField): structcode = 'L' structvalues = 1 def calc_length(self, length): return (length - 32) / 4 class LengthOf(LengthField): def __init__(self, name, size): self.name = name self.structcode = unsigned_codes[size] class OddLength(LengthField): structcode = 'B' structvalues = 1 def __init__(self, name): self.name = name def calc_length(self, length): return length % 2 def parse_value(self, value, display): if value == 0: return 'even' else: return 'odd' class FormatField(Field): """A FormatField encodes the format of some other field, in a manner similar to LengthFields. The ff.get_binary_value() method is not used, replaced by ff.get_binary_format(). """ structvalues = 1 def __init__(self, name, size): self.name = name self.structcode = unsigned_codes[size] Format = FormatField class ValueField(Field): def __init__(self, name, default = None): self.name = name self.default = default class Int8(ValueField): structcode = 'b' structvalues = 1 class Int16(ValueField): structcode = 'h' structvalues = 1 class Int32(ValueField): structcode = 'l' structvalues = 1 class Card8(ValueField): structcode = 'B' structvalues = 1 class Card16(ValueField): structcode = 'H' structvalues = 1 class Card32(ValueField): structcode = 'L' structvalues = 1 class Resource(Card32): cast_function = '__resource__' class_name = 'resource' def __init__(self, name, codes = (), default = None): Card32.__init__(self, name, default) self.codes = codes def check_value(self, value): if type(value) is types.InstanceType: return getattr(value, self.cast_function)() else: return value def parse_value(self, value, display): # if not display: # return value if value in self.codes: return value c = display.get_resource_class(self.class_name) if c: return c(display, value) else: return value class Window(Resource): cast_function = '__window__' class_name = 'window' class Pixmap(Resource): cast_function = '__pixmap__' class_name = 'pixmap' class Drawable(Resource): cast_function = '__drawable__' class_name = 'drawable' class Fontable(Resource): cast_function = '__fontable__' class_name = 'fontable' class Font(Resource): cast_function = '__font__' class_name = 'font' class GC(Resource): cast_function = '__gc__' class_name = 'gc' class Colormap(Resource): cast_function = '__colormap__' class_name = 'colormap' class Cursor(Resource): cast_function = '__cursor__' class_name = 'cursor' class Bool(ValueField): structvalues = 1 structcode = 'B' def check_value(self, value): return not not value class Set(ValueField): structvalues = 1 def __init__(self, name, size, values, default = None): ValueField.__init__(self, name, default) self.structcode = unsigned_codes[size] self.values = values def check_value(self, val): if val not in self.values: raise ValueError('field %s: argument %s not in %s' % (self.name, val, self.values)) return val class Gravity(Set): def __init__(self, name): Set.__init__(self, name, 1, (X.ForgetGravity, X.StaticGravity, X.NorthWestGravity, X.NorthGravity, X.NorthEastGravity, X.WestGravity, X.CenterGravity, X.EastGravity, X.SouthWestGravity, X.SouthGravity, X.SouthEastGravity)) class FixedString(ValueField): structvalues = 1 def __init__(self, name, size): ValueField.__init__(self, name) self.structcode = '%ds' % size class String8(ValueField): structcode = None def __init__(self, name, pad = 1): ValueField.__init__(self, name) self.pad = pad def pack_value(self, val): slen = len(val) if self.pad: return val + '\0' * ((4 - slen % 4) % 4), slen, None else: return val, slen, None def parse_binary_value(self, data, display, length, format): if length is None: return str(data), '' if self.pad: slen = length + ((4 - length % 4) % 4) else: slen = length return str(data[:length]), buffer(data, slen) class String16(ValueField): structcode = None def __init__(self, name, pad = 1): ValueField.__init__(self, name) self.pad = pad def pack_value(self, val): # Convert 8-byte string into 16-byte list if type(val) is types.StringType: val = map(lambda c: ord(c), val) slen = len(val) if self.pad: pad = '\0\0' * (slen % 2) else: pad = '' return apply(struct.pack, ('>' + 'H' * slen, ) + tuple(val)) + pad, slen, None def parse_binary_value(self, data, display, length, format): if length == 'odd': length = len(data) / 2 - 1 elif length == 'even': length = len(data) / 2 if self.pad: slen = length + (length % 2) else: slen = length return struct.unpack('>' + 'H' * length, data[:length * 2]), buffer(data, slen * 2) class List(ValueField): """The List, FixedList and Object fields store compound data objects. The type of data objects must be provided as an object with the following attributes and methods: ... """ structcode = None def __init__(self, name, type, pad = 1): ValueField.__init__(self, name) self.type = type self.pad = pad def parse_binary_value(self, data, display, length, format): if length is None: ret = [] if self.type.structcode is None: while data: val, data = self.type.parse_binary(data, display) ret.append(val) else: scode = '=' + self.type.structcode slen = struct.calcsize(scode) pos = 0 while pos + slen <= len(data): v = struct.unpack(scode, data[pos: pos + slen]) if self.type.structvalues == 1: v = v[0] if self.type.parse_value is None: ret.append(v) else: ret.append(self.type.parse_value(v, display)) pos = pos + slen data = buffer(data, pos) else: ret = [None] * int(length) if self.type.structcode is None: for i in range(0, length): ret[i], data = self.type.parse_binary(data, display) else: scode = '=' + self.type.structcode slen = struct.calcsize(scode) pos = 0 for i in range(0, length): v = struct.unpack(scode, data[pos: pos + slen]) if self.type.structvalues == 1: v = v[0] if self.type.parse_value is None: ret[i] = v else: ret[i] = self.type.parse_value(v, display) pos = pos + slen data = buffer(data, pos) if self.pad: data = buffer(data, len(data) % 4) return ret, data def pack_value(self, val): # Single-char values, we'll assume that means integer lists. if self.type.structcode and len(self.type.structcode) == 1: data = array(struct_to_array_codes[self.type.structcode], val).tostring() else: data = [] for v in val: data.append(self.type.pack_value(v)) data = string.join(data, '') if self.pad: dlen = len(data) data = data + '\0' * ((4 - dlen % 4) % 4) return data, len(val), None class FixedList(List): def __init__(self, name, size, type, pad = 1): List.__init__(self, name, type, pad) self.size = size def parse_binary_value(self, data, display, length, format): return List.parse_binary_value(self, data, display, self.size, format) def pack_value(self, val): if len(val) != self.size: raise BadDataError('length mismatch for FixedList %s' % self.name) return List.pack_value(self, val) class Object(ValueField): structcode = None def __init__(self, name, type, default = None): ValueField.__init__(self, name, default) self.type = type self.structcode = self.type.structcode self.structvalues = self.type.structvalues def parse_binary_value(self, data, display, length, format): if self.type.structcode is None: return self.type.parse_binary(data, display) else: scode = '=' + self.type.structcode slen = struct.calcsize(scode) v = struct.unpack(scode, data[:slen]) if self.type.structvalues == 1: v = v[0] if self.type.parse_value is not None: v = self.type.parse_value(v, display) return v, buffer(data, slen) def parse_value(self, val, display): if self.type.parse_value is None: return val else: return self.type.parse_value(val, display) def pack_value(self, val): # Single-char values, we'll assume that mean an integer if self.type.structcode and len(self.type.structcode) == 1: return struct.pack('=' + self.type.structcode, val), None, None else: return self.type.pack_value(val) def check_value(self, val): if self.type.structcode is None: return val if type(val) is types.TupleType: return val if type(val) is types.DictType: data = val elif isinstance(val, DictWrapper): data = val._data else: raise TypeError('Object value must be tuple, dictionary or DictWrapper: %s' % val) vals = [] for f in self.type.fields: if f.name: vals.append(data[f.name]) return vals class PropertyData(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): if length is None: length = len(data) / (format / 8) else: length = int(length) if format == 0: ret = None elif format == 8: ret = (8, str(data[:length])) data = buffer(data, length + ((4 - length % 4) % 4)) elif format == 16: ret = (16, array(array_unsigned_codes[2], str(data[:2 * length]))) data = buffer(data, 2 * (length + length % 2)) elif format == 32: ret = (32, array(array_unsigned_codes[4], str(data[:4 * length]))) data = buffer(data, 4 * length) return ret, data def pack_value(self, value): fmt, val = value if fmt not in (8, 16, 32): raise BadDataError('Invalid property data format %d' % fmt) if type(val) is types.StringType: size = fmt / 8 vlen = len(val) if vlen % size: vlen = vlen - vlen % size data = val[:vlen] else: data = val dlen = vlen / size else: if type(val) is types.TupleType: val = list(val) size = fmt / 8 data = array(array_unsigned_codes[size], val).tostring() dlen = len(val) dl = len(data) data = data + '\0' * ((4 - dl % 4) % 4) return data, dlen, fmt class FixedPropertyData(PropertyData): def __init__(self, name, size): PropertyData.__init__(self, name) self.size = size def parse_binary_value(self, data, display, length, format): return PropertyData.parse_binary_value(self, data, display, self.size / (format / 8), format) def pack_value(self, value): data, dlen, fmt = PropertyData.pack_value(self, value) if len(data) != self.size: raise BadDataError('Wrong data length for FixedPropertyData: %s' % (value, )) return data, dlen, fmt class ValueList(Field): structcode = None keyword_args = 1 default = 'usekeywords' def __init__(self, name, mask, pad, *fields): self.name = name self.maskcode = '=%s%dx' % (unsigned_codes[mask], pad) self.maskcodelen = struct.calcsize(self.maskcode) self.fields = [] flag = 1 for f in fields: if f.name: self.fields.append((f, flag)) flag = flag << 1 def pack_value(self, arg, keys): mask = 0 data = '' if arg == self.default: arg = keys for field, flag in self.fields: if arg.has_key(field.name): mask = mask | flag val = arg[field.name] if field.check_value is not None: val = field.check_value(val) d = struct.pack('=' + field.structcode, val) data = data + d + '\0' * (4 - len(d)) return struct.pack(self.maskcode, mask) + data, None, None def parse_binary_value(self, data, display, length, format): r = {} mask = int(struct.unpack(self.maskcode, data[:self.maskcodelen])[0]) data = buffer(data, self.maskcodelen) for field, flag in self.fields: if mask & flag: if field.structcode: vals = struct.unpack('=' + field.structcode, data[:struct.calcsize('=' + field.structcode)]) if field.structvalues == 1: vals = vals[0] if field.parse_value is not None: vals = field.parse_value(vals, display) else: vals, d = field.parse_binary_value(data[:4], display, None, None) r[field.name] = vals data = buffer(data, 4) return DictWrapper(r), data class KeyboardMapping(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): if length is None: dlen = len(data) else: dlen = 4 * length * format a = array(array_unsigned_codes[4], str(data[:dlen])) ret = [] for i in range(0, len(a), format): ret.append(a[i : i + format]) return ret, buffer(data, dlen) def pack_value(self, value): keycodes = 0 for v in value: keycodes = max(keycodes, len(v)) a = array(array_unsigned_codes[4]) for v in value: for k in v: a.append(k) for i in range(len(v), keycodes): a.append(X.NoSymbol) return a.tostring(), len(value), keycodes class ModifierMapping(ValueField): structcode = None def parse_binary_value(self, data, display, length, format): a = array(array_unsigned_codes[1], str(data[:8 * format])) ret = [] for i in range(0, 8): ret.append(a[i * format : (i + 1) * format]) return ret, buffer(data, 8 * format) def pack_value(self, value): if len(value) != 8: raise BadDataError('ModifierMapping list should have eight elements') keycodes = 0 for v in value: keycodes = max(keycodes, len(v)) a = array(array_unsigned_codes[1]) for v in value: for k in v: a.append(k) for i in range(len(v), keycodes): a.append(0) return a.tostring(), len(value), keycodes class EventField(ValueField): structcode = None def pack_value(self, value): if not isinstance(value, Event): raise BadDataError('%s is not an Event for field %s' % (value, self.name)) return value._binary, None, None def parse_binary_value(self, data, display, length, format): import event estruct = display.event_classes.get(ord(data[0]) & 0x7f, event.AnyEvent) return estruct(display = display, binarydata = data[:32]), buffer(data, 32) # # Objects usable for List and FixedList fields. # Struct is also usable. # class ScalarObj: def __init__(self, code): self.structcode = code self.structvalues = 1 self.parse_value = None Card8Obj = ScalarObj('B') Card16Obj = ScalarObj('H') Card32Obj = ScalarObj('L') class ResourceObj: structcode = 'L' structvalues = 1 def __init__(self, class_name): self.class_name = class_name def parse_value(self, value, display): # if not display: # return value c = display.get_resource_class(self.class_name) if c: return c(display, value) else: return value WindowObj = ResourceObj('window') ColormapObj = ResourceObj('colormap') class StrClass: structcode = None def pack_value(self, val): return chr(len(val)) + val def parse_binary(self, data, display): slen = ord(data[0]) + 1 return data[1:slen], buffer(data, slen) Str = StrClass() class Struct: """Struct objects represents a binary data structure. It can contain both fields with static and dynamic sizes. However, all static fields must appear before all dynamic fields. Fields are represented by various subclasses of the abstract base class Field. The fields of a structure are given as arguments when instantiating a Struct object. Struct objects have two public methods: to_binary() -- build a binary representation of the structure with the values given as arguments parse_binary() -- convert a binary (string) representation into a Python dictionary or object. These functions will be generated dynamically for each Struct object to make conversion as fast as possible. They are generated the first time the methods are called. """ def __init__(self, *fields): self.fields = fields # Structures for to_binary, parse_value and parse_binary self.static_codes = '=' self.static_values = 0 self.static_fields = [] self.static_size = None self.var_fields = [] for f in self.fields: # Append structcode if there is one and we haven't # got any varsize fields yet. if f.structcode is not None: assert not self.var_fields self.static_codes = self.static_codes + f.structcode # Only store fields with values if f.structvalues > 0: self.static_fields.append(f) self.static_values = self.static_values + f.structvalues # If we have got one varsize field, all the rest must # also be varsize fields. else: self.var_fields.append(f) self.static_size = struct.calcsize(self.static_codes) if self.var_fields: self.structcode = None self.structvalues = 0 else: self.structcode = self.static_codes[1:] self.structvalues = self.static_values # These functions get called only once, as they will override # themselves with dynamically created functions in the Struct # object def to_binary(self, *varargs, **keys): """data = s.to_binary(...) Convert Python values into the binary representation. The arguments will be all value fields with names, in the order given when the Struct object was instantiated. With one exception: fields with default arguments will be last. Returns the binary representation as the string DATA. """ code = '' total_length = str(self.static_size) joins = [] args = [] defargs = [] kwarg = 0 # First pack all varfields so their lengths and formats are # available when we pack their static LengthFields and # FormatFields i = 0 for f in self.var_fields: if f.keyword_args: kwarg = 1 kw = ', _keyword_args' else: kw = '' # Call pack_value method for each field, storing # the return values for later use code = code + (' _%(name)s, _%(name)s_length, _%(name)s_format' ' = self.var_fields[%(fno)d].pack_value(%(name)s%(kw)s)\n' % { 'name': f.name, 'fno': i, 'kw': kw }) total_length = total_length + ' + len(_%s)' % f.name joins.append('_%s' % f.name) i = i + 1 # Construct argument list for struct.pack call, packing all # static fields. First argument is the structcode, the # remaining are values. pack_args = ['"%s"' % self.static_codes] i = 0 for f in self.static_fields: if isinstance(f, LengthField): # If this is a total length field, insert # the calculated field value here if isinstance(f, TotalLengthField): if self.var_fields: pack_args.append('self.static_fields[%d].calc_length(%s)' % (i, total_length)) else: pack_args.append(str(f.calc_length(self.static_size))) else: pack_args.append('self.static_fields[%d].calc_length(_%s_length)' % (i, f.name)) # Format field, just insert the value we got previously elif isinstance(f, FormatField): pack_args.append('_%s_format' % f.name) # A constant field, insert its value directly elif isinstance(f, ConstantField): pack_args.append(str(f.value)) # Value fields else: if f.structvalues == 1: # If there's a value check/convert function, call it if f.check_value is not None: pack_args.append('self.static_fields[%d].check_value(%s)' % (i, f.name)) # Else just use the argument as provided else: pack_args.append(f.name) # Multivalue field. Handled like single valuefield, # but the value are tuple unpacked into seperate arguments # which are appended to pack_args else: a = [] for j in range(f.structvalues): a.append('_%s_%d' % (f.name, j)) if f.check_value is not None: code = code + (' %s = self.static_fields[%d].check_value(%s)\n' % (string.join(a, ', '), i, f.name)) else: code = code + ' %s = %s\n' % (string.join(a, ', '), f.name) pack_args = pack_args + a # Add field to argument list if f.name: if f.default is None: args.append(f.name) else: defargs.append('%s = %s' % (f.name, repr(f.default))) i = i + 1 # Construct call to struct.pack pack = 'struct.pack(%s)' % string.join(pack_args, ', ') # If there are any varfields, we append the packed strings to build # the resulting binary value if self.var_fields: code = code + ' return %s + %s\n' % (pack, string.join(joins, ' + ')) # If there's only static fields, return the packed value else: code = code + ' return %s\n' % pack # Add all varsize fields to argument list. We do it here # to ensure that they appear after the static fields. for f in self.var_fields: if f.name: if f.default is None: args.append(f.name) else: defargs.append('%s = %s' % (f.name, repr(f.default))) args = args + defargs if kwarg: args.append('**_keyword_args') # Add function header code = 'def to_binary(self, %s):\n' % string.join(args, ', ') + code # self._pack_code = code # print # print code # print # Finally, compile function by evaluating it. This will store # the function in the local variable to_binary, thanks to the # def: line. Convert it into a instance metod bound to self, # and store it in self. # Unfortunately, this creates a circular reference. However, # Structs are not really created dynamically so the potential # memory leak isn't that serious. Besides, Python 2.0 has # real garbage collect. exec code self.to_binary = new.instancemethod(to_binary, self, self.__class__) # Finally call it manually return apply(self.to_binary, varargs, keys) def pack_value(self, value): """ This function allows Struct objects to be used in List and Object fields. Each item represents the arguments to pass to to_binary, either a tuple, a dictionary or a DictWrapper. """ if type(value) is types.TupleType: return apply(self.to_binary, value, {}) elif type(value) is types.DictionaryType: return apply(self.to_binary, (), value) elif isinstance(value, DictWrapper): return apply(self.to_binary, (), value._data) else: raise BadDataError('%s is not a tuple or a list' % (value)) def parse_value(self, val, display, rawdict = 0): """This function is used by List and Object fields to convert Struct objects with no var_fields into Python values. """ code = ('def parse_value(self, val, display, rawdict = 0):\n' ' ret = {}\n') vno = 0 fno = 0 for f in self.static_fields: # Fields without names should be ignored, and there should # not be any length or format fields if this function # ever gets called. (If there were such fields, there should # be a matching field in var_fields and then parse_binary # would have been called instead. if not f.name: pass elif isinstance(f, LengthField): pass elif isinstance(f, FormatField): pass # Value fields else: # Get the index or range in val representing this field. if f.structvalues == 1: vrange = str(vno) else: vrange = '%d:%d' % (vno, vno + f.structvalues) # If this field has a parse_value method, call it, otherwise # use the unpacked value as is. if f.parse_value is None: code = code + ' ret["%s"] = val[%s]\n' % (f.name, vrange) else: code = code + (' ret["%s"] = self.static_fields[%d].' 'parse_value(val[%s], display)\n' % (f.name, fno, vrange)) fno = fno + 1 vno = vno + f.structvalues code = code + ' if not rawdict: return DictWrapper(ret)\n' code = code + ' return ret\n' # print # print code # print # Finally, compile function as for to_binary. exec code self.parse_value = new.instancemethod(parse_value, self, self.__class__) # Call it manually return self.parse_value(val, display, rawdict) def parse_binary(self, data, display, rawdict = 0): """values, remdata = s.parse_binary(data, display, rawdict = 0) Convert a binary representation of the structure into Python values. DATA is a string or a buffer containing the binary data. DISPLAY should be a Xlib.protocol.display.Display object if there are any Resource fields or Lists with ResourceObjs. The Python values are returned as VALUES. If RAWDICT is true, a Python dictionary is returned, where the keys are field names and the values are the corresponding Python value. If RAWDICT is false, a DictWrapper will be returned where all fields are available as attributes. REMDATA are the remaining binary data, unused by the Struct object. """ code = ('def parse_binary(self, data, display, rawdict = 0):\n' ' ret = {}\n' ' val = struct.unpack("%s", data[:%d])\n' % (self.static_codes, self.static_size)) lengths = {} formats = {} vno = 0 fno = 0 for f in self.static_fields: # Fields without name should be ignored. This is typically # pad and constant fields if not f.name: pass # Store index in val for Length and Format fields, to be used # when treating varfields. elif isinstance(f, LengthField): if f.parse_value is None: lengths[f.name] = 'val[%d]' % vno else: lengths[f.name] = ('self.static_fields[%d].' 'parse_value(val[%d], display)' % (fno, vno)) elif isinstance(f, FormatField): formats[f.name] = 'val[%d]' % vno # Treat value fields the same was as in parse_value. else: if f.structvalues == 1: vrange = str(vno) else: vrange = '%d:%d' % (vno, vno + f.structvalues) if f.parse_value is None: code = code + ' ret["%s"] = val[%s]\n' % (f.name, vrange) else: code = code + (' ret["%s"] = self.static_fields[%d].' 'parse_value(val[%s], display)\n' % (f.name, fno, vrange)) fno = fno + 1 vno = vno + f.structvalues code = code + ' data = buffer(data, %d)\n' % self.static_size # Call parse_binary_value for each var_field, passing the # length and format values from the unpacked val. fno = 0 for f in self.var_fields: code = code + (' ret["%s"], data = ' 'self.var_fields[%d].parse_binary_value' '(data, display, %s, %s)\n' % (f.name, fno, lengths.get(f.name, 'None'), formats.get(f.name, 'None'))) fno = fno + 1 code = code + ' if not rawdict: ret = DictWrapper(ret)\n' code = code + ' return ret, data\n' # print # print code # print # Finally, compile function as for to_binary. exec code self.parse_binary = new.instancemethod(parse_binary, self, self.__class__) # Call it manually return self.parse_binary(data, display, rawdict) class TextElements8(ValueField): string_textitem = Struct( LengthOf('string', 1), Int8('delta'), String8('string', pad = 0) ) def pack_value(self, value): data = '' args = {} for v in value: # Let values be simple strings, meaning a delta of 0 if type(v) is types.StringType: v = (0, v) # A tuple, it should be (delta, string) # Encode it as one or more textitems if type(v) in (types.TupleType, types.DictType) or \ isinstance(v, DictWrapper): if type(v) is types.TupleType: delta, str = v else: delta = v['delta'] str = v['string'] while delta or str: args['delta'] = delta args['string'] = str[:254] data = data + apply(self.string_textitem.to_binary, (), args) delta = 0 str = str[254:] # Else an integer, i.e. a font change else: # Use fontable cast function if instance if type(v) is types.InstanceType: v = v.__fontable__() data = data + struct.pack('>BL', 255, v) # Pad out to four byte length dlen = len(data) return data + '\0' * ((4 - dlen % 4) % 4), None, None def parse_binary_value(self, data, display, length, format): values = [] while 1: if len(data) < 2: break # font change if ord(data[0]) == 255: values.append(struct.unpack('>L', str(data[1:5]))[0]) data = buffer(data, 5) # skip null strings elif ord(data[0]) == 0 and ord(data[1]) == 0: data = buffer(data, 2) # string with delta else: v, data = self.string_textitem.parse_binary(data, display) values.append(v) return values, '' class TextElements16(TextElements8): string_textitem = Struct( LengthOf('string', 1), Int8('delta'), String16('string', pad = 0) ) class GetAttrData: def __getattr__(self, attr): try: if self._data: return self._data[attr] else: raise AttributeError(attr) except KeyError: raise AttributeError(attr) class DictWrapper(GetAttrData): def __init__(self, dict): self.__dict__['_data'] = dict def __getitem__(self, key): return self._data[key] def __setitem__(self, key, value): self._data[key] = value def __delitem__(self, key): del self._data[key] def __setattr__(self, key, value): self._data[key] = value def __delattr__(self, key): del self._data[key] def __str__(self): return str(self._data) def __repr__(self): return '%s(%s)' % (self.__class__, repr(self._data)) def __cmp__(self, other): if isinstance(other, DictWrapper): return cmp(self._data, other._data) else: return cmp(self._data, other) class Request: def __init__(self, display, onerror = None, *args, **keys): self._errorhandler = onerror self._binary = apply(self._request.to_binary, args, keys) self._serial = None display.send_request(self, onerror is not None) def _set_error(self, error): if self._errorhandler is not None: return call_error_handler(self._errorhandler, error, self) else: return 0 class ReplyRequest(GetAttrData): def __init__(self, display, defer = 0, *args, **keys): self._display = display self._binary = apply(self._request.to_binary, args, keys) self._serial = None self._data = None self._error = None self._response_lock = lock.allocate_lock() self._display.send_request(self, 1) if not defer: self.reply() def reply(self): # Send request and wait for reply if we hasn't # already got one. This means that reply() can safely # be called more than one time. self._response_lock.acquire() while self._data is None and self._error is None: self._display.send_recv_lock.acquire() self._response_lock.release() self._display.send_and_recv(request = self._serial) self._response_lock.acquire() self._response_lock.release() self._display = None # If error has been set, raise it if self._error: raise self._error def _parse_response(self, data): self._response_lock.acquire() self._data, d = self._reply.parse_binary(data, self._display, rawdict = 1) self._response_lock.release() def _set_error(self, error): self._response_lock.acquire() self._error = error self._response_lock.release() return 1 def __repr__(self): return '<%s serial = %s, data = %s, error = %s>' % (self.__class__, self._serial, self._data, self._error) class Event(GetAttrData): def __init__(self, binarydata = None, display = None, **keys): if binarydata: self._binary = binarydata self._data, data = self._fields.parse_binary(binarydata, display, rawdict = 1) # split event type into type and send_event bit self._data['send_event'] = not not self._data['type'] & 0x80 self._data['type'] = self._data['type'] & 0x7f else: if self._code: keys['type'] = self._code keys['sequence_number'] = 0 self._binary = apply(self._fields.to_binary, (), keys) keys['send_event'] = 0 self._data = keys def __repr__(self): kwlist = [] for kw, val in self._data.items(): if kw == 'send_event': continue if kw == 'type' and self._data['send_event']: val = val | 0x80 kwlist.append('%s = %s' % (kw, repr(val))) kws = string.join(kwlist, ', ') return '%s(%s)' % (self.__class__, kws) def __cmp__(self, other): if isinstance(other, Event): return cmp(self._data, other._data) else: return cmp(self._data, other) def call_error_handler(handler, error, request): try: return handler(error, request) except: sys.stderr.write('Exception raised by error handler.\n') traceback.print_exc() return 0 python-xlib-0.14+20091101/Xlib/protocol/structs.py0000644000175000017500000001230610770020473020154 0ustar stewstew# Xlib.protocol.structs -- some common request structures # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Xlib modules from Xlib import X # Xlib.protocol modules import rq def WindowValues(arg): return rq.ValueList( arg, 4, 0, rq.Pixmap('background_pixmap'), rq.Card32('background_pixel'), rq.Pixmap('border_pixmap'), rq.Card32('border_pixel'), rq.Gravity('bit_gravity'), rq.Gravity('win_gravity'), rq.Set('backing_store', 1, (X.NotUseful, X.WhenMapped, X.Always)), rq.Card32('backing_planes'), rq.Card32('backing_pixel'), rq.Bool('override_redirect'), rq.Bool('save_under'), rq.Card32('event_mask'), rq.Card32('do_not_propagate_mask'), rq.Colormap('colormap'), rq.Cursor('cursor'), ) def GCValues(arg): return rq.ValueList( arg, 4, 0, rq.Set('function', 1, (X.GXclear, X.GXand, X.GXandReverse, X.GXcopy, X.GXandInverted, X.GXnoop, X.GXxor, X.GXor, X.GXnor, X.GXequiv, X.GXinvert, X.GXorReverse, X.GXcopyInverted, X.GXorInverted, X.GXnand, X.GXset)), rq.Card32('plane_mask'), rq.Card32('foreground'), rq.Card32('background'), rq.Card16('line_width'), rq.Set('line_style', 1, (X.LineSolid, X.LineOnOffDash, X.LineDoubleDash)), rq.Set('cap_style', 1, (X.CapNotLast, X.CapButt, X.CapRound, X.CapProjecting)), rq.Set('join_style', 1, (X.JoinMiter, X.JoinRound, X.JoinBevel)), rq.Set('fill_style', 1, (X.FillSolid, X.FillTiled, X.FillStippled, X.FillOpaqueStippled)), rq.Set('fill_rule', 1, (X.EvenOddRule, X.WindingRule)), rq.Pixmap('tile'), rq.Pixmap('stipple'), rq.Int16('tile_stipple_x_origin'), rq.Int16('tile_stipple_y_origin'), rq.Font('font'), rq.Set('subwindow_mode', 1, (X.ClipByChildren, X.IncludeInferiors)), rq.Bool('graphics_exposures'), rq.Int16('clip_x_origin'), rq.Int16('clip_y_origin'), rq.Pixmap('clip_mask'), rq.Card16('dash_offset'), rq.Card8('dashes'), rq.Set('arc_mode', 1, (X.ArcChord, X.ArcPieSlice)) ) TimeCoord = rq.Struct( rq.Card32('time'), rq.Int16('x'), rq.Int16('y'), ) Host = rq.Struct( rq.Set('family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)), rq.Pad(1), rq.LengthOf('name', 2), rq.List('name', rq.Card8Obj) ) CharInfo = rq.Struct( rq.Int16('left_side_bearing'), rq.Int16('right_side_bearing'), rq.Int16('character_width'), rq.Int16('ascent'), rq.Int16('descent'), rq.Card16('attributes'), ) FontProp = rq.Struct( rq.Card32('name'), rq.Card32('value'), ) ColorItem = rq.Struct( rq.Card32('pixel'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Card8('flags'), rq.Pad(1), ) RGB = rq.Struct( rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), ) Point = rq.Struct( rq.Int16('x'), rq.Int16('y'), ) Segment = rq.Struct( rq.Int16('x1'), rq.Int16('y1'), rq.Int16('x2'), rq.Int16('y2'), ) Rectangle = rq.Struct( rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) Arc = rq.Struct( rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Int16('angle1'), rq.Int16('angle2'), ) python-xlib-0.14+20091101/Xlib/protocol/ChangeLog0000644000175000017500000001037710460447310017652 0ustar stewstew2006-07-22 Mike Grant * Xlib/protocol/display.py: (mggrant) Fix for 1219457 - flushing was blocking and waiting for a read operation. Added missing "import socket" per bug report #681511. Fix for bug:1098695 & 1098738. The "recv" variable was being used for more than one thing - renamed one. Changelog hasn't been maintained since 2002, but some of the more significant comments from cvs logs follow: * Xlib/protocol/request.py: (petli) Fix bugs in definition and method of GrabButton/Pointer 2002-02-22 Peter Liljenberg * event.py(CirculateNotify, CirculateRequest): These are identical, so subclass the common Circulate. 2002-02-13 Peter Liljenberg * rq.py (ValueList.parse_binary_value): Use = both for calcsize and unpacking. Caused problems on Alpha. 2002-02-11 Peter Liljenberg * request.py (GetWindowAttributes): Rename class to win_class. (AllocColorPlanes): Fix Pad(4) to Pad(8) in reply. * rq.py (ReplyLength): Add a reply length field, for completeness and easier unit test generation. 2002-02-10 Peter Liljenberg * rq.py (DictWrapper.__cmp__): Let DictWrapper compare with plain dictionaries. (Event.__init__): Set send_event to 0 when creating new events objects, and allow events to be compared. (Struct.parse_binary): Allow LengthFields to have a parse_value method. (OddLength.parse_value): Decode field. (String16.parse_binary_value): Handle OddLength fields. (TextElements8.parse_binary_value): Bugfix: return values instead of v. (String8.parse_binary_value): Parse String8 with no LengthOf field. 2002-02-09 Peter Liljenberg * rq.py (TextElements16): Bugfix: inherit TextElements8 instead of TextElements16. Found while preparing unit tests, whee. 2002-01-14 Peter Liljenberg * display.py (Display.parse_event_response): Fix bug reported by Ilpo Nyyssönen, whereby ReplyRequests which generates events (e.g. get_property with delete = 1) will get dropped when the event is received. 2001-12-14 Peter Liljenberg * display.py (Display.parse_event_response): * rq.py (Event.__init__): Fixed bug in event type decoding: bit 0-6 is the event type, and bit 7 is set if the event was sent by SendEvent. 2001-01-16 * event.py: Changed some class names so that they correspond exactly to the event type constants. Tue Jan 9 10:03:25 2001 Peter Liljenberg * display.py (Display.send_request): Fixed a call to append() with multiple arguments, something that modern Pythons don't allow. 2001-01-04 * rq.py: The fix for 64-bit platforms didn't work, and close scrutiny of structmodule.c shows why: it turns out that '=' translates into '<' or '>', the one the platform would use. This means B is one byte, H is two and L is four, and no extra alignment, always. '@', which is the default, selects native number of bytes, which on Alpha means that 'L' is eight bytes. Now the code goes to pains to ensure that '=' encoding is always used, so _now_ it should work on all platforms. Ahem. 2000-12-29 * rq.py: Optimizations: + replace calls to Field.get_name() with access to attribute name. (Struct.build_from_args): Fri Dec 29 17:05:02 2000 Peter Liljenberg * rq.py: Alpha forces us to probe how many bytes each struct code in 'bhil' represents, instead of being able to assume that b is 1, h is 2 and l is 4. 2000-12-21 * request.py (SetClipRectangles): Fixed typo (attribute was "rectangels"). 2000-12-20 * rq.py (DictWrapper.__setitem__), (DictWrapper.__delitem__), (DictWrapper.__setattr__), (DictWrapper.__delattr__): Add a few methods to the DictWrapper, to make sure that even if attributes are changed, all attributes can be found in the _data mapping. (ValueField.__init__): (Object.__init__): (ValueField.pack_value): (Set.__init__): Added a default parameter, so that structure elements with a default value can be omitted when calling build_from_args. python-xlib-0.14+20091101/Xlib/protocol/event.py0000644000175000017500000003601410770020473017570 0ustar stewstew# Xlib.protocol.event -- definitions of core events # # Copyright (C) 2000-2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Xlib modules from Xlib import X # Xlib.protocol modules import rq class AnyEvent(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.FixedString('data', 28), ) class KeyButtonPointer(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('root'), rq.Window('window'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('event_x'), rq.Int16('event_y'), rq.Card16('state'), rq.Card8('same_screen'), rq.Pad(1), ) class KeyPress(KeyButtonPointer): _code = X.KeyPress class KeyRelease(KeyButtonPointer): _code = X.KeyRelease class ButtonPress(KeyButtonPointer): _code = X.ButtonPress class ButtonRelease(KeyButtonPointer): _code = X.ButtonRelease class MotionNotify(KeyButtonPointer): _code = X.MotionNotify class EnterLeave(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('root'), rq.Window('window'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('event_x'), rq.Int16('event_y'), rq.Card16('state'), rq.Card8('mode'), rq.Card8('flags'), ) class EnterNotify(EnterLeave): _code = X.EnterNotify class LeaveNotify(EnterLeave): _code = X.LeaveNotify class Focus(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('detail'), rq.Card16('sequence_number'), rq.Window('window'), rq.Card8('mode'), rq.Pad(23), ) class FocusIn(Focus): _code = X.FocusIn class FocusOut(Focus): _code = X.FocusOut class Expose(rq.Event): _code = X.Expose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card16('x'), rq.Card16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('count'), rq.Pad(14), ) class GraphicsExpose(rq.Event): _code = X.GraphicsExpose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Drawable('drawable'), rq.Card16('x'), rq.Card16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('minor_event'), rq.Card16('count'), rq.Card8('major_event'), rq.Pad(11), ) class NoExpose(rq.Event): _code = X.NoExpose _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Drawable('window'), rq.Card16('minor_event'), rq.Card8('major_event'), rq.Pad(21), ) class VisibilityNotify(rq.Event): _code = X.VisibilityNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card8('state'), rq.Pad(23), ) class CreateNotify(rq.Event): _code = X.CreateNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card8('override'), rq.Pad(9), ) class DestroyNotify(rq.Event): _code = X.DestroyNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Pad(20), ) class UnmapNotify(rq.Event): _code = X.UnmapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Card8('from_configure'), rq.Pad(19), ) class MapNotify(rq.Event): _code = X.MapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Card8('override'), rq.Pad(19), ) class MapRequest(rq.Event): _code = X.MapRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Pad(20), ) class ReparentNotify(rq.Event): _code = X.ReparentNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), rq.Card8('override'), rq.Pad(11), ) class ConfigureNotify(rq.Event): _code = X.ConfigureNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Window('above_sibling', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card8('override'), rq.Pad(5), ) class ConfigureRequest(rq.Event): _code = X.ConfigureRequest _fields = rq.Struct( rq.Card8('type'), rq.Card8('stack_mode'), rq.Card16('sequence_number'), rq.Window('parent'), rq.Window('window'), rq.Window('sibling', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Card16('value_mask'), rq.Pad(4), ) class GravityNotify(rq.Event): _code = X.GravityNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Pad(16), ) class ResizeRequest(rq.Event): _code = X.ResizeRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card16('width'), rq.Card16('height'), rq.Pad(20), ) class Circulate(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('event'), rq.Window('window'), rq.Pad(4), rq.Card8('place'), rq.Pad(15), ) class CirculateNotify(Circulate): _code = X.CirculateNotify class CirculateRequest(Circulate): _code = X.CirculateRequest class PropertyNotify(rq.Event): _code = X.PropertyNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('atom'), rq.Card32('time'), rq.Card8('state'), rq.Pad(15), ) class SelectionClear(rq.Event): _code = X.SelectionClear _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('window'), rq.Card32('atom'), rq.Pad(16), ) class SelectionRequest(rq.Event): _code = X.SelectionRequest _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('owner'), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Pad(4), ) class SelectionNotify(rq.Event): _code = X.SelectionNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('time'), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Pad(8), ) class ColormapNotify(rq.Event): _code = X.ColormapNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Window('window'), rq.Colormap('colormap', (X.NONE, )), rq.Card8('new'), rq.Card8('state'), rq.Pad(18), ) class MappingNotify(rq.Event): _code = X.MappingNotify _fields = rq.Struct( rq.Card8('type'), rq.Pad(1), rq.Card16('sequence_number'), rq.Card8('request'), rq.Card8('first_keycode'), rq.Card8('count'), rq.Pad(25), ) class ClientMessage(rq.Event): _code = X.ClientMessage _fields = rq.Struct( rq.Card8('type'), rq.Format('data', 1), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('client_type'), rq.FixedPropertyData('data', 20), ) class KeymapNotify(rq.Event): _code = X.KeymapNotify _fields = rq.Struct( rq.Card8('type'), rq.FixedList('data', 31, rq.Card8Obj, pad = 0) ) event_class = { X.KeyPress: KeyPress, X.KeyRelease: KeyRelease, X.ButtonPress: ButtonPress, X.ButtonRelease: ButtonRelease, X.MotionNotify: MotionNotify, X.EnterNotify: EnterNotify, X.LeaveNotify: LeaveNotify, X.FocusIn: FocusIn, X.FocusOut: FocusOut, X.KeymapNotify: KeymapNotify, X.Expose: Expose, X.GraphicsExpose: GraphicsExpose, X.NoExpose: NoExpose, X.VisibilityNotify: VisibilityNotify, X.CreateNotify: CreateNotify, X.DestroyNotify: DestroyNotify, X.UnmapNotify: UnmapNotify, X.MapNotify: MapNotify, X.MapRequest: MapRequest, X.ReparentNotify: ReparentNotify, X.ConfigureNotify: ConfigureNotify, X.ConfigureRequest: ConfigureRequest, X.GravityNotify: GravityNotify, X.ResizeRequest: ResizeRequest, X.CirculateNotify: CirculateNotify, X.CirculateRequest: CirculateRequest, X.PropertyNotify: PropertyNotify, X.SelectionClear: SelectionClear, X.SelectionRequest: SelectionRequest, X.SelectionNotify: SelectionNotify, X.ColormapNotify: ColormapNotify, X.ClientMessage: ClientMessage, X.MappingNotify: MappingNotify, } python-xlib-0.14+20091101/Xlib/protocol/__init__.py0000644000175000017500000000166210770020473020207 0ustar stewstew# Xlib.protocol.__init__ -- glue for Xlib.protocol package # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __all__ = [ 'display', 'event', 'request', 'rq', 'structs', ] python-xlib-0.14+20091101/Xlib/protocol/request.py0000644000175000017500000013456610770020473020152 0ustar stewstew# Xlib.protocol.request -- definitions of core requests # # Copyright (C) 2000-2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Xlib modules from Xlib import X # Xlib.protocol modules import rq import structs class CreateWindow(rq.Request): _request = rq.Struct( rq.Opcode(1), rq.Card8('depth'), rq.RequestLength(), rq.Window('wid'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Set('window_class', 2, (X.CopyFromParent, X.InputOutput, X.InputOnly)), rq.Card32('visual'), structs.WindowValues('attrs'), ) class ChangeWindowAttributes(rq.Request): _request = rq.Struct( rq.Opcode(2), rq.Pad(1), rq.RequestLength(), rq.Window('window'), structs.WindowValues('attrs'), ) class GetWindowAttributes(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(3), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('backing_store'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('visual'), rq.Card16('win_class'), rq.Card8('bit_gravity'), rq.Card8('win_gravity'), rq.Card32('backing_bit_planes'), rq.Card32('backing_pixel'), rq.Card8('save_under'), rq.Card8('map_is_installed'), rq.Card8('map_state'), rq.Card8('override_redirect'), rq.Colormap('colormap', (X.NONE, )), rq.Card32('all_event_masks'), rq.Card32('your_event_mask'), rq.Card16('do_not_propagate_mask'), rq.Pad(2), ) class DestroyWindow(rq.Request): _request = rq.Struct( rq.Opcode(4), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class DestroySubWindows(rq.Request): _request = rq.Struct( rq.Opcode(5), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class ChangeSaveSet(rq.Request): _request = rq.Struct( rq.Opcode(6), rq.Set('mode', 1, (X.SetModeInsert, X.SetModeDelete)), rq.RequestLength(), rq.Window('window'), ) class ReparentWindow(rq.Request): _request = rq.Struct( rq.Opcode(7), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Window('parent'), rq.Int16('x'), rq.Int16('y'), ) class MapWindow(rq.Request): _request = rq.Struct( rq.Opcode(8), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class MapSubwindows(rq.Request): _request = rq.Struct( rq.Opcode(9), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class UnmapWindow(rq.Request): _request = rq.Struct( rq.Opcode(10), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class UnmapSubwindows(rq.Request): _request = rq.Struct( rq.Opcode(11), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) class ConfigureWindow(rq.Request): _request = rq.Struct( rq.Opcode(12), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.ValueList( 'attrs', 2, 2, rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Int16('border_width'), rq.Window('sibling'), rq.Set('stack_mode', 1, (X.Above, X.Below, X.TopIf, X.BottomIf, X.Opposite)) ) ) class CirculateWindow(rq.Request): _request = rq.Struct( rq.Opcode(13), rq.Set('direction', 1, (X.RaiseLowest, X.LowerHighest)), rq.RequestLength(), rq.Window('window'), ) class GetGeometry(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(14), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable') ) _reply = rq.Struct ( rq.ReplyCode(), rq.Card8('depth'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card16('border_width'), rq.Pad(10) ) class QueryTree(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(15), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Window('parent', (X.NONE, )), rq.LengthOf('children', 2), rq.Pad(14), rq.List('children', rq.WindowObj), ) class InternAtom(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(16), rq.Bool('only_if_exists'), rq.RequestLength(), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('atom'), rq.Pad(20), ) class GetAtomName(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(17), rq.Pad(1), rq.RequestLength(), rq.Card32('atom') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('name', 2), rq.Pad(22), rq.String8('name'), ) class ChangeProperty(rq.Request): _request = rq.Struct( rq.Opcode(18), rq.Set('mode', 1, (X.PropModeReplace, X.PropModePrepend, X.PropModeAppend)), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), rq.Card32('type'), rq.Format('data', 1), rq.Pad(3), rq.LengthOf('data', 4), rq.PropertyData('data'), ) class DeleteProperty(rq.Request): _request = rq.Struct( rq.Opcode(19), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), ) class GetProperty(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(20), rq.Bool('delete'), rq.RequestLength(), rq.Window('window'), rq.Card32('property'), rq.Card32('type'), rq.Card32('long_offset'), rq.Card32('long_length'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('value', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('property_type'), rq.Card32('bytes_after'), rq.LengthOf('value', 4), rq.Pad(12), rq.PropertyData('value'), ) class ListProperties(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(21), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('atoms', 2), rq.Pad(22), rq.List('atoms', rq.Card32Obj), ) class SetSelectionOwner(rq.Request): _request = rq.Struct( rq.Opcode(22), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('selection'), rq.Card32('time'), ) class GetSelectionOwner(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(23), rq.Pad(1), rq.RequestLength(), rq.Card32('selection') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('owner', (X.NONE, )), rq.Pad(20), ) class ConvertSelection(rq.Request): _request = rq.Struct( rq.Opcode(24), rq.Pad(1), rq.RequestLength(), rq.Window('requestor'), rq.Card32('selection'), rq.Card32('target'), rq.Card32('property'), rq.Card32('time'), ) class SendEvent(rq.Request): _request = rq.Struct( rq.Opcode(25), rq.Bool('propagate'), rq.RequestLength(), rq.Window('destination'), rq.Card32('event_mask'), rq.EventField('event'), ) class GrabPointer(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(26), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('event_mask'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Window('confine_to', (X.NONE, )), rq.Cursor('cursor', (X.NONE, )), rq.Card32('time'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class UngrabPointer(rq.Request): _request = rq.Struct( rq.Opcode(27), rq.Pad(1), rq.RequestLength(), rq.Card32('time') ) class GrabButton(rq.Request): _request = rq.Struct( rq.Opcode(28), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('event_mask'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Window('confine_to', (X.NONE, )), rq.Cursor('cursor', (X.NONE, )), rq.Card8('button'), rq.Pad(1), rq.Card16('modifiers'), ) class UngrabButton(rq.Request): _request = rq.Struct( rq.Opcode(29), rq.Card8('button'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Pad(2), ) class ChangeActivePointerGrab(rq.Request): _request = rq.Struct( rq.Opcode(30), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor'), rq.Card32('time'), rq.Card16('event_mask'), rq.Pad(2), ) class GrabKeyboard(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(31), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card32('time'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class UngrabKeyboard(rq.Request): _request = rq.Struct( rq.Opcode(32), rq.Pad(1), rq.RequestLength(), rq.Card32('time') ) class GrabKey(rq.Request): _request = rq.Struct( rq.Opcode(33), rq.Bool('owner_events'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Card8('key'), rq.Set('pointer_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Set('keyboard_mode', 1, (X.GrabModeSync, X.GrabModeAsync)), rq.Pad(3), ) class UngrabKey(rq.Request): _request = rq.Struct( rq.Opcode(34), rq.Card8('key'), rq.RequestLength(), rq.Window('grab_window'), rq.Card16('modifiers'), rq.Pad(2), ) class AllowEvents(rq.Request): _request = rq.Struct( rq.Opcode(35), rq.Set('mode', 1, (X.AsyncPointer, X.SyncPointer, X.ReplayPointer, X.AsyncKeyboard, X.SyncKeyboard, X.ReplayKeyboard, X.AsyncBoth, X.SyncBoth)), rq.RequestLength(), rq.Card32('time'), ) class GrabServer(rq.Request): _request = rq.Struct( rq.Opcode(36), rq.Pad(1), rq.RequestLength(), ) class UngrabServer(rq.Request): _request = rq.Struct( rq.Opcode(37), rq.Pad(1), rq.RequestLength(), ) class QueryPointer(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(38), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('same_screen'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Window('child', (X.NONE, )), rq.Int16('root_x'), rq.Int16('root_y'), rq.Int16('win_x'), rq.Int16('win_y'), rq.Card16('mask'), rq.Pad(6), ) class GetMotionEvents(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(39), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.Card32('start'), rq.Card32('stop'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('events', 4), rq.Pad(20), rq.List('events', structs.TimeCoord), ) class TranslateCoords(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(40), rq.Pad(1), rq.RequestLength(), rq.Window('src_wid'), rq.Window('dst_wid'), rq.Int16('src_x'), rq.Int16('src_y'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('same_screen'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('child', (X.NONE, )), rq.Int16('x'), rq.Int16('y'), rq.Pad(16), ) class WarpPointer(rq.Request): _request = rq.Struct( rq.Opcode(41), rq.Pad(1), rq.RequestLength(), rq.Window('src_window'), rq.Window('dst_window'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Card16('src_width'), rq.Card16('src_height'), rq.Int16('dst_x'), rq.Int16('dst_y'), ) class SetInputFocus(rq.Request): _request = rq.Struct( rq.Opcode(42), rq.Set('revert_to', 1, (X.RevertToNone, X.RevertToPointerRoot, X.RevertToParent)), rq.RequestLength(), rq.Window('focus'), rq.Card32('time'), ) class GetInputFocus(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(43), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('revert_to'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('focus', (X.NONE, X.PointerRoot)), rq.Pad(20), ) class QueryKeymap(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(44), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.FixedList('map', 32, rq.Card8Obj), ) class OpenFont(rq.Request): _request = rq.Struct( rq.Opcode(45), rq.Pad(1), rq.RequestLength(), rq.Font('fid'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) class CloseFont(rq.Request): _request = rq.Struct( rq.Opcode(46), rq.Pad(1), rq.RequestLength(), rq.Font('font') ) class QueryFont(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(47), rq.Pad(1), rq.RequestLength(), rq.Fontable('font') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('min_bounds', structs.CharInfo), rq.Pad(4), rq.Object('max_bounds', structs.CharInfo), rq.Pad(4), rq.Card16('min_char_or_byte2'), rq.Card16('max_char_or_byte2'), rq.Card16('default_char'), rq.LengthOf('properties', 2), rq.Card8('draw_direction'), rq.Card8('min_byte1'), rq.Card8('max_byte1'), rq.Card8('all_chars_exist'), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.LengthOf('char_infos', 4), rq.List('properties', structs.FontProp), rq.List('char_infos', structs.CharInfo), ) class QueryTextExtents(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(48), rq.OddLength('string'), rq.RequestLength(), rq.Fontable('font'), rq.String16('string'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('draw_direction'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.Int16('overall_ascent'), rq.Int16('overall_descent'), rq.Int32('overall_width'), rq.Int32('overall_left'), rq.Int32('overall_right'), rq.Pad(4), ) class ListFonts(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(49), rq.Pad(1), rq.RequestLength(), rq.Card16('max_names'), rq.LengthOf('pattern', 2), rq.String8('pattern'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('fonts', 2), rq.Pad(22), rq.List('fonts', rq.Str), ) class ListFontsWithInfo(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(50), rq.Pad(1), rq.RequestLength(), rq.Card16('max_names'), rq.LengthOf('pattern', 2), rq.String8('pattern'), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('name', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('min_bounds', structs.CharInfo), rq.Pad(4), rq.Object('max_bounds', structs.CharInfo), rq.Pad(4), rq.Card16('min_char_or_byte2'), rq.Card16('max_char_or_byte2'), rq.Card16('default_char'), rq.LengthOf('properties', 2), rq.Card8('draw_direction'), rq.Card8('min_byte1'), rq.Card8('max_byte1'), rq.Card8('all_chars_exist'), rq.Int16('font_ascent'), rq.Int16('font_descent'), rq.Card32('replies_hint'), rq.List('properties', structs.FontProp), rq.String8('name'), ) # Somebody must have smoked some really wicked weed when they # defined the ListFontsWithInfo request: # The server sends a reply for _each_ matching font... # It then sends a special reply (name length == 0) to indicate # that there are no more fonts in the reply. # This means that we have to do some special parsing to see if # we have got the end-of-reply reply. If we haven't, we # have to reinsert the request in the front of the # display.sent_request queue to catch the next response. # Bastards. def __init__(self, *args, **keys): self._fonts = [] apply(ReplyRequest.__init__, (self, ) + args, keys) def _parse_response(self, data): if ord(data[1]) == 0: self._response_lock.acquire() self._data = self._fonts del self._fonts self._response_lock.release() return r, d = self._reply.parse_binary(data) self._fonts.append(r) self._display.sent_requests.insert(0, self) # Override the default __getattr__, since it isn't usable for # the list reply. Instead provide a __getitem__ and a __len__. def __getattr__(self, attr): raise AttributeError(attr) def __getitem__(self, item): return self._data[item] def __len__(self): return len(self._data) class SetFontPath(rq.Request): _request = rq.Struct( rq.Opcode(51), rq.Pad(1), rq.RequestLength(), rq.LengthOf('path', 2), rq.Pad(2), rq.List('path', rq.Str), ) class GetFontPath(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(52), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('paths', 2), rq.Pad(22), rq.List('paths', rq.Str), ) class CreatePixmap(rq.Request): _request = rq.Struct( rq.Opcode(53), rq.Card8('depth'), rq.RequestLength(), rq.Pixmap('pid'), rq.Drawable('drawable'), rq.Card16('width'), rq.Card16('height'), ) class FreePixmap(rq.Request): _request = rq.Struct( rq.Opcode(54), rq.Pad(1), rq.RequestLength(), rq.Pixmap('pixmap') ) class CreateGC(rq.Request): _request = rq.Struct( rq.Opcode(55), rq.Pad(1), rq.RequestLength(), rq.GC('cid'), rq.Drawable('drawable'), structs.GCValues('attrs'), ) class ChangeGC(rq.Request): _request = rq.Struct( rq.Opcode(56), rq.Pad(1), rq.RequestLength(), rq.GC('gc'), structs.GCValues('attrs'), ) class CopyGC(rq.Request): _request = rq.Struct( rq.Opcode(57), rq.Pad(1), rq.RequestLength(), rq.GC('src_gc'), rq.GC('dst_gc'), rq.Card32('mask'), ) class SetDashes(rq.Request): _request = rq.Struct( rq.Opcode(58), rq.Pad(1), rq.RequestLength(), rq.GC('gc'), rq.Card16('dash_offset'), rq.LengthOf('dashes', 2), rq.List('dashes', rq.Card8Obj), ) class SetClipRectangles(rq.Request): _request = rq.Struct( rq.Opcode(59), rq.Set('ordering', 1, (X.Unsorted, X.YSorted, X.YXSorted, X.YXBanded)), rq.RequestLength(), rq.GC('gc'), rq.Int16('x_origin'), rq.Int16('y_origin'), rq.List('rectangles', structs.Rectangle), ) class FreeGC(rq.Request): _request = rq.Struct( rq.Opcode(60), rq.Pad(1), rq.RequestLength(), rq.GC('gc') ) class ClearArea(rq.Request): _request = rq.Struct( rq.Opcode(61), rq.Bool('exposures'), rq.RequestLength(), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) class CopyArea(rq.Request): _request = rq.Struct( rq.Opcode(62), rq.Pad(1), rq.RequestLength(), rq.Drawable('src_drawable'), rq.Drawable('dst_drawable'), rq.GC('gc'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card16('width'), rq.Card16('height'), ) class CopyPlane(rq.Request): _request = rq.Struct( rq.Opcode(63), rq.Pad(1), rq.RequestLength(), rq.Drawable('src_drawable'), rq.Drawable('dst_drawable'), rq.GC('gc'), rq.Int16('src_x'), rq.Int16('src_y'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('bit_plane'), ) class PolyPoint(rq.Request): _request = rq.Struct( rq.Opcode(64), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('points', structs.Point), ) class PolyLine(rq.Request): _request = rq.Struct( rq.Opcode(65), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('points', structs.Point), ) class PolySegment(rq.Request): _request = rq.Struct( rq.Opcode(66), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('segments', structs.Segment), ) class PolyRectangle(rq.Request): _request = rq.Struct( rq.Opcode(67), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('rectangles', structs.Rectangle), ) class PolyArc(rq.Request): _request = rq.Struct( rq.Opcode(68), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('arcs', structs.Arc), ) class FillPoly(rq.Request): _request = rq.Struct( rq.Opcode(69), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Set('shape', 1, (X.Complex, X.Nonconvex, X.Convex)), rq.Set('coord_mode', 1, (X.CoordModeOrigin, X.CoordModePrevious)), rq.Pad(2), rq.List('points', structs.Point), ) class PolyFillRectangle(rq.Request): _request = rq.Struct( rq.Opcode(70), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('rectangles', structs.Rectangle), ) class PolyFillArc(rq.Request): _request = rq.Struct( rq.Opcode(71), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.List('arcs', structs.Arc), ) class PutImage(rq.Request): _request = rq.Struct( rq.Opcode(72), rq.Set('format', 1, (X.XYBitmap, X.XYPixmap, X.ZPixmap)), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Card16('width'), rq.Card16('height'), rq.Int16('dst_x'), rq.Int16('dst_y'), rq.Card8('left_pad'), rq.Card8('depth'), rq.Pad(2), rq.String8('data'), ) class GetImage(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(73), rq.Set('format', 1, (X.XYPixmap, X.ZPixmap)), rq.RequestLength(), rq.Drawable('drawable'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('plane_mask'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('depth'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('visual'), rq.Pad(20), rq.String8('data'), ) class PolyText8(rq.Request): _request = rq.Struct( rq.Opcode(74), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.TextElements8('items'), ) class PolyText16(rq.Request): _request = rq.Struct( rq.Opcode(75), rq.Pad(1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.TextElements16('items'), ) class ImageText8(rq.Request): _request = rq.Struct( rq.Opcode(76), rq.LengthOf('string', 1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.String8('string'), ) class ImageText16(rq.Request): _request = rq.Struct( rq.Opcode(77), rq.LengthOf('string', 1), rq.RequestLength(), rq.Drawable('drawable'), rq.GC('gc'), rq.Int16('x'), rq.Int16('y'), rq.String16('string'), ) class CreateColormap(rq.Request): _request = rq.Struct( rq.Opcode(78), rq.Set('alloc', 1, (X.AllocNone, X.AllocAll)), rq.RequestLength(), rq.Colormap('mid'), rq.Window('window'), rq.Card32('visual'), ) class FreeColormap(rq.Request): _request = rq.Struct( rq.Opcode(79), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class CopyColormapAndFree(rq.Request): _request = rq.Struct( rq.Opcode(80), rq.Pad(1), rq.RequestLength(), rq.Colormap('mid'), rq.Colormap('src_cmap'), ) class InstallColormap(rq.Request): _request = rq.Struct( rq.Opcode(81), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class UninstallColormap(rq.Request): _request = rq.Struct( rq.Opcode(82), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap') ) class ListInstalledColormaps(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(83), rq.Pad(1), rq.RequestLength(), rq.Window('window') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('cmaps', 2), rq.Pad(22), rq.List('cmaps', rq.ColormapObj), ) class AllocColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(84), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), rq.Pad(2), rq.Card32('pixel'), rq.Pad(12), ) class AllocNamedColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(85), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('pixel'), rq.Card16('exact_red'), rq.Card16('exact_green'), rq.Card16('exact_blue'), rq.Card16('screen_red'), rq.Card16('screen_green'), rq.Card16('screen_blue'), rq.Pad(8), ) class AllocColorCells(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(86), rq.Bool('contiguous'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('colors'), rq.Card16('planes'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('pixels', 2), rq.LengthOf('masks', 2), rq.Pad(20), rq.List('pixels', rq.Card32Obj), rq.List('masks', rq.Card32Obj), ) class AllocColorPlanes(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(87), rq.Bool('contiguous'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card16('colors'), rq.Card16('red'), rq.Card16('green'), rq.Card16('blue'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('pixels', 2), rq.Pad(2), rq.Card32('red_mask'), rq.Card32('green_mask'), rq.Card32('blue_mask'), rq.Pad(8), rq.List('pixels', rq.Card32Obj), ) class FreeColors(rq.Request): _request = rq.Struct( rq.Opcode(88), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.Card32('plane_mask'), rq.List('pixels', rq.Card32Obj), ) class StoreColors(rq.Request): _request = rq.Struct( rq.Opcode(89), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.List('items', structs.ColorItem), ) class StoreNamedColor(rq.Request): _request = rq.Struct( rq.Opcode(90), rq.Card8('flags'), rq.RequestLength(), rq.Colormap('cmap'), rq.Card32('pixel'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) class QueryColors(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(91), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.List('pixels', rq.Card32Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('colors', 2), rq.Pad(22), rq.List('colors', structs.RGB), ) class LookupColor(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(92), rq.Pad(1), rq.RequestLength(), rq.Colormap('cmap'), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('exact_red'), rq.Card16('exact_green'), rq.Card16('exact_blue'), rq.Card16('screen_red'), rq.Card16('screen_green'), rq.Card16('screen_blue'), rq.Pad(12), ) class CreateCursor(rq.Request): _request = rq.Struct( rq.Opcode(93), rq.Pad(1), rq.RequestLength(), rq.Cursor('cid'), rq.Pixmap('source'), rq.Pixmap('mask'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), rq.Card16('x'), rq.Card16('y'), ) class CreateGlyphCursor(rq.Request): _request = rq.Struct( rq.Opcode(94), rq.Pad(1), rq.RequestLength(), rq.Cursor('cid'), rq.Font('source'), rq.Font('mask'), rq.Card16('source_char'), rq.Card16('mask_char'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), ) class FreeCursor(rq.Request): _request = rq.Struct( rq.Opcode(95), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor') ) class RecolorCursor(rq.Request): _request = rq.Struct( rq.Opcode(96), rq.Pad(1), rq.RequestLength(), rq.Cursor('cursor'), rq.Card16('fore_red'), rq.Card16('fore_green'), rq.Card16('fore_blue'), rq.Card16('back_red'), rq.Card16('back_green'), rq.Card16('back_blue'), ) class QueryBestSize(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(97), rq.Set('item_class', 1, (X.CursorShape, X.TileShape, X.StippleShape)), rq.RequestLength(), rq.Drawable('drawable'), rq.Card16('width'), rq.Card16('height'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('width'), rq.Card16('height'), rq.Pad(20), ) class QueryExtension(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(98), rq.Pad(1), rq.RequestLength(), rq.LengthOf('name', 2), rq.Pad(2), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card8('present'), rq.Card8('major_opcode'), rq.Card8('first_event'), rq.Card8('first_error'), rq.Pad(20), ) class ListExtensions(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(99), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('names', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.List('names', rq.Str), ) class ChangeKeyboardMapping(rq.Request): _request = rq.Struct( rq.Opcode(100), rq.LengthOf('keysyms', 1), rq.RequestLength(), rq.Card8('first_keycode'), rq.Format('keysyms', 1), rq.Pad(2), rq.KeyboardMapping('keysyms'), ) class GetKeyboardMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(101), rq.Pad(1), rq.RequestLength(), rq.Card8('first_keycode'), rq.Card8('count'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('keysyms', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.KeyboardMapping('keysyms'), ) class ChangeKeyboardControl(rq.Request): _request = rq.Struct( rq.Opcode(102), rq.Pad(1), rq.RequestLength(), rq.ValueList( 'attrs', 4, 0, rq.Int8('key_click_percent'), rq.Int8('bell_percent'), rq.Int16('bell_pitch'), rq.Int16('bell_duration'), rq.Card8('led'), rq.Set('led_mode', 1, (X.LedModeOff, X.LedModeOn)), rq.Card8('key'), rq.Set('auto_repeat_mode', 1, (X.AutoRepeatModeOff, X.AutoRepeatModeOn, X.AutoRepeatModeDefault)) ) ) class GetKeyboardControl(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(103), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('global_auto_repeat'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('led_mask'), rq.Card8('key_click_percent'), rq.Card8('bell_percent'), rq.Card16('bell_pitch'), rq.Card16('bell_duration'), rq.Pad(2), rq.FixedList('auto_repeats', 32, rq.Card8Obj), ) class Bell(rq.Request): _request = rq.Struct( rq.Opcode(104), rq.Int8('percent'), rq.RequestLength(), ) class ChangePointerControl(rq.Request): _request = rq.Struct( rq.Opcode(105), rq.Pad(1), rq.RequestLength(), rq.Int16('accel_num'), rq.Int16('accel_denum'), rq.Int16('threshold'), rq.Bool('do_accel'), rq.Bool('do_thresh'), ) class GetPointerControl(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(106), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('accel_num'), rq.Card16('accel_denom'), rq.Card16('threshold'), rq.Pad(18), ) class SetScreenSaver(rq.Request): _request = rq.Struct( rq.Opcode(107), rq.Pad(1), rq.RequestLength(), rq.Int16('timeout'), rq.Int16('interval'), rq.Set('prefer_blank', 1, (X.DontPreferBlanking, X.PreferBlanking, X.DefaultBlanking)), rq.Set('allow_exposures', 1, (X.DontAllowExposures, X.AllowExposures, X.DefaultExposures)), rq.Pad(2), ) class GetScreenSaver(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(108), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('timeout'), rq.Card16('interval'), rq.Card8('prefer_blanking'), rq.Card8('allow_exposures'), rq.Pad(18), ) class ChangeHosts(rq.Request): _request = rq.Struct( rq.Opcode(109), rq.Set('mode', 1, (X.HostInsert, X.HostDelete)), rq.RequestLength(), rq.Set('host_family', 1, (X.FamilyInternet, X.FamilyDECnet, X.FamilyChaos)), rq.Pad(1), rq.LengthOf('host', 2), rq.List('host', rq.Card8Obj) ) class ListHosts(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(110), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('mode'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('hosts', 2), rq.Pad(22), rq.List('hosts', structs.Host), ) class SetAccessControl(rq.Request): _request = rq.Struct( rq.Opcode(111), rq.Set('mode', 1, (X.DisableAccess, X.EnableAccess)), rq.RequestLength(), ) class SetCloseDownMode(rq.Request): _request = rq.Struct( rq.Opcode(112), rq.Set('mode', 1, (X.DestroyAll, X.RetainPermanent, X.RetainTemporary)), rq.RequestLength(), ) class KillClient(rq.Request): _request = rq.Struct( rq.Opcode(113), rq.Pad(1), rq.RequestLength(), rq.Resource('resource') ) class RotateProperties(rq.Request): _request = rq.Struct( rq.Opcode(114), rq.Pad(1), rq.RequestLength(), rq.Window('window'), rq.LengthOf('properties', 2), rq.Int16('delta'), rq.List('properties', rq.Card32Obj), ) class ForceScreenSaver(rq.Request): _request = rq.Struct( rq.Opcode(115), rq.Set('mode', 1, (X.ScreenSaverReset, X.ScreenSaverActive)), rq.RequestLength(), ) class SetPointerMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(116), rq.LengthOf('map', 1), rq.RequestLength(), rq.List('map', rq.Card8Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class GetPointerMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(117), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.LengthOf('map', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.List('map', rq.Card8Obj), ) class SetModifierMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(118), rq.Format('keycodes', 1), rq.RequestLength(), rq.ModifierMapping('keycodes') ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) class GetModifierMapping(rq.ReplyRequest): _request = rq.Struct( rq.Opcode(119), rq.Pad(1), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('keycodes', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), rq.ModifierMapping('keycodes') ) class NoOperation(rq.Request): _request = rq.Struct( rq.Opcode(127), rq.Pad(1), rq.RequestLength(), ) major_codes = { 1: CreateWindow, 2: ChangeWindowAttributes, 3: GetWindowAttributes, 4: DestroyWindow, 5: DestroySubWindows, 6: ChangeSaveSet, 7: ReparentWindow, 8: MapWindow, 9: MapSubwindows, 10: UnmapWindow, 11: UnmapSubwindows, 12: ConfigureWindow, 13: CirculateWindow, 14: GetGeometry, 15: QueryTree, 16: InternAtom, 17: GetAtomName, 18: ChangeProperty, 19: DeleteProperty, 20: GetProperty, 21: ListProperties, 22: SetSelectionOwner, 23: GetSelectionOwner, 24: ConvertSelection, 25: SendEvent, 26: GrabPointer, 27: UngrabPointer, 28: GrabButton, 29: UngrabButton, 30: ChangeActivePointerGrab, 31: GrabKeyboard, 32: UngrabKeyboard, 33: GrabKey, 34: UngrabKey, 35: AllowEvents, 36: GrabServer, 37: UngrabServer, 38: QueryPointer, 39: GetMotionEvents, 40: TranslateCoords, 41: WarpPointer, 42: SetInputFocus, 43: GetInputFocus, 44: QueryKeymap, 45: OpenFont, 46: CloseFont, 47: QueryFont, 48: QueryTextExtents, 49: ListFonts, 50: ListFontsWithInfo, 51: SetFontPath, 52: GetFontPath, 53: CreatePixmap, 54: FreePixmap, 55: CreateGC, 56: ChangeGC, 57: CopyGC, 58: SetDashes, 59: SetClipRectangles, 60: FreeGC, 61: ClearArea, 62: CopyArea, 63: CopyPlane, 64: PolyPoint, 65: PolyLine, 66: PolySegment, 67: PolyRectangle, 68: PolyArc, 69: FillPoly, 70: PolyFillRectangle, 71: PolyFillArc, 72: PutImage, 73: GetImage, 74: PolyText8, 75: PolyText16, 76: ImageText8, 77: ImageText16, 78: CreateColormap, 79: FreeColormap, 80: CopyColormapAndFree, 81: InstallColormap, 82: UninstallColormap, 83: ListInstalledColormaps, 84: AllocColor, 85: AllocNamedColor, 86: AllocColorCells, 87: AllocColorPlanes, 88: FreeColors, 89: StoreColors, 90: StoreNamedColor, 91: QueryColors, 92: LookupColor, 93: CreateCursor, 94: CreateGlyphCursor, 95: FreeCursor, 96: RecolorCursor, 97: QueryBestSize, 98: QueryExtension, 99: ListExtensions, 100: ChangeKeyboardMapping, 101: GetKeyboardMapping, 102: ChangeKeyboardControl, 103: GetKeyboardControl, 104: Bell, 105: ChangePointerControl, 106: GetPointerControl, 107: SetScreenSaver, 108: GetScreenSaver, 109: ChangeHosts, 110: ListHosts, 111: SetAccessControl, 112: SetCloseDownMode, 113: KillClient, 114: RotateProperties, 115: ForceScreenSaver, 116: SetPointerMapping, 117: GetPointerMapping, 118: SetModifierMapping, 119: GetModifierMapping, 127: NoOperation, } python-xlib-0.14+20091101/Xlib/display.py0000644000175000017500000010542410770020473016255 0ustar stewstew# Xlib.display -- high level display object # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Python modules import new # Xlib modules import error import ext import X # Xlib.protocol modules import protocol.display from protocol import request, event, rq # Xlib.xobjects modules import xobject.resource import xobject.drawable import xobject.fontable import xobject.colormap import xobject.cursor _resource_baseclasses = { 'resource': xobject.resource.Resource, 'drawable': xobject.drawable.Drawable, 'window': xobject.drawable.Window, 'pixmap': xobject.drawable.Pixmap, 'fontable': xobject.fontable.Fontable, 'font': xobject.fontable.Font, 'gc': xobject.fontable.GC, 'colormap': xobject.colormap.Colormap, 'cursor': xobject.cursor.Cursor, } _resource_hierarchy = { 'resource': ('drawable', 'window', 'pixmap', 'fontable', 'font', 'gc', 'colormap', 'cursor'), 'drawable': ('window', 'pixmap'), 'fontable': ('font', 'gc') } class _BaseDisplay(protocol.display.Display): resource_classes = _resource_baseclasses.copy() # Implement a cache of atom names, used by Window objects when # dealing with some ICCCM properties not defined in Xlib.Xatom def __init__(self, *args, **keys): apply(protocol.display.Display.__init__, (self, ) + args, keys) self._atom_cache = {} def get_atom(self, atomname, only_if_exists=0): if self._atom_cache.has_key(atomname): return self._atom_cache[atomname] r = request.InternAtom(display = self, name = atomname, only_if_exists = only_if_exists) # don't cache NONE responses in case someone creates this later if r.atom != X.NONE: self._atom_cache[atomname] = r.atom return r.atom class Display: def __init__(self, display = None): self.display = _BaseDisplay(display) # Create the keymap cache self._keymap_codes = [()] * 256 self._keymap_syms = {} self._update_keymap(self.display.info.min_keycode, (self.display.info.max_keycode - self.display.info.min_keycode + 1)) # Translations for keysyms to strings. self.keysym_translations = {} # Find all supported extensions self.extensions = [] self.class_extension_dicts = {} self.display_extension_methods = {} self.extension_event = rq.DictWrapper({}) exts = self.list_extensions() # Go through all extension modules for extname, modname in ext.__extensions__: if extname in exts: # Import the module and fetch it __import__('Xlib.ext.' + modname) mod = getattr(ext, modname) info = self.query_extension(extname) self.display.set_extension_major(extname, info.major_opcode) # Call initialiasation function mod.init(self, info) self.extensions.append(extname) # Finalize extensions by creating new classes for type, dict in self.class_extension_dicts.items(): origcls = self.display.resource_classes[type] self.display.resource_classes[type] = new.classobj(origcls.__name__, (origcls,), dict) # Problem: we have already created some objects without the # extensions: the screen roots and default colormaps. # Fix that by reinstantiating them. for screen in self.display.info.roots: screen.root = self.display.resource_classes['window'](self.display, screen.root.id) screen.default_colormap = self.display.resource_classes['colormap'](self.display, screen.default_colormap.id) def get_display_name(self): """Returns the name used to connect to the server, either provided when creating the Display object, or fetched from the environmental variable $DISPLAY.""" return self.display.get_display_name() def fileno(self): """Returns the file descriptor number of the underlying socket. This method is provided to allow Display objects to be passed select.select().""" return self.display.fileno() def close(self): """Close the display, freeing the resources that it holds.""" self.display.close() def set_error_handler(self, handler): """Set the default error handler which will be called for all unhandled errors. handler should take two arguments as a normal request error handler, but the second argument (the request) will be None. See section Error Handling.""" self.display.set_error_handler(handler) def flush(self): """Flush the request queue, building and sending the queued requests. This can be necessary in applications that never wait for events, and in threaded applications.""" self.display.flush() def sync(self): """Flush the queue and wait until the server has processed all the queued requests. Use this e.g. when it is important that errors caused by a certain request is trapped.""" # Do a light-weight replyrequest to sync. There must # be a better way to do it... self.get_pointer_control() def next_event(self): """Return the next event. If there are no events queued, it will block until the next event is fetched from the server.""" return self.display.next_event() def pending_events(self): """Return the number of events queued, i.e. the number of times that Display.next_event() can be called without blocking.""" return self.display.pending_events() def has_extension(self, extension): """Check if both the server and the client library support the X extension named extension.""" return extension in self.extensions def create_resource_object(self, type, id): """Create a resource object of type for the integer id. type should be one of the following strings: resource drawable window pixmap fontable font gc colormap cursor This function can be used when a resource ID has been fetched e.g. from an resource or a command line argument. Resource objects should never be created by instantiating the appropriate class directly, since any X extensions dynamically added by the library will not be available. """ return self.display.resource_classes[type](self.display, id) # We need this to handle display extension methods def __getattr__(self, attr): try: function = self.display_extension_methods[attr] return new.instancemethod(function, self, self.__class__) except KeyError: raise AttributeError(attr) ### ### display information retrieval ### def screen(self, sno = None): if sno is None: return self.display.info.roots[self.display.default_screen] else: return self.display.info.roots[sno] def screen_count(self): """Return the total number of screens on the display.""" return len(self.display.info.roots) def get_default_screen(self): """Return the number of the default screen, extracted from the display name.""" return self.display.get_default_screen() ### ### Extension module interface ### def extension_add_method(self, object, name, function): """extension_add_method(object, name, function) Add an X extension module method. OBJECT is the type of object to add the function to, a string from this list: display resource drawable window pixmap fontable font gc colormap cursor NAME is the name of the method, a string. FUNCTION is a normal function whose first argument is a 'self'. """ if object == 'display': if hasattr(self, name): raise error.MethodOverrideError('attempting to replace display method: %s' % name) self.display_extension_methods[name] = function else: types = (object, ) + _resource_hierarchy.get(object, ()) for type in types: cls = _resource_baseclasses[type] if hasattr(cls, name): raise error.MethodOverrideError('attempting to replace %s method: %s' % (type, name)) method = new.instancemethod(function, None, cls) # Maybe should check extension overrides too try: self.class_extension_dicts[type][name] = method except KeyError: self.class_extension_dicts[type] = { name: method } def extension_add_event(self, code, evt, name = None): """extension_add_event(code, evt, [name]) Add an extension event. CODE is the numeric code, and EVT is the event class. EVT will be cloned, and the attribute _code of the new event class will be set to CODE. If NAME is ommitted, it will be set to the name of EVT. This name is used to insert an entry in the DictWrapper extension_event. """ newevt = new.classobj(evt.__name__, evt.__bases__, evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt) if name is None: name = evt.__name__ setattr(self.extension_event, name, code) def add_extension_error(self, code, err): """add_extension_error(code, err) Add an extension error. CODE is the numeric code, and ERR is the error class. """ self.display.add_extension_error(code, err) ### ### keymap cache implementation ### # The keycode->keysym map is stored in a list with 256 elements. # Each element represents a keycode, and the tuple elements are # the keysyms bound to the key. # The keysym->keycode map is stored in a mapping, where the keys # are keysyms. The values are a sorted list of tuples with two # elements each: (index, keycode) # keycode is the code for a key to which this keysym is bound, and # index is the keysyms index in the map for that keycode. def keycode_to_keysym(self, keycode, index): """Convert a keycode to a keysym, looking in entry index. Normally index 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shift+alt grid. If that key entry is not bound, X.NoSymbol is returned.""" try: return self._keymap_codes[keycode][index] except IndexError: return X.NoSymbol def keysym_to_keycode(self, keysym): """Look up the primary keycode that is bound to keysym. If several keycodes are found, the one with the lowest index and lowest code is returned. If keysym is not bound to any key, 0 is returned.""" try: return self._keymap_syms[keysym][0][1] except (KeyError, IndexError): return 0 def keysym_to_keycodes(self, keysym): """Look up all the keycodes that is bound to keysym. A list of tuples (keycode, index) is returned, sorted primarily on the lowest index and secondarily on the lowest keycode.""" try: # Copy the map list, reversing the arguments return map(lambda x: (x[1], x[0]), self._keymap_syms[keysym]) except KeyError: return [] def refresh_keyboard_mapping(self, evt): """This method should be called once when a MappingNotify event is received, to update the keymap cache. evt should be the event object.""" if isinstance(evt, event.MappingNotify): if evt.request == X.MappingKeyboard: self._update_keymap(evt.first_keycode, evt.count) else: raise TypeError('expected a MappingNotify event') def _update_keymap(self, first_keycode, count): """Internal function, called to refresh the keymap cache. """ # Delete all sym->code maps for the changed codes lastcode = first_keycode + count for keysym, codes in self._keymap_syms.items(): i = 0 while i < len(codes): code = codes[i][1] if code >= first_keycode and code < lastcode: del codes[i] else: i = i + 1 # Get the new keyboard mapping keysyms = self.get_keyboard_mapping(first_keycode, count) # Replace code->sym map with the new map self._keymap_codes[first_keycode:lastcode] = keysyms # Update sym->code map code = first_keycode for syms in keysyms: index = 0 for sym in syms: if sym != X.NoSymbol: if self._keymap_syms.has_key(sym): symcodes = self._keymap_syms[sym] symcodes.append((index, code)) symcodes.sort() else: self._keymap_syms[sym] = [(index, code)] index = index + 1 code = code + 1 ### ### client-internal keysym to string translations ### def lookup_string(self, keysym): """Return a string corresponding to KEYSYM, or None if no reasonable translation is found. """ s = self.keysym_translations.get(keysym) if s is not None: return s import Xlib.XK return Xlib.XK.keysym_to_string(keysym) def rebind_string(self, keysym, newstring): """Change the translation of KEYSYM to NEWSTRING. If NEWSTRING is None, remove old translation if any. """ if newstring is None: try: del self.keysym_translations[keysym] except KeyError: pass else: self.keysym_translations[keysym] = newstring ### ### X requests ### def intern_atom(self, name, only_if_exists = 0): """Intern the string name, returning its atom number. If only_if_exists is true and the atom does not already exist, it will not be created and X.NONE is returned.""" r = request.InternAtom(display = self.display, name = name, only_if_exists = only_if_exists) return r.atom def get_atom(self, atom, only_if_exists = 0): """Alias for intern_atom, using internal cache""" return self.display.get_atom(atom, only_if_exists) def get_atom_name(self, atom): """Look up the name of atom, returning it as a string. Will raise BadAtom if atom does not exist.""" r = request.GetAtomName(display = self.display, atom = atom) return r.name def get_selection_owner(self, selection): """Return the window that owns selection (an atom), or X.NONE if there is no owner for the selection. Can raise BadAtom.""" r = request.GetSelectionOwner(display = self.display, selection = selection) return r.owner def send_event(self, destination, event, event_mask = 0, propagate = 0, onerror = None): """Send a synthetic event to the window destination which can be a window object, or X.PointerWindow or X.InputFocus. event is the event object to send, instantiated from one of the classes in protocol.events. See XSendEvent(3X11) for details. There is also a Window.send_event() method.""" request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, destination = destination, event_mask = event_mask, event = event) def ungrab_pointer(self, time, onerror = None): """elease a grabbed pointer and any queued events. See XUngrabPointer(3X11).""" request.UngrabPointer(display = self.display, onerror = onerror, time = time) def change_active_pointer_grab(self, event_mask, cursor, time, onerror = None): """Change the dynamic parameters of a pointer grab. See XChangeActivePointerGrab(3X11).""" request.ChangeActivePointerGrab(display = self.display, onerror = onerror, cursor = cursor, time = time, event_mask = event_mask) def ungrab_keyboard(self, time, onerror = None): """Ungrab a grabbed keyboard and any queued events. See XUngrabKeyboard(3X11).""" request.UngrabKeyboard(display = self.display, onerror = onerror, time = time) def allow_events(self, mode, time, onerror = None): """Release some queued events. mode should be one of X.AsyncPointer, X.SyncPointer, X.AsyncKeyboard, X.SyncKeyboard, X.ReplayPointer, X.ReplayKeyboard, X.AsyncBoth, or X.SyncBoth. time should be a timestamp or X.CurrentTime.""" request.AllowEvents(display = self.display, onerror = onerror, mode = mode, time = time) def grab_server(self, onerror = None): """Disable processing of requests on all other client connections until the server is ungrabbed. Server grabbing should be avoided as much as possible.""" request.GrabServer(display = self.display, onerror = onerror) def ungrab_server(self, onerror = None): """Release the server if it was previously grabbed by this client.""" request.UngrabServer(display = self.display, onerror = onerror) def warp_pointer(self, x, y, src_window = X.NONE, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None): """Move the pointer relative its current position by the offsets (x, y). However, if src_window is a window the pointer is only moved if the specified rectangle in src_window contains it. If src_width is 0 it will be replaced with the width of src_window - src_x. src_height is treated in a similar way. To move the pointer to absolute coordinates, use Window.warp_pointer().""" request.WarpPointer(display = self.display, onerror = onerror, src_window = src_window, dst_window = X.NONE, src_x = src_x, src_y = src_y, src_width = src_width, src_height = src_height, dst_x = x, dst_y = y) def set_input_focus(self, focus, revert_to, time, onerror = None): """Set input focus to focus, which should be a window, X.PointerRoot or X.NONE. revert_to specifies where the focus reverts to if the focused window becomes not visible, and should be X.RevertToParent, RevertToPointerRoot, or RevertToNone. See XSetInputFocus(3X11) for details. There is also a Window.set_input_focus().""" request.SetInputFocus(display = self.display, onerror = onerror, revert_to = revert_to, focus = focus, time = time) def get_input_focus(self): """Return an object with the following attributes: focus The window which currently holds the input focus, X.NONE or X.PointerRoot. revert_to Where the focus will revert, one of X.RevertToParent, RevertToPointerRoot, or RevertToNone. """ return request.GetInputFocus(display = self.display) def query_keymap(self): """Return a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as a list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N.""" r = request.QueryKeymap(display = self.display) return r.map def open_font(self, name): """Open the font identifed by the pattern name and return its font object. If name does not match any font, None is returned.""" fid = self.display.allocate_resource_id() ec = error.CatchError(error.BadName) request.OpenFont(display = self.display, onerror = ec, fid = fid, name = name) self.sync() if ec.get_error(): self.display.free_resource_id(fid) return None else: cls = self.display.get_resource_class('font', xobject.fontable.Font) return cls(self.display, fid, owner = 1) def list_fonts(self, pattern, max_names): """Return a list of font names matching pattern. No more than max_names will be returned.""" r = request.ListFonts(display = self.display, max_names = max_names, pattern = pattern) return r.fonts def list_fonts_with_info(self, pattern, max_names): """Return a list of fonts matching pattern. No more than max_names will be returned. Each list item represents one font and has the following properties: name The name of the font. min_bounds max_bounds min_char_or_byte2 max_char_or_byte2 default_char draw_direction min_byte1 max_byte1 all_chars_exist font_ascent font_descent replies_hint See the descripton of XFontStruct in XGetFontProperty(3X11) for details on these values. properties A list of properties. Each entry has two attributes: name The atom identifying this property. value A 32-bit unsigned value. """ return request.ListFontsWithInfo(display = self.display, max_names = max_names, pattern = pattern) def set_font_path(self, path, onerror = None): """Set the font path to path, which should be a list of strings. If path is empty, the default font path of the server will be restored.""" request.SetFontPath(display = self.display, onerror = onerror, path = path) def get_font_path(self): """Return the current font path as a list of strings.""" r = request.GetFontPath(display = self.display) return r.paths def query_extension(self, name): """Ask the server if it supports the extension name. If it is supported an object with the following attributes is returned: major_opcode The major opcode that the requests of this extension uses. first_event The base event code if the extension have additional events, or 0. first_error The base error code if the extension have additional errors, or 0. If the extension is not supported, None is returned.""" r = request.QueryExtension(display = self.display, name = name) if r.present: return r else: return None def list_extensions(self): """Return a list of all the extensions provided by the server.""" r = request.ListExtensions(display = self.display) return r.names def change_keyboard_mapping(self, first_keycode, keysyms, onerror = None): """Modify the keyboard mapping, starting with first_keycode. keysyms is a list of tuples of keysyms. keysyms[n][i] will be assigned to keycode first_keycode+n at index i.""" request.ChangeKeyboardMapping(display = self.display, onerror = onerror, first_keycode = first_keycode, keysyms = keysyms) def get_keyboard_mapping(self, first_keycode, count): """Return the current keyboard mapping as a list of tuples, starting at first_keycount and no more than count.""" r = request.GetKeyboardMapping(display = self.display, first_keycode = first_keycode, count = count) return r.keysyms def change_keyboard_control(self, onerror = None, **keys): """Change the parameters provided as keyword arguments: key_click_percent The volume of key clicks between 0 (off) and 100 (load). -1 will restore default setting. bell_percent The base volume of the bell, coded as above. bell_pitch The pitch of the bell in Hz, -1 restores the default. bell_duration The duration of the bell in milliseconds, -1 restores the default. led led_mode led_mode should be X.LedModeOff or X.LedModeOn. If led is provided, it should be a 32-bit mask listing the LEDs that should change. If led is not provided, all LEDs are changed. key auto_repeat_mode auto_repeat_mode should be one of X.AutoRepeatModeOff, X.AutoRepeatModeOn, or X.AutoRepeatModeDefault. If key is provided, that key will be modified, otherwise the global state for the entire keyboard will be modified.""" request.ChangeKeyboardControl(display = self.display, onerror = onerror, attrs = keys) def get_keyboard_control(self): """Return an object with the following attributes: global_auto_repeat X.AutoRepeatModeOn or X.AutoRepeatModeOff. auto_repeats A list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. If a bit is on, autorepeat is enabled for the corresponding key. led_mask A 32-bit mask indicating which LEDs are on. key_click_percent The volume of key click, from 0 to 100. bell_percent bell_pitch bell_duration The volume, pitch and duration of the bell. """ return request.GetKeyboardControl(display = self.display) def bell(self, percent = 0, onerror = None): """Ring the bell at the volume percent which is relative the base volume. See XBell(3X11).""" request.Bell(display = self.display, onerror = onerror, percent = percent) def change_pointer_control(self, accel = None, threshold = None, onerror = None): """To change the pointer acceleration, set accel to a tuple (num, denum). The pointer will then move num/denum times the normal speed if it moves beyond the threshold number of pixels at once. To change the threshold, set it to the number of pixels. -1 restores the default.""" if accel is None: do_accel = 0 accel_num = 0 accel_denum = 0 else: do_accel = 1 accel_num, accel_denum = accel if threshold is None: do_threshold = 0 else: do_threshold = 1 request.ChangePointerControl(display = self.display, onerror = onerror, do_accel = do_accel, do_thres = do_threshold, accel_num = accel_num, accel_denum = accel_denum, threshold = threshold) def get_pointer_control(self): """Return an object with the following attributes: accel_num accel_denom The acceleration as numerator/denumerator. threshold The number of pixels the pointer must move before the acceleration kicks in.""" return request.GetPointerControl(display = self.display) def set_screen_saver(self, timeout, interval, prefer_blank, allow_exposures, onerror = None): """See XSetScreenSaver(3X11).""" request.SetScreenSaver(display = self.display, onerror = onerror, timeout = timeout, interval = interval, prefer_blank = prefer_blank, allow_exposures = allow_exposures) def get_screen_saver(self): """Return an object with the attributes timeout, interval, prefer_blanking, allow_exposures. See XGetScreenSaver(3X11) for details.""" return request.GetScreenSaver(display = self.display) def change_hosts(self, mode, host_family, host, onerror = None): """mode is either X.HostInsert or X.HostDelete. host_family is one of X.FamilyInternet, X.FamilyDECnet or X.FamilyChaos. host is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address.""" request.ChangeHosts(display = self.display, onerror = onerror, mode = mode, host_family = host_family, host = host) def list_hosts(self): """Return an object with the following attributes: mode X.EnableAccess if the access control list is used, X.DisableAccess otherwise. hosts The hosts on the access list. Each entry has the following attributes: family X.FamilyInternet, X.FamilyDECnet, or X.FamilyChaos. name A list of byte values, the coding depends on family. For the Internet family, it is the 4 bytes of an IPv4 address. """ return request.ListHosts(display = self.display) def set_access_control(self, mode, onerror = None): """Enable use of access control lists at connection setup if mode is X.EnableAccess, disable if it is X.DisableAccess.""" request.SetAccessControl(display = self.display, onerror = onerror, mode = mode) def set_close_down_mode(self, mode, onerror = None): """Control what will happen with the client's resources at connection close. The default is X.DestroyAll, the other values are X.RetainPermanent and X.RetainTemporary.""" request.SetCloseDownMode(display = self.display, onerror = onerror, mode = mode) def force_screen_saver(self, mode, onerror = None): """If mode is X.ScreenSaverActive the screen saver is activated. If it is X.ScreenSaverReset, the screen saver is deactivated as if device input had been received.""" request.ForceScreenSaver(display = self.display, onerror = onerror, mode = mode) def set_pointer_mapping(self, map): """Set the mapping of the pointer buttons. map is a list of logical button numbers. map must be of the same length as the list returned by Display.get_pointer_mapping(). map[n] sets the logical number for the physical button n+1. Logical number 0 disables the button. Two physical buttons cannot be mapped to the same logical number. If one of the buttons to be altered are logically in the down state, X.MappingBusy is returned and the mapping is not changed. Otherwise the mapping is changed and X.MappingSuccess is returned.""" r = request.SetPointerMapping(display = self.display, map = map) return r.status def get_pointer_mapping(self): """Return a list of the pointer button mappings. Entry N in the list sets the logical button number for the physical button N+1.""" r = request.GetPointerMapping(display = self.display) return r.map def set_modifier_mapping(self, keycodes): """Set the keycodes for the eight modifiers X.Shift, X.Lock, X.Control, X.Mod1, X.Mod2, X.Mod3, X.Mod4 and X.Mod5. keycodes should be a eight-element list where each entry is a list of the keycodes that should be bound to that modifier. If any changed key is logically in the down state, X.MappingBusy is returned and the mapping is not changed. If the mapping violates some server restriction, X.MappingFailed is returned. Otherwise the mapping is changed and X.MappingSuccess is returned.""" r = request.SetModifierMapping(display = self.display, keycodes = keycodes) return r.status def get_modifier_mapping(self): """Return a list of eight lists, one for each modifier. The list can be indexed using X.ShiftMapIndex, X.Mod1MapIndex, and so on. The sublists list the keycodes bound to that modifier.""" r = request.GetModifierMapping(display = self.display) return r.keycodes def no_operation(self, onerror = None): """Do nothing but send a request to the server.""" request.NoOperation(display = self.display, onerror = onerror) python-xlib-0.14+20091101/Xlib/ext/0000755000175000017500000000000011273361453015035 5ustar stewstewpython-xlib-0.14+20091101/Xlib/ext/record.py0000644000175000017500000002221110770020473016656 0ustar stewstew# Xlib.ext.record -- RECORD extension module # # Copyright (C) 2006 Alex Badea # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; 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.Object('major_range', Record_Range8), rq.Object('minor_range', Record_Range16)) 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 str(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 apply(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) python-xlib-0.14+20091101/Xlib/ext/xtest.py0000644000175000017500000001071710770020473016557 0ustar stewstew# Xlib.ext.xtest -- XTEST extension module # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; 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 = 'XTEST' CurrentCursor = 1 class GetVersion(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Pad(1), rq.Card16('minor_version') ) _reply = rq.Struct(rq.Pad(1), rq.Card8('major_version'), rq.Card16('sequence_number'), rq.Pad(4), rq.Card16('minor_version'), rq.Pad(22) ) 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 CompareCursor(rq.ReplyRequest): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), rq.Cursor('cursor', (X.NONE, CurrentCursor)), ) _reply = rq.Struct(rq.Pad(1), rq.Card8('same'), rq.Card16('sequence_number'), rq.Pad(28), ) def compare_cursor(self, cursor): r = CompareCursor(display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, cursor = cursor) return r.same class FakeInput(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Set('event_type', 1, (X.KeyPress, X.KeyRelease, X.ButtonPress, X.ButtonRelease, X.MotionNotify)), rq.Card8('detail'), rq.Pad(2), rq.Card32('time'), rq.Window('root', (X.NONE, )), rq.Pad(8), rq.Int16('x'), rq.Int16('y'), rq.Pad(8) ) def fake_input(self, event_type, detail = 0, time = X.CurrentTime, root = X.NONE, x = 0, y = 0): FakeInput(display = self.display, opcode = self.display.get_extension_major(extname), event_type = event_type, detail = detail, time = time, root = root, x = x, y = y) class GrabControl(rq.Request): _request = rq.Struct(rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Bool('impervious'), rq.Pad(3) ) def grab_control(self, impervious): GrabControl(display = self.display, opcode = self.display.get_extension_major(extname), impervious = impervious) def init(disp, info): disp.extension_add_method('display', 'xtest_get_version', get_version) disp.extension_add_method('window', 'xtest_compare_cursor', compare_cursor) disp.extension_add_method('display', 'xtest_fake_input', fake_input) disp.extension_add_method('display', 'xtest_grab_control', grab_control) python-xlib-0.14+20091101/Xlib/ext/composite.py0000644000175000017500000001642411007421422017404 0ustar stewstew# $Id: xtest.py,v 1.1 2000/08/21 10:03:45 petli Exp $ # # Xlib.ext.composite -- Composite extension module # # Copyright (C) 2007 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Composite extension, allowing windows to be rendered to off-screen storage. For detailed description, see the protocol specification at http://freedesktop.org/wiki/Software/CompositeExt By itself this extension is not very useful, it is intended to be used together with the DAMAGE and XFIXES extensions. Typically you would also need RENDER or glX or some similar method of creating fancy graphics. """ from Xlib import X from Xlib.protocol import rq from Xlib.xobject import drawable extname = 'Composite' RedirectAutomatic = 0 RedirectManual = 1 class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version') ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): return QueryVersion( display = self.display, opcode = self.display.get_extension_major(extname), ) class RedirectWindow(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def redirect_window(self, update): """Redirect the hierarchy starting at this window to off-screen storage. """ RedirectWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class RedirectSubwindows(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def redirect_subwindows(self, update): """Redirect the hierarchies starting at all current and future children to this window to off-screen storage. """ RedirectSubwindows(display = self.display, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class UnredirectWindow(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def unredirect_window(self, update): """Stop redirecting this window hierarchy. """ UnredirectWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class UnredirectSubindows(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Window('window'), rq.Set('update', 1, (RedirectAutomatic, RedirectManual)), rq.Pad(3), ) def unredirect_subwindows(self, update): """Stop redirecting the hierarchies of children to this window. """ RedirectWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self, update = update, ) class CreateRegionFromBorderClip(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Card32('region'), # FIXME: this should be a Region from XFIXES extension rq.Window('window'), ) def create_region_from_border_clip(self): """Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows. """ rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, opcode = self.display.get_extension_major(extname), region = rid, window = self, ) # FIXME: create Region object and return it return rid class NameWindowPixmap(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('window'), rq.Pixmap('pixmap'), ) def name_window_pixmap(self): """Create a new pixmap that refers to the off-screen storage of the window, including its border. This pixmap will remain allocated until freed whatever happens with the window. However, the window will get a new off-screen pixmap every time it is mapped or resized, so to keep track of the contents you must listen for these events and get a new pixmap after them. """ pid = self.display.allocate_resource_id() NameWindowPixmap(display = self.display, opcode = self.display.get_extension_major(extname), window = self, pixmap = pid, ) cls = self.display.get_resource_class('pixmap', drawable.Pixmap) return cls(self.display, pid, owner = 1) def init(disp, info): disp.extension_add_method('display', 'composite_query_version', query_version) disp.extension_add_method('window', 'composite_redirect_window', redirect_window) disp.extension_add_method('window', 'composite_redirect_subwindows', redirect_subwindows) disp.extension_add_method('window', 'composite_unredirect_window', unredirect_window) disp.extension_add_method('window', 'composite_unredirect_subwindows', unredirect_subwindows) disp.extension_add_method('window', 'composite_create_region_from_border_clip', create_region_from_border_clip) disp.extension_add_method('window', 'composite_name_window_pixmap', name_window_pixmap) python-xlib-0.14+20091101/Xlib/ext/randr.py0000644000175000017500000010262511211313074016507 0ustar stewstew# Xlib.ext.randr -- RandR extension module # # Copyright (C) 2006 Mike Meyer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """RandR - provide access to the RandR extension information. This implementation is based off version 1.3 of the XRandR protocol, and may not be compatible with other versions. Version 1.2 of the protocol is documented at: http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt """ from Xlib import X from Xlib.protocol import rq, structs extname = 'RANDR' # Event codes # RRScreenChangeNotify = 0 # V1.2 additions RRNotify = 1 # RRNotify Subcodes RRNotify_CrtcChange = 0 RRNotify_OutputChange = 1 RRNotify_OutputProperty = 2 # Event selection bits # RRScreenChangeNotifyMask = (1 << 0) # V1.2 additions RRCrtcChangeNotifyMask = (1 << 1) RROutputChangeNotifyMask = (1 << 2) RROutputPropertyNotifyMask = (1 << 3) # Constants # SetConfigSuccess = 0 SetConfigInvalidConfigTime = 1 SetConfigInvalidTime = 2 SetConfigFailed = 3 # used in the rotation field; rotation and reflection in 0.1 proto. Rotate_0 = 1 Rotate_90 = 2 Rotate_180 = 4 Rotate_270 = 8 # new in 1.0 protocol, to allow reflection of screen Reflect_X = 16 Reflect_Y = 32 # new in 1.2 protocol HSyncPositive = 0x00000001 HSyncNegative = 0x00000002 VSyncPositive = 0x00000004 VSyncNegative = 0x00000008 Interlace = 0x00000010 DoubleScan = 0x00000020 CSync = 0x00000040 CSyncPositive = 0x00000080 CSyncNegative = 0x00000100 HSkewPresent = 0x00000200 BCast = 0x00000400 PixelMultiplex = 0x00000800 DoubleClock = 0x00001000 ClockDivideBy2 = 0x00002000 # event types? Connected = 0 Disconnected = 1 UnknownConnection = 2 # Conventional RandR output properties PROPERTY_RANDR_EDID = "EDID" PROPERTY_SIGNAL_FORMAT = "SignalFormat" PROPERTY_SIGNAL_PROPERTIES = "SignalProperties" PROPERTY_CONNECTOR_TYPE = "ConnectorType" PROPERTY_CONNECTOR_NUMBER = "ConnectorNumber" PROPERTY_COMPATIBILITY_LIST = "CompatibilityList" PROPERTY_CLONE_LIST = "CloneList" # subpixel order - TODO: These constants are part of the RENDER extension and # should be moved there if/when that extension is added to python-xlib. SubPixelUnknown = 0 SubPixelHorizontalRGB = 1 SubPixelHorizontalBGR = 2 SubPixelVerticalRGB = 3 SubPixelVerticalBGR = 4 SubPixelNone = 5 # Error Codes # BadRROutput = 0 BadRRCrtc = 1 BadRRMode = 2 # Data Structures # RandR_ScreenSizes = rq.Struct( rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_millimeters'), rq.Card16('height_in_millimeters'), ) RandR_ModeInfo = rq.Struct( rq.Card32('id'), rq.Card16('width'), rq.Card16('height'), rq.Card32('dot_clock'), rq.Card16('h_sync_start'), rq.Card16('h_sync_end'), rq.Card16('h_total'), rq.Card16('h_skew'), rq.Card16('v_sync_start'), rq.Card16('v_sync_end'), rq.Card16('v_total'), rq.Card16('name_length'), rq.Card32('flags'), ) RandR_Rates = rq.Struct( rq.LengthOf('rates', 2), rq.List('rates', rq.Card16Obj) ) # TODO: This struct is part of the RENDER extension and should be moved there # if/when that extension is added to python-xlib. Render_Transform = rq.Struct( rq.Card32('matrix11'), #FIXME: All of these are listed as FIXED in the protocol header. rq.Card32('matrix12'), rq.Card32('matrix13'), rq.Card32('matrix21'), rq.Card32('matrix22'), rq.Card32('matrix23'), rq.Card32('matrix31'), rq.Card32('matrix32'), rq.Card32('matrix33'), ) # Requests # class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card32('major_version'), rq.Card32('minor_version'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('major_version'), rq.Card32('minor_version'), rq.Pad(16), ) def query_version(self): """Get the current version of the RandR extension. """ return QueryVersion( display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=3, ) class _1_0SetScreenConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Drawable('drawable'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Card16('size_id'), rq.Card16('rotation'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Card32('new_config_timestamp'), rq.Window('root'), rq.Card16('subpixel_order'), rq.Pad(10), ) def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime): """Sets the screen to the specified size and rotation. """ return _1_0SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, ) class SetScreenConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Drawable('drawable'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Card16('size_id'), rq.Card16('rotation'), rq.Card16('rate'), # added in version 1.1 rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Card32('new_config_timestamp'), rq.Window('root'), rq.Card16('subpixel_order'), rq.Pad(10), ) def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime): """Sets the screen to the specified size, rate, rotation and reflection. rate can be 0 to have the server select an appropriate rate. """ return SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, rate=rate, ) class SelectInput(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Window('window'), rq.Card16('mask'), rq.Pad(2), ) def select_input(self, mask): return SelectInput( display=self.display, opcode=self.display.get_extension_major(extname), window=self, mask=mask, ) class GetScreenInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('set_of_rotations'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('root'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('sizes', 2), rq.Card16('size_id'), rq.Card16('rotation'), rq.Card16('rate'), # added in version 1.1 rq.Card16('n_rate_ents'), # XCB's protocol description disagrees with the X headers on this; ignoring. rq.Pad(2), rq.List('sizes', RandR_ScreenSizes), #rq.List('rates', RandR_Rates) #FIXME: Why does uncommenting this cause an error? ) def get_screen_info(self): """Retrieve information about the current and available configurations for the screen associated with this window. """ return GetScreenInfo( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) # version 1.2 class GetScreenSizeRange(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('min_width'), rq.Card16('min_height'), rq.Card16('max_width'), rq.Card16('max_height'), rq.Pad(16), ) def get_screen_size_range(self): """Retrieve the range of possible screen sizes. The screen may be set to any size within this range. """ return GetScreenSizeRange( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class SetScreenSize(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Window('window'), rq.Card16('width'), rq.Card16('height'), rq.Card32('width_in_millimeters'), rq.Card32('height_in_millimeters'), ) def set_screen_size(self, width, height, width_in_millimeters=None, height_in_millimeters=None): return SetScreenSize( display=self.display, opcode=self.display.get_extension_major(extname), window=self, width=width, height=height, width_in_millimeters=width_in_millimeters, height_in_millimeters=height_in_millimeters, ) class GetScreenResources(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(8), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('crtcs', 2), rq.LengthOf('outputs', 2), rq.LengthOf('modes', 2), rq.LengthOf('mode_names', 2), rq.Pad(8), rq.List('crtcs', rq.Card32Obj), rq.List('outputs', rq.Card32Obj), rq.List('modes', RandR_ModeInfo), rq.String8('mode_names'), ) def get_screen_resources(self): return GetScreenResources( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class GetOutputInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(9), rq.RequestLength(), rq.Card32('output'), rq.Card32('config_timestamp'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('crtc'), rq.Card32('mm_width'), rq.Card32('mm_height'), rq.Card8('connection'), rq.Card8('subpixel_order'), rq.LengthOf('crtcs', 2), rq.LengthOf('modes', 2), rq.LengthOf('preferred', 2), rq.LengthOf('clones', 2), rq.LengthOf('name', 2), rq.List('crtcs', rq.Card32Obj), rq.List('modes', rq.Card32Obj), rq.List('preferred', rq.Card32Obj), rq.List('clones', rq.Card32Obj), rq.String8('name'), ) def get_output_info(self, output, config_timestamp): return GetOutputInfo( display=self.display, opcode=self.display.get_extension_major(extname), output=output, config_timestamp=config_timestamp, ) class ListOutputProperties(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(10), rq.RequestLength(), rq.Card32('output'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('atoms', 2), rq.Pad(22), rq.List('atoms', rq.Card32Obj), ) def list_output_properties(self, output): return ListOutputProperties ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, ) class QueryOutputProperty(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(11), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Bool('pending'), rq.Bool('range'), rq.Bool('immutable'), rq.Pad(21), rq.List('valid_values', rq.Card32Obj), ) def query_output_property(self, output, property): return QueryOutputProperty ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class ConfigureOutputProperty (rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(12), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Bool('pending'), rq.Bool('range'), rq.Pad(2), rq.List('valid_values', rq.Card32Obj), ) def configure_output_property (self, output, property): return ConfigureOutputProperty ( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class ChangeOutputProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(13), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Card32('type'), rq.Format('value', 1), rq.Card8('mode'), rq.Pad(2), rq.LengthOf('value', 4), rq.List('value', rq.Card8Obj), ) def change_output_property(self, output, property, type, format, mode, nUnits): return ChangeOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, type=type, format=format, mode=mode, nUnits=nUnits, ) class DeleteOutputProperty(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(14), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), ) def delete_output_property(self, output, property): return DeleteOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, ) class GetOutputProperty(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(15), rq.RequestLength(), rq.Card32('output'), rq.Card32('property'), rq.Card32('type'), rq.Card32('long_offset'), rq.Card32('long_length'), rq.Bool('delete'), rq.Bool('pending'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Format('value', 1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('property_type'), rq.Card32('bytes_after'), rq.LengthOf('value', 4), rq.Pad(12), rq.List('value', rq.Card8Obj), ) def get_output_property(self, output, property, type, longOffset, longLength): return GetOutputProperty( display=self.display, opcode=self.display.get_extension_major(extname), output=output, property=property, type=type, longOffset=longOffset, longLength=longLength, ) class CreateMode(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(16), rq.RequestLength(), rq.Window('window'), rq.Object('mode', RandR_ModeInfo), rq.String8('name'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('mode'), rq.Pad(20), ) def create_mode(self): return CreateMode ( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class DestroyMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(17), rq.RequestLength(), rq.Card32('mode'), ) def destroy_mode(self, mode): return DestroyMode( display=self.display, opcode=self.display.get_extension_major(extname), mode=mode, ) class AddOutputMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(18), rq.RequestLength(), rq.Card32('output'), rq.Card32('mode'), ) def add_output_mode(self): return AddOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), output=output, mode=mode, ) class DeleteOutputMode(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(19), rq.RequestLength(), rq.Card32('output'), rq.Card32('mode'), ) def delete_output_mode(self): return DeleteOutputMode( display=self.display, opcode=self.display.get_extension_major(extname), output=output, mode=mode, ) class GetCrtcInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(20), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('config_timestamp'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card16('width'), rq.Card16('height'), rq.Card32('mode'), rq.Card16('rotation'), rq.Card16('possible_rotations'), rq.LengthOf('outputs', 2), rq.LengthOf('possible_outputs', 2), rq.List('outputs', rq.Card32Obj), rq.List('possible_outputs', rq.Card32Obj), ) def get_crtc_info(self, crtc, config_timestamp): return GetCrtcInfo ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, config_timestamp=config_timestamp, ) class SetCrtcConfig(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(21), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Int16('x'), rq.Int16('y'), rq.Card32('mode'), rq.Card16('rotation'), rq.Pad(2), rq.List('outputs', rq.Card32Obj), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Pad(20), ) def set_crtc_config(self, crtc, config_timestamp, mode, rotation, timestamp=X.CurrentTime): return SetCrtcConfig ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, config_timestamp=config_timestamp, mode=mode, rotation=rotation, timestamp=timestamp, ) class GetCrtcGammaSize(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(22), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('size'), rq.Pad(22), ) def get_crtc_gamma_size(self, crtc): return GetCrtcGammaSize ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class GetCrtcGamma(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(23), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('size'), rq.Pad(22), rq.List('red', rq.Card16Obj), rq.List('green', rq.Card16Obj), rq.List('blue', rq.Card16Obj), ) def get_crtc_gamma(self, crtc): return GetCrtcGamma ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class SetCrtcGamma(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(24), rq.RequestLength(), rq.Card32('crtc'), rq.Card16('size'), rq.Pad(2), rq.List('red', rq.Card16Obj), rq.List('green', rq.Card16Obj), rq.List('blue', rq.Card16Obj), ) def set_crtc_gamma(self, crtc, size): return SetCrtcGamma( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, size=size, ) # version 1.3 class GetScreenResourcesCurrent(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(25), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.LengthOf('crtcs', 2), rq.LengthOf('outputs', 2), rq.LengthOf('modes', 2), rq.LengthOf('names', 2), rq.Pad(8), rq.List('crtcs', rq.Card32Obj), rq.List('outputs', rq.Card32Obj), rq.List('modes', RandR_ModeInfo), rq.String8('names'), ) def get_screen_resources_current(self): return GetScreenResourcesCurrent( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) class SetCrtcTransform(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(26), rq.RequestLength(), rq.Card32('crtc'), rq.Object('transform', Render_Transform), rq.LengthOf('filter_name', 2), rq.Pad(2), rq.String8('filter_name'), rq.List('filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 ) def set_crtc_transform(self, crtc, n_bytes_filter): return SetCrtcTransform( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, n_bytes_filter=n_bytes_filter, ) class GetCrtcTransform(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(27), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Object('pending_transform', Render_Transform), rq.Bool('has_transforms'), rq.Pad(3), rq.Object('current_transform', Render_Transform), rq.Pad(4), rq.LengthOf('pending_filter_name', 2), rq.LengthOf('pending_filter_params', 2), rq.LengthOf('current_filter_name', 2), rq.LengthOf('current_filter_params', 2), rq.String8('pending_filter_name'), rq.List('pending_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 rq.String8('current_filter_name'), rq.List('current_filter_params', rq.Card32Obj), #FIXME: The protocol says FIXED? http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt#n2161 ) def get_crtc_transform(self, crtc): return GetCrtcTransform( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class GetPanning(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(28), rq.RequestLength(), rq.Card32('crtc'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('timestamp'), rq.Card16('left'), rq.Card16('top'), rq.Card16('width'), rq.Card16('height'), rq.Card16('track_left'), rq.Card16('track_top'), rq.Card16('track_width'), rq.Card16('track_height'), rq.Int16('border_left'), rq.Int16('border_top'), rq.Int16('border_right'), rq.Int16('border_bottom'), ) def get_panning(self, crtc): return GetPanning ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, ) class SetPanning(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(29), rq.RequestLength(), rq.Card32('crtc'), rq.Card32('timestamp'), rq.Card16('left'), rq.Card16('top'), rq.Card16('width'), rq.Card16('height'), rq.Card16('track_left'), rq.Card16('track_top'), rq.Card16('track_width'), rq.Card16('track_height'), rq.Int16('border_left'), rq.Int16('border_top'), rq.Int16('border_right'), rq.Int16('border_bottom'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('status'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('new_timestamp'), rq.Pad(20), ) def set_panning(self, crtc, left, top, width, height, track_left, track_top, track_width, track_height, border_left, border_top, border_width, border_height, timestamp=X.CurrentTime): return SetPanning ( display=self.display, opcode=self.display.get_extension_major(extname), crtc=crtc, left=left, top=top, width=width, height=height, track_left=track_left, track_top=track_top, track_width=track_width, track_height=track_height, border_left=border_left, border_top=border_top, border_width=border_width, border_height=border_height, timestamp=timestamp, ) class SetOutputPrimary(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(30), rq.RequestLength(), rq.Window('window'), rq.Card32('output'), ) def set_output_primary(self, output): return SetOutputPrimary( display=self.display, opcode=self.display.get_extension_major(extname), window=self, output=output, ) class GetOutputPrimary(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(31), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('output'), rq.Pad(20), ) def get_output_primary(self): return GetOutputPrimary( display=self.display, opcode=self.display.get_extension_major(extname), window=self, ) # Events # class ScreenChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('rotation'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Window('root'), rq.Window('window'), rq.Card16('size_id'), rq.Card16('subpixel_order'), rq.Card16('width_in_pixels'), rq.Card16('height_in_pixels'), rq.Card16('width_in_millimeters'), rq.Card16('height_in_millimeters'), ) class CrtcChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Window('window'), rq.Card32('crtc'), rq.Card32('mode'), rq.Card16('rotation'), rq.Pad(2), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), ) class OutputChangeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Card32('timestamp'), rq.Card32('config_timestamp'), rq.Window('window'), rq.Card32('output'), rq.Card32('crtc'), rq.Card32('mode'), rq.Card16('rotation'), rq.Card8('connection'), rq.Card8('subpixel_order'), ) class OutputPropertyNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Card8('sub_code'), rq.Card16('sequence_number'), rq.Window('window'), rq.Card32('output'), rq.Card32('atom'), rq.Card32('timestamp'), rq.Card8('state'), rq.Pad(11), ) # Initialization # def init(disp, info): print info.__class__ disp.extension_add_method('display', 'xrandr_query_version', query_version) disp.extension_add_method('window', 'xrandr_select_input', select_input) disp.extension_add_method('window', 'xrandr_get_screen_info', get_screen_info) disp.extension_add_method('drawable', 'xrandr_1_0set_screen_config', _1_0set_screen_config) disp.extension_add_method('drawable', 'xrandr_set_screen_config', set_screen_config) disp.extension_add_method('window', 'xrandr_get_screen_size_range', get_screen_size_range) disp.extension_add_method('window', 'xrandr_set_screen_size', set_screen_size) disp.extension_add_method('window', 'xrandr_get_screen_resources', get_screen_resources) disp.extension_add_method('display', 'xrandr_get_output_info', get_output_info) disp.extension_add_method('display', 'xrandr_list_output_properties', list_output_properties) disp.extension_add_method('display', 'xrandr_query_output_property', query_output_property) disp.extension_add_method('display', 'xrandr_configure_output_property ', configure_output_property ) disp.extension_add_method('display', 'xrandr_change_output_property', change_output_property) disp.extension_add_method('display', 'xrandr_delete_output_property', delete_output_property) disp.extension_add_method('display', 'xrandr_get_output_property', get_output_property) disp.extension_add_method('window', 'xrandr_create_mode', create_mode) disp.extension_add_method('display', 'xrandr_destroy_mode', destroy_mode) disp.extension_add_method('display', 'xrandr_add_output_mode', add_output_mode) disp.extension_add_method('display', 'xrandr_delete_output_mode', delete_output_mode) disp.extension_add_method('display', 'xrandr_get_crtc_info', get_crtc_info) disp.extension_add_method('display', 'xrandr_set_crtc_config', set_crtc_config) disp.extension_add_method('display', 'xrandr_get_crtc_gamma_size', get_crtc_gamma_size) disp.extension_add_method('display', 'xrandr_get_crtc_gamma', get_crtc_gamma) disp.extension_add_method('display', 'xrandr_set_crtc_gamma', set_crtc_gamma) disp.extension_add_method('window', 'xrandr_get_screen_resources_current', get_screen_resources_current) disp.extension_add_method('display', 'xrandr_set_crtc_transform', set_crtc_transform) disp.extension_add_method('display', 'xrandr_get_crtc_transform', get_crtc_transform) disp.extension_add_method('window', 'xrandr_set_output_primary', set_output_primary) disp.extension_add_method('window', 'xrandr_get_output_primary', get_output_primary) disp.extension_add_method('display', 'xrandr_get_panning', get_panning) disp.extension_add_method('display', 'xrandr_set_panning', set_panning) disp.extension_add_event(info.first_event, ScreenChangeNotify) disp.extension_add_event(info.first_event + 1, CrtcChangeNotify) disp.extension_add_event(info.first_event + 2, OutputChangeNotify) disp.extension_add_event(info.first_event + 3, OutputPropertyNotify) #disp.extension_add_error(BadRROutput, BadRROutputError) #disp.extension_add_error(BadRRCrtc, BadRRCrtcError) #disp.extension_add_error(BadRRMode, BadRRModeError) python-xlib-0.14+20091101/Xlib/ext/xinerama.py0000644000175000017500000001542010633003257017207 0ustar stewstew# Xlib.ext.xinerama -- Xinerama extension module # # Copyright (C) 2006 Mike Meyer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Xinerama - provide access to the Xinerama extension information. There are at least there different - and mutually incomparable - Xinerama extensions available. This uses the one bundled with XFree86 4.6 and/or Xorg 6.9 in the ati/radeon driver. It uses the include files from that X distribution, so should work with it as well. I provide code for the lone Sun 1.0 request that isn't part of 1.1, but this is untested because I don't have a server that implements it. The functions loosely follow the libXineram functions. Mostly, they return an rq.Struct in lieue of passing in pointers that get data from the rq.Struct crammed into them. The exception is isActive, which returns the state information - because that's what libXinerama does.""" from Xlib import X from Xlib.protocol import rq, structs extname = 'XINERAMA' class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), rq.Card8('major_version'), rq.Card8('minor_version'), rq.Pad(2), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def query_version(self): return QueryVersion(display=self.display, opcode=self.display.get_extension_major(extname), major_version=1, minor_version=1) class GetState(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Bool('state'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), rq.Pad(20), ) def get_state(self): return GetState(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, ) class GetScreenCount(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('screen_count'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), rq.Pad(20), ) def get_screen_count(self): return GetScreenCount(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, ) class GetScreenSize(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Window('window'), rq.Card32('screen'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.Card32('length'), rq.Card32('width'), rq.Card32('height'), rq.Window('window'), rq.Card32('screen'), rq.Pad(8), ) def get_screen_size(self, screen_no): """Returns the size of the given screen number""" return GetScreenSize(display=self.display, opcode=self.display.get_extension_major(extname), window=self.id, screen=screen_no, ) # IsActive is only available from Xinerama 1.1 and later. # It should be used in preference to GetState. class IsActive(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('state'), rq.Pad(20), ) def is_active(self): r = IsActive(display=self.display, opcode=self.display.get_extension_major(extname), ) return r.state # QueryScreens is only available from Xinerama 1.1 and later class QueryScreens(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card32('number'), rq.Pad(20), rq.List('screens', structs.Rectangle), ) def query_screens(self): # Hmm. This one needs to read the screen data from the socket. Ooops... return QueryScreens(display=self.display, opcode=self.display.get_extension_major(extname), ) # GetInfo is only available from some Xinerama 1.0, and *NOT* later! Untested class GetInfo(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Card32('visual'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Window('window'), # An array of subwindow slots goes here. Bah. ) def get_info(self, visual): r = GetInfo(display=self.display, opcode=self.display.get_extension_major(extname), visual=visual) def init(disp, info): disp.extension_add_method('display', 'xinerama_query_version', query_version) disp.extension_add_method('window', 'xinerama_get_state', get_state) disp.extension_add_method('window', 'xinerama_get_screen_count', get_screen_count) disp.extension_add_method('window', 'xinerama_get_screen_size', get_screen_size) disp.extension_add_method('display', 'xinerama_is_active', is_active) disp.extension_add_method('display', 'xinerama_query_screens', query_screens) disp.extension_add_method('display', 'xinerama_get_info', get_info) python-xlib-0.14+20091101/Xlib/ext/shape.py0000644000175000017500000002434510633003257016511 0ustar stewstew# Xlib.ext.shape -- SHAPE extension module # # Copyright (C) 2002 Jeffrey Boser # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Constants to use # # Regions of a window ShapeBounding = 0 # the 'edge' of a shaped window ShapeClip = 1 # the clipping region # Shape Operations ShapeSet = 0 # Set the region unmodified (dest=src) ShapeUnion = 1 # Add the new region to the old (dest=src|dest) ShapeIntersect = 2 # Use the intersection (dest=src&dest) ShapeSubtract = 3 # remove region (dest = dest - intersect) ShapeInvert = 4 # opposite of subtract (dest = src - intersect) # Events ShapeNotifyMask = (1<<0) #a keypress mask? ShapeNotify = 0 #still unsure of these values # How to Use # The basic functions that change the shapes of things are: # shape_rectangles (uses a set of rectangles as the source) # operation, region, ordering, rects # shape_mask (uses a bitmap as the source) # operation, region, x_offset, y_offset, bitmap # shape_combine (uses a window as the source) # operation, src_region, dest_region, x_offset, y_offset, src_window # shape_offset (moves the region) # region, x_offset, y_offset # The functions to find stuff out (these three return mappings of field/values): # shape_query_version (shape extension version) # major_version, minor_version # shape_query_extents (rectangle boundaries of a window's regions) # clip_shaped, clip_x, clip_y, clip_width, clip_height, # bounding_shaped, bounding_x, bounding_y, bounding_width, bounding_height # shape_input_selected (if the window products shapenotify events) # enabled # shape_get_rectangles (the rectangles set by shape_rectangles) # ordering, rects # And to turn on shape notify events: # shape_select_input # enable from Xlib import X from Xlib.protocol import rq, structs extname = 'SHAPE' class QueryVersion(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(0), rq.RequestLength(), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Card16('major_version'), rq.Card16('minor_version'), rq.Pad(20), ) def query_version(self): return QueryVersion( display = self.display, opcode = self.display.get_extension_major(extname), ) class Rectangles(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(1), rq.RequestLength(), rq.Card8('operation'), rq.Set('region', 1, (ShapeBounding, ShapeClip)), rq.Card8('ordering'), rq.Pad(1), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.List('rectangles', structs.Rectangle), ) def rectangles(self, region, operation, ordering, x, y, rectangles): Rectangles( display = self.display, opcode = self.display.get_extension_major(extname), operation = operation, region = region, ordering = ordering, window = self.id, x = x, y = y, rectangles = rectangles, ) class Mask(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(2), rq.RequestLength(), rq.Card8('operation'), rq.Set('region', 1, (ShapeBounding, ShapeClip)), rq.Pad(2), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Pixmap('source', (X.NONE, )), ) def mask(self, operation, region, x, y, source): Mask(display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, operation = operation, region = region, x = x, y = y, source = source, ) class Combine(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(3), rq.RequestLength(), rq.Card8('operation'), rq.Set('dest_region', 1, (ShapeBounding, ShapeClip)), rq.Set('source_region', 1, (ShapeBounding, ShapeClip)), rq.Pad(1), rq.Window('dest'), rq.Int16('x'), rq.Int16('y'), rq.Window('source'), ) def combine(self, operation, region, source, source_region, x, y): Combine( display = self.display, opcode = self.display.get_extension_major(extname), operation = operation, dest_region = region, source_region = source_region, dest = self.id, x = x, y = y, source = source, ) class Offset(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(4), rq.RequestLength(), rq.Set('region', 1, (ShapeBounding, ShapeClip)), rq.Pad(3), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), ) def offset(self, region, x, y): Offset( display = self.display, opcode = self.display.get_extension_major(extname), region = region, window = self.id, x = x, y = y, ) class QueryExtents(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(5), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Pad(1), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Bool('bounding_shaped'), rq.Bool('clip_shaped'), rq.Pad(2), rq.Int16('bounding_x'), rq.Int16('bounding_y'), rq.Card16('bounding_width'), rq.Card16('bounding_height'), rq.Int16('clip_x'), rq.Int16('clip_y'), rq.Card16('clip_width'), rq.Card16('clip_height'), rq.Pad(4), ) def query_extents(self): return QueryExtents( display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, ) class SelectInput(rq.Request): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(6), rq.RequestLength(), rq.Window('window'), rq.Bool('enable'), rq.Pad(3), ) def select_input(self, enable = 1): SelectInput( display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, enable = enable, ) class InputSelected(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(7), rq.RequestLength(), rq.Window('window'), ) _reply = rq.Struct( rq.ReplyCode(), rq.Bool('enabled'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.Pad(24), ) def input_selected(self): reply = InputSelected( display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, ) return reply.enabled class GetRectangles(rq.ReplyRequest): _request = rq.Struct( rq.Card8('opcode'), rq.Opcode(8), rq.RequestLength(), rq.Window('window'), rq.Set('region', 1, (ShapeBounding, ShapeClip)), rq.Pad(3), ) _reply = rq.Struct( rq.ReplyCode(), rq.Card8('ordering'), rq.Card16('sequence_number'), rq.ReplyLength(), rq.LengthOf('rectangles', 4), rq.Pad(20), rq.List('rectangles', structs.Rectangle), ) def get_rectangles(self, region): return GetRectangles( display = self.display, opcode = self.display.get_extension_major(extname), window = self.id, region = region, ) class ShapeNotify(rq.Event): _code = None _fields = rq.Struct( rq.Card8('type'), rq.Set('region', 1, (ShapeBounding, ShapeClip)), rq.Card16('sequence_number'), rq.Window('window'), rq.Int16('x'), rq.Int16('y'), rq.Card16('width'), rq.Card16('height'), rq.Card32('time'), rq.Bool('shaped'), rq.Pad(11), ) def init(disp, info): disp.extension_add_method('display', 'shape_query_version', query_version ) disp.extension_add_method('window', 'shape_rectangles', rectangles ) disp.extension_add_method('window', 'shape_mask', mask ) disp.extension_add_method('window', 'shape_combine', combine ) disp.extension_add_method('window', 'shape_offset', offset ) disp.extension_add_method('window', 'shape_query_extents', query_extents ) disp.extension_add_method('window', 'shape_select_input', select_input ) disp.extension_add_method('window', 'shape_input_selected', input_selected ) disp.extension_add_method('window', 'shape_get_rectangles', get_rectangles ) disp.extension_add_event(info.first_event, ShapeNotify) python-xlib-0.14+20091101/Xlib/ext/__init__.py0000644000175000017500000000234611211313074017137 0ustar stewstew# Xlib.ext.__init__ -- X extension modules # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # __extensions__ is a list of tuples: (extname, extmod) # extname is the name of the extension according to the X # protocol. extmod is the name of the module in this package. __extensions__ = [ ('XTEST', 'xtest'), ('SHAPE', 'shape'), ('XINERAMA', 'xinerama'), ('RECORD', 'record'), ('Composite', 'composite'), ('RANDR', 'randr'), ] __all__ = map(lambda x: x[1], __extensions__) python-xlib-0.14+20091101/Xlib/threaded.py0000644000175000017500000000206210770020473016362 0ustar stewstew# Xlib.threaded -- Import this module to enable threading # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import thread # We change the allocate_lock function in Xlib.support.lock to # return a basic Python lock, instead of the default dummy lock from Xlib.support import lock lock.allocate_lock = thread.allocate_lock python-xlib-0.14+20091101/Xlib/Xatom.py0000644000175000017500000000364010770020473015675 0ustar stewstew# Xlib.Xatom -- Standard X atoms # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA PRIMARY = 1 SECONDARY = 2 ARC = 3 ATOM = 4 BITMAP = 5 CARDINAL = 6 COLORMAP = 7 CURSOR = 8 CUT_BUFFER0 = 9 CUT_BUFFER1 = 10 CUT_BUFFER2 = 11 CUT_BUFFER3 = 12 CUT_BUFFER4 = 13 CUT_BUFFER5 = 14 CUT_BUFFER6 = 15 CUT_BUFFER7 = 16 DRAWABLE = 17 FONT = 18 INTEGER = 19 PIXMAP = 20 POINT = 21 RECTANGLE = 22 RESOURCE_MANAGER = 23 RGB_COLOR_MAP = 24 RGB_BEST_MAP = 25 RGB_BLUE_MAP = 26 RGB_DEFAULT_MAP = 27 RGB_GRAY_MAP = 28 RGB_GREEN_MAP = 29 RGB_RED_MAP = 30 STRING = 31 VISUALID = 32 WINDOW = 33 WM_COMMAND = 34 WM_HINTS = 35 WM_CLIENT_MACHINE = 36 WM_ICON_NAME = 37 WM_ICON_SIZE = 38 WM_NAME = 39 WM_NORMAL_HINTS = 40 WM_SIZE_HINTS = 41 WM_ZOOM_HINTS = 42 MIN_SPACE = 43 NORM_SPACE = 44 MAX_SPACE = 45 END_SPACE = 46 SUPERSCRIPT_X = 47 SUPERSCRIPT_Y = 48 SUBSCRIPT_X = 49 SUBSCRIPT_Y = 50 UNDERLINE_POSITION = 51 UNDERLINE_THICKNESS = 52 STRIKEOUT_ASCENT = 53 STRIKEOUT_DESCENT = 54 ITALIC_ANGLE = 55 X_HEIGHT = 56 QUAD_WIDTH = 57 WEIGHT = 58 POINT_SIZE = 59 RESOLUTION = 60 COPYRIGHT = 61 NOTICE = 62 FONT_NAME = 63 FAMILY_NAME = 64 FULL_NAME = 65 CAP_HEIGHT = 66 WM_CLASS = 67 WM_TRANSIENT_FOR = 68 LAST_PREDEFINED = 68 python-xlib-0.14+20091101/Xlib/X.py0000644000175000017500000002374110770020473015020 0ustar stewstew# Xlib.X -- basic X constants # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Avoid overwriting None if doing "from Xlib.X import *" NONE = 0 ParentRelative = 1 # background pixmap in CreateWindow # and ChangeWindowAttributes CopyFromParent = 0 # border pixmap in CreateWindow # and ChangeWindowAttributes # special VisualID and special window # class passed to CreateWindow PointerWindow = 0 # destination window in SendEvent InputFocus = 1 # destination window in SendEvent PointerRoot = 1 # focus window in SetInputFocus AnyPropertyType = 0 # special Atom, passed to GetProperty AnyKey = 0 # special Key Code, passed to GrabKey AnyButton = 0 # special Button Code, passed to GrabButton AllTemporary = 0 # special Resource ID passed to KillClient CurrentTime = 0 # special Time NoSymbol = 0 # special KeySym #----------------------------------------------------------------------- # Event masks: # NoEventMask = 0 KeyPressMask = (1<<0) KeyReleaseMask = (1<<1) ButtonPressMask = (1<<2) ButtonReleaseMask = (1<<3) EnterWindowMask = (1<<4) LeaveWindowMask = (1<<5) PointerMotionMask = (1<<6) PointerMotionHintMask = (1<<7) Button1MotionMask = (1<<8) Button2MotionMask = (1<<9) Button3MotionMask = (1<<10) Button4MotionMask = (1<<11) Button5MotionMask = (1<<12) ButtonMotionMask = (1<<13) KeymapStateMask = (1<<14) ExposureMask = (1<<15) VisibilityChangeMask = (1<<16) StructureNotifyMask = (1<<17) ResizeRedirectMask = (1<<18) SubstructureNotifyMask = (1<<19) SubstructureRedirectMask = (1<<20) FocusChangeMask = (1<<21) PropertyChangeMask = (1<<22) ColormapChangeMask = (1<<23) OwnerGrabButtonMask = (1<<24) #----------------------------------------------------------------------- # Event names: # # Used in "type" field in XEvent structures. Not to be confused with event # masks above. They start from 2 because 0 and 1 are reserved in the # protocol for errors and replies. # KeyPress = 2 KeyRelease = 3 ButtonPress = 4 ButtonRelease = 5 MotionNotify = 6 EnterNotify = 7 LeaveNotify = 8 FocusIn = 9 FocusOut = 10 KeymapNotify = 11 Expose = 12 GraphicsExpose = 13 NoExpose = 14 VisibilityNotify = 15 CreateNotify = 16 DestroyNotify = 17 UnmapNotify = 18 MapNotify = 19 MapRequest = 20 ReparentNotify = 21 ConfigureNotify = 22 ConfigureRequest = 23 GravityNotify = 24 ResizeRequest = 25 CirculateNotify = 26 CirculateRequest = 27 PropertyNotify = 28 SelectionClear = 29 SelectionRequest = 30 SelectionNotify = 31 ColormapNotify = 32 ClientMessage = 33 MappingNotify = 34 LASTEvent = 35 # must be bigger than any event #----------------------------------------------------------------------- # Key masks: # # Used as modifiers to GrabButton and GrabKey, results of QueryPointer, # state in various key-, mouse-, and button-related events. # ShiftMask = (1<<0) LockMask = (1<<1) ControlMask = (1<<2) Mod1Mask = (1<<3) Mod2Mask = (1<<4) Mod3Mask = (1<<5) Mod4Mask = (1<<6) Mod5Mask = (1<<7) #----------------------------------------------------------------------- # Modifier names: # # Used to build a SetModifierMapping request or to read a # GetModifierMapping request. These correspond to the masks defined above. # ShiftMapIndex = 0 LockMapIndex = 1 ControlMapIndex = 2 Mod1MapIndex = 3 Mod2MapIndex = 4 Mod3MapIndex = 5 Mod4MapIndex = 6 Mod5MapIndex = 7 #----------------------------------------------------------------------- # Button masks: # # Used in same manner as Key masks above. Not to be confused with button # names below. Note that 0 is already defined above as "AnyButton". # Button1Mask = (1<<8) Button2Mask = (1<<9) Button3Mask = (1<<10) Button4Mask = (1<<11) Button5Mask = (1<<12) AnyModifier = (1<<15) # used in GrabButton, GrabKey #----------------------------------------------------------------------- # Button names: # # Used as arguments to GrabButton and as detail in ButtonPress and # ButtonRelease events. Not to be confused with button masks above. # Note that 0 is already defined above as "AnyButton". # Button1 = 1 Button2 = 2 Button3 = 3 Button4 = 4 Button5 = 5 #----------------------------------------------------------------------- # XXX These still need documentation -- for now, read # NotifyNormal = 0 NotifyGrab = 1 NotifyUngrab = 2 NotifyWhileGrabbed = 3 NotifyHint = 1 NotifyAncestor = 0 NotifyVirtual = 1 NotifyInferior = 2 NotifyNonlinear = 3 NotifyNonlinearVirtual = 4 NotifyPointer = 5 NotifyPointerRoot = 6 NotifyDetailNone = 7 VisibilityUnobscured = 0 VisibilityPartiallyObscured = 1 VisibilityFullyObscured = 2 PlaceOnTop = 0 PlaceOnBottom = 1 FamilyInternet = 0 FamilyDECnet = 1 FamilyChaos = 2 PropertyNewValue = 0 PropertyDelete = 1 ColormapUninstalled = 0 ColormapInstalled = 1 GrabModeSync = 0 GrabModeAsync = 1 GrabSuccess = 0 AlreadyGrabbed = 1 GrabInvalidTime = 2 GrabNotViewable = 3 GrabFrozen = 4 AsyncPointer = 0 SyncPointer = 1 ReplayPointer = 2 AsyncKeyboard = 3 SyncKeyboard = 4 ReplayKeyboard = 5 AsyncBoth = 6 SyncBoth = 7 RevertToNone = 0 RevertToPointerRoot = PointerRoot RevertToParent = 2 Success = 0 BadRequest = 1 BadValue = 2 BadWindow = 3 BadPixmap = 4 BadAtom = 5 BadCursor = 6 BadFont = 7 BadMatch = 8 BadDrawable = 9 BadAccess = 10 BadAlloc = 11 BadColor = 12 BadGC = 13 BadIDChoice = 14 BadName = 15 BadLength = 16 BadImplementation = 17 FirstExtensionError = 128 LastExtensionError = 255 InputOutput = 1 InputOnly = 2 CWBackPixmap = (1<<0) CWBackPixel = (1<<1) CWBorderPixmap = (1<<2) CWBorderPixel = (1<<3) CWBitGravity = (1<<4) CWWinGravity = (1<<5) CWBackingStore = (1<<6) CWBackingPlanes = (1<<7) CWBackingPixel = (1<<8) CWOverrideRedirect = (1<<9) CWSaveUnder = (1<<10) CWEventMask = (1<<11) CWDontPropagate = (1<<12) CWColormap = (1<<13) CWCursor = (1<<14) CWX = (1<<0) CWY = (1<<1) CWWidth = (1<<2) CWHeight = (1<<3) CWBorderWidth = (1<<4) CWSibling = (1<<5) CWStackMode = (1<<6) ForgetGravity = 0 NorthWestGravity = 1 NorthGravity = 2 NorthEastGravity = 3 WestGravity = 4 CenterGravity = 5 EastGravity = 6 SouthWestGravity = 7 SouthGravity = 8 SouthEastGravity = 9 StaticGravity = 10 UnmapGravity = 0 NotUseful = 0 WhenMapped = 1 Always = 2 IsUnmapped = 0 IsUnviewable = 1 IsViewable = 2 SetModeInsert = 0 SetModeDelete = 1 DestroyAll = 0 RetainPermanent = 1 RetainTemporary = 2 Above = 0 Below = 1 TopIf = 2 BottomIf = 3 Opposite = 4 RaiseLowest = 0 LowerHighest = 1 PropModeReplace = 0 PropModePrepend = 1 PropModeAppend = 2 GXclear = 0x0 GXand = 0x1 GXandReverse = 0x2 GXcopy = 0x3 GXandInverted = 0x4 GXnoop = 0x5 GXxor = 0x6 GXor = 0x7 GXnor = 0x8 GXequiv = 0x9 GXinvert = 0xa GXorReverse = 0xb GXcopyInverted = 0xc GXorInverted = 0xd GXnand = 0xe GXset = 0xf LineSolid = 0 LineOnOffDash = 1 LineDoubleDash = 2 CapNotLast = 0 CapButt = 1 CapRound = 2 CapProjecting = 3 JoinMiter = 0 JoinRound = 1 JoinBevel = 2 FillSolid = 0 FillTiled = 1 FillStippled = 2 FillOpaqueStippled = 3 EvenOddRule = 0 WindingRule = 1 ClipByChildren = 0 IncludeInferiors = 1 Unsorted = 0 YSorted = 1 YXSorted = 2 YXBanded = 3 CoordModeOrigin = 0 CoordModePrevious = 1 Complex = 0 Nonconvex = 1 Convex = 2 ArcChord = 0 ArcPieSlice = 1 GCFunction = (1<<0) GCPlaneMask = (1<<1) GCForeground = (1<<2) GCBackground = (1<<3) GCLineWidth = (1<<4) GCLineStyle = (1<<5) GCCapStyle = (1<<6) GCJoinStyle = (1<<7) GCFillStyle = (1<<8) GCFillRule = (1<<9) GCTile = (1<<10) GCStipple = (1<<11) GCTileStipXOrigin = (1<<12) GCTileStipYOrigin = (1<<13) GCFont = (1<<14) GCSubwindowMode = (1<<15) GCGraphicsExposures = (1<<16) GCClipXOrigin = (1<<17) GCClipYOrigin = (1<<18) GCClipMask = (1<<19) GCDashOffset = (1<<20) GCDashList = (1<<21) GCArcMode = (1<<22) GCLastBit = 22 FontLeftToRight = 0 FontRightToLeft = 1 FontChange = 255 XYBitmap = 0 XYPixmap = 1 ZPixmap = 2 AllocNone = 0 AllocAll = 1 DoRed = (1<<0) DoGreen = (1<<1) DoBlue = (1<<2) CursorShape = 0 TileShape = 1 StippleShape = 2 AutoRepeatModeOff = 0 AutoRepeatModeOn = 1 AutoRepeatModeDefault = 2 LedModeOff = 0 LedModeOn = 1 KBKeyClickPercent = (1<<0) KBBellPercent = (1<<1) KBBellPitch = (1<<2) KBBellDuration = (1<<3) KBLed = (1<<4) KBLedMode = (1<<5) KBKey = (1<<6) KBAutoRepeatMode = (1<<7) MappingSuccess = 0 MappingBusy = 1 MappingFailed = 2 MappingModifier = 0 MappingKeyboard = 1 MappingPointer = 2 DontPreferBlanking = 0 PreferBlanking = 1 DefaultBlanking = 2 DisableScreenSaver = 0 DisableScreenInterval = 0 DontAllowExposures = 0 AllowExposures = 1 DefaultExposures = 2 ScreenSaverReset = 0 ScreenSaverActive = 1 HostInsert = 0 HostDelete = 1 EnableAccess = 1 DisableAccess = 0 StaticGray = 0 GrayScale = 1 StaticColor = 2 PseudoColor = 3 TrueColor = 4 DirectColor = 5 LSBFirst = 0 MSBFirst = 1 python-xlib-0.14+20091101/Xlib/XK.py0000644000175000017500000000620010770020473015122 0ustar stewstew# Xlib.XK -- X keysym defs # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # This module defines some functions for working with X keysyms as well # as a modular keysym definition and loading mechanism. See the keysym # definition modules in the Xlib/keysymdef directory. from X import NoSymbol def string_to_keysym(keysym): '''Return the (16 bit) numeric code of keysym. Given the name of a keysym as a string, return its numeric code. Don't include the 'XK_' prefix, just use the base, i.e. 'Delete' instead of 'XK_Delete'.''' return globals().get('XK_' + keysym, NoSymbol) def load_keysym_group(group): '''Load all the keysyms in group. Given a group name such as 'latin1' or 'katakana' load the keysyms defined in module 'Xlib.keysymdef.group-name' into this XK module.''' if '.' in group: raise ValueError('invalid keysym group name: %s' % group) G = globals() #Get a reference to XK.__dict__ a.k.a. globals #Import just the keysyms module. mod = __import__('Xlib.keysymdef.%s' % group, G, locals(), [group]) #Extract names of just the keysyms. keysyms = [n for n in dir(mod) if n.startswith('XK_')] #Copy the named keysyms into XK.__dict__ for keysym in keysyms: ## k = mod.__dict__[keysym]; assert k == int(k) #probably too much. G[keysym] = mod.__dict__[keysym] #And get rid of the keysym module. del mod def _load_keysyms_into_XK(mod): '''keysym definition modules need no longer call Xlib.XK._load_keysyms_into_XK(). You should remove any calls to that function from your keysym modules.''' pass # Always import miscellany and latin1 keysyms load_keysym_group('miscellany') load_keysym_group('latin1') def keysym_to_string(keysym): '''Translate a keysym (16 bit number) into a python string. This will pass 0 to 0xff as well as XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete. For other values it returns None.''' # ISO latin 1, LSB is the code if keysym & 0xff00 == 0: return chr(keysym & 0xff) if keysym in [XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete]: return chr(keysym & 0xff) # We should be able to do these things quite automatically # for latin2, latin3, etc, in Python 2.0 using the Unicode, # but that will have to wait. return None python-xlib-0.14+20091101/Xlib/Xcursorfont.py0000644000175000017500000000375010770020473017143 0ustar stewstew# Xlib.Xcursorfont -- standard cursors # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA num_glyphs = 154 X_cursor = 0 arrow = 2 based_arrow_down = 4 based_arrow_up = 6 boat = 8 bogosity = 10 bottom_left_corner = 12 bottom_right_corner = 14 bottom_side = 16 bottom_tee = 18 box_spiral = 20 center_ptr = 22 circle = 24 clock = 26 coffee_mug = 28 cross = 30 cross_reverse = 32 crosshair = 34 diamond_cross = 36 dot = 38 dotbox = 40 double_arrow = 42 draft_large = 44 draft_small = 46 draped_box = 48 exchange = 50 fleur = 52 gobbler = 54 gumby = 56 hand1 = 58 hand2 = 60 heart = 62 icon = 64 iron_cross = 66 left_ptr = 68 left_side = 70 left_tee = 72 leftbutton = 74 ll_angle = 76 lr_angle = 78 man = 80 middlebutton = 82 mouse = 84 pencil = 86 pirate = 88 plus = 90 question_arrow = 92 right_ptr = 94 right_side = 96 right_tee = 98 rightbutton = 100 rtl_logo = 102 sailboat = 104 sb_down_arrow = 106 sb_h_double_arrow = 108 sb_left_arrow = 110 sb_right_arrow = 112 sb_up_arrow = 114 sb_v_double_arrow = 116 shuttle = 118 sizing = 120 spider = 122 spraycan = 124 star = 126 target = 128 tcross = 130 top_left_arrow = 132 top_left_corner = 134 top_right_corner = 136 top_side = 138 top_tee = 140 trek = 142 ul_angle = 144 umbrella = 146 ur_angle = 148 watch = 150 xterm = 152 python-xlib-0.14+20091101/Xlib/ChangeLog0000644000175000017500000001012210633004320015765 0ustar stewstew2007-06-10 Mike Grant * (many files): (mgg) Converted tabs to spaces throughout the codebase, using reindent.py (SF id: 1559082) 2007-03-18 Mike Grant * Xlib/display.py: (mgg) Added a get_atom alias that uses the internal cache * Xlib/xobject/drawable.py: (mgg) Added a raise_window() alias to the Window class 2007-02-15 Mike Grant * Xlib/xauth.py: (mgg) Python 2.5 didn't like the way the buffer type was used, resulting in X authorisation failure, so reverted to using slices 2006-11-22 Mike Grant * Xlib/ext/record.py: Addition of RECORD extension by Alex Badea , SF patch id #1538663 (demo program in python-xlib/examples/record_demo.py) 2006-09-20 Mike Meyer * Xlib/ext/xinerama.py: (mwm) Addition of Xinerama extension 2006-07-22 Mike Grant Various typo fixes, general updates. Changelog hasn't been maintained since 2002, but some of the more significant comments from cvs logs follow: * Xlib/display.py: (petli) Fix bug in refresh_keyboard_mapping: ignore modifier and pointer remappings. Plays nice with pydoc. Copied some text from the docs to __doc__ strings in Xlib/display.py so that they appear when you use pydoc. Completed documentation for Display objects. * Xlib/XK.py: (calroc99) Minor doc string changes. Called load_keysym_group() for miscellany and latin1 keysyms, rather than importing the modules. * Xlib/keysymdef/*: (calroc99) Small change to keysym loading. Works the same way. * Xlib/support/*, Xlib/xauth.py, Xlib/error.py: (petli) Added ~/.Xauthority parsing by Python code instead of relying on /usr/X11R6/bin/xauth. Not activated yet in all cases yet? Activated in unix_support.py. * Xlib/xobject/drawable.py: (petli) Fix bugs in definition and method of GrabButton/Pointer * Xlib/xobject/icccm.py: (petli) Add WithdrawnState to WMHints * doc/*: (petli) documentation updates, typos and completing documentation for Display objects 2002-03-30 Peter Liljenberg * support/unix_connect.py: Handle fcntl/FCNTL changes in Python 2.2. 2002-03-11 Peter Liljenberg * xobject/drawable.py (Drawable.fill_arc): This should be a PolyFillArc. Fri Jan 19 17:49:45 2001 Peter Liljenberg * XK.py: Moved all keysyms into separate modules, based on their category. By default only the miscellany and latin1 keysyms are loaded, and other have to be loaded by importing the Xlib.keysymdef. module, or calling load_keysym_group('category'). * display.py (Display.lookup_string): (Display.rebind_string): Functions to translate keysyms to strings, and binding keysyms to new strings. 2001-01-16 * xobject/drawable.py (Window.send_event): * display.py (Display.send_event): Changed the order of the event_mask and propagate arguments. 2001-01-10 * display.py (Display._update_keymap): The first half of the update algorithm operated on an earlier type of code->sym map than the second half. Stupid, stupid. It would have been nice with a type-checker now. Tue Jan 9 13:03:19 2001 Peter Liljenberg * display.py (Display._update_keymap): Fixed call to append with 1.5.2 semantics, broke in newer Pythons. 2000-12-22 * display.py (Display.keycode_to_keysym): (Display.keysym_to_keycode): (Display.keysym_to_keycodes): (Display.refresh_keyboard_mapping): (Display._update_keymap): Added keymap cache implementation. 2000-12-21 * xobject/colormap.py (Colormap.alloc_named_color): Extended to handle #000000 style color specifications. * xobject/drawable.py (Window.reparent): Renamed from reparent_window. * display.py (Display.set_error_handler): Added. 2000-12-20 * display.py (_BaseDisplay): Implement a cache of atom names. python-xlib-0.14+20091101/Xlib/support/0000755000175000017500000000000011273361453015751 5ustar stewstewpython-xlib-0.14+20091101/Xlib/support/lock.py0000644000175000017500000000277610770020473017262 0ustar stewstew# Xlib.support.lock -- allocate a lock # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class _DummyLock: def __init__(self): # This might be nerdy, but by assigning methods like this # instead of defining them all, we create a single bound # method object once instead of one each time one of the # methods is called. # This gives some speed improvements which should reduce the # impact of the threading infrastructure in the regular code, # when not using threading. self.acquire = self.release = self.locked = self.__noop def __noop(self, *args): return # More optimisations: we use a single lock for all lock instances _dummy_lock = _DummyLock() def allocate_lock(): return _dummy_lock python-xlib-0.14+20091101/Xlib/support/connect.py0000644000175000017500000000544310770020473017755 0ustar stewstew# Xlib.support.connect -- OS-independent display connection functions # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import string # List the modules which contain the corresponding functions _display_mods = { 'OpenVMS': 'vms_connect', } _default_display_mod = 'unix_connect' _socket_mods = { 'OpenVMS': 'vms_connect' } _default_socket_mod = 'unix_connect' _auth_mods = { 'OpenVMS': 'vms_connect' } _default_auth_mod = 'unix_connect' # Figure out which OS we're using. # sys.platform is either "OS-ARCH" or just "OS". _parts = string.split(sys.platform, '-') platform = _parts[0] del _parts def get_display(display): """dname, host, dno, screen = get_display(display) Parse DISPLAY into its components. If DISPLAY is None, use the default display. The return values are: DNAME -- the full display name (string) HOST -- the host name (string, possibly empty) DNO -- display number (integer) SCREEN -- default screen number (integer) """ modname = _display_mods.get(platform, _default_display_mod) mod = __import__(modname, globals()) return mod.get_display(display) def get_socket(dname, host, dno): """socket = get_socket(dname, host, dno) Connect to the display specified by DNAME, HOST and DNO, which are the corresponding values from a previous call to get_display(). Return SOCKET, a new socket object connected to the X server. """ modname = _socket_mods.get(platform, _default_socket_mod) mod = __import__(modname, globals()) return mod.get_socket(dname, host, dno) def get_auth(sock, dname, host, dno): """auth_name, auth_data = get_auth(sock, dname, host, dno) Return authentication data for the display on the other side of SOCK, which was opened with DNAME, HOST and DNO. Return AUTH_NAME and AUTH_DATA, two strings to be used in the connection setup request. """ modname = _auth_mods.get(platform, _default_auth_mod) mod = __import__(modname, globals()) return mod.get_auth(sock, dname, host, dno) python-xlib-0.14+20091101/Xlib/support/vms_connect.py0000644000175000017500000000401210770020473020631 0ustar stewstew# Xlib.support.vms_connect -- VMS-type display connection functions # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import re import socket from Xlib import error display_re = re.compile(r'^([-a-zA-Z0-9._]*):([0-9]+)(\.([0-9]+))?$') def get_display(display): # Use dummy display if none is set. We really should # check DECW$DISPLAY instead, but that has to wait if display is None: return ':0.0', 'localhost', 0, 0 m = display_re.match(display) if not m: raise error.DisplayNameError(display) name = display # Always return a host, since we don't have AF_UNIX sockets host = m.group(1) if not host: host = 'localhost' dno = int(m.group(2)) screen = m.group(4) if screen: screen = int(screen) else: screen = 0 return name, host, dno, screen def get_socket(dname, host, dno): try: # Always use TCP/IP sockets. Later it would be nice to # be able to use DECNET och LOCAL connections. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 6000 + dno)) except socket.error, val: raise error.DisplayConnectionError(dname, str(val)) return s def get_auth(sock, dname, host, dno): # VMS doesn't have xauth return '', '' python-xlib-0.14+20091101/Xlib/support/unix_connect.py0000644000175000017500000001176311041647520021022 0ustar stewstew# Xlib.support.unix_connect -- Unix-type display connection functions # # Copyright (C) 2000,2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import re import string import os import platform import socket # FCNTL is deprecated from Python 2.2, so only import it if we doesn't # get the names we need. Furthermore, FD_CLOEXEC seems to be missing # in Python 2.2. import fcntl if hasattr(fcntl, 'F_SETFD'): F_SETFD = fcntl.F_SETFD if hasattr(fcntl, 'FD_CLOEXEC'): FD_CLOEXEC = fcntl.FD_CLOEXEC else: FD_CLOEXEC = 1 else: from FCNTL import F_SETFD, FD_CLOEXEC from Xlib import error, xauth uname = platform.uname() if (uname[0] == 'Darwin') and ([int(x) for x in uname[2].split('.')] >= [9, 0]): display_re = re.compile(r'^([-a-zA-Z0-9._/]*):([0-9]+)(\.([0-9]+))?$') else: display_re = re.compile(r'^([-a-zA-Z0-9._]*):([0-9]+)(\.([0-9]+))?$') def get_display(display): # Use $DISPLAY if display isn't provided if display is None: display = os.environ.get('DISPLAY', '') m = display_re.match(display) if not m: raise error.DisplayNameError(display) name = display host = m.group(1) dno = int(m.group(2)) screen = m.group(4) if screen: screen = int(screen) else: screen = 0 return name, host, dno, screen def get_socket(dname, host, dno): try: # Darwin funky socket if (uname[0] == 'Darwin') and host and host.startswith('/tmp/'): s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(dname) # If hostname (or IP) is provided, use TCP socket elif host: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, 6000 + dno)) # Else use Unix socket else: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect('/tmp/.X11-unix/X%d' % dno) except socket.error, val: raise error.DisplayConnectionError(dname, str(val)) # Make sure that the connection isn't inherited in child processes fcntl.fcntl(s.fileno(), F_SETFD, FD_CLOEXEC) return s def new_get_auth(sock, dname, host, dno): # Translate socket address into the xauth domain if (uname[0] == 'Darwin') and host and host.startswith('/tmp/'): family = xauth.FamilyLocal addr = socket.gethostname() elif host: family = xauth.FamilyInternet # Convert the prettyprinted IP number into 4-octet string. # Sometimes these modules are too damn smart... octets = string.split(sock.getpeername()[0], '.') addr = string.join(map(lambda x: chr(int(x)), octets), '') else: family = xauth.FamilyLocal addr = socket.gethostname() au = xauth.Xauthority() while 1: try: return au.get_best_auth(family, addr, dno) except error.XNoAuthError: pass # We need to do this to handle ssh's X forwarding. It sets # $DISPLAY to localhost:10, but stores the xauth cookie as if # DISPLAY was :10. Hence, if localhost and not found, try # again as a Unix socket. if family == xauth.FamilyInternet and addr == '\x7f\x00\x00\x01': family = xauth.FamilyLocal addr = socket.gethostname() else: return '', '' def old_get_auth(sock, dname, host, dno): # Find authorization cookie auth_name = auth_data = '' try: # We could parse .Xauthority, but xauth is simpler # although more inefficient data = os.popen('xauth list %s 2>/dev/null' % dname).read() # If there's a cookie, it is of the format # DISPLAY SCHEME COOKIE # We're interested in the two last parts for the # connection establishment lines = string.split(data, '\n') if len(lines) >= 1: parts = string.split(lines[0], None, 2) if len(parts) == 3: auth_name = parts[1] hexauth = parts[2] auth = '' # Translate hexcode into binary for i in range(0, len(hexauth), 2): auth = auth + chr(string.atoi(hexauth[i:i+2], 16)) auth_data = auth except os.error: pass return auth_name, auth_data get_auth = new_get_auth python-xlib-0.14+20091101/Xlib/support/__init__.py0000644000175000017500000000167310770020473020064 0ustar stewstew# Xlib.support.__init__ -- support code package # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __all__ = [ 'lock', 'connect' # The platform specific modules should not be listed here ] python-xlib-0.14+20091101/Xlib/Xutil.py0000644000175000017500000000424411212302303015676 0ustar stewstew# Xlib.Xutil -- ICCCM definitions and similar stuff # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA NoValue = 0x0000 XValue = 0x0001 YValue = 0x0002 WidthValue = 0x0004 HeightValue = 0x0008 AllValues = 0x000F XNegative = 0x0010 YNegative = 0x0020 USPosition = (1 << 0) USSize = (1 << 1) PPosition = (1 << 2) PSize = (1 << 3) PMinSize = (1 << 4) PMaxSize = (1 << 5) PResizeInc = (1 << 6) PAspect = (1 << 7) PBaseSize = (1 << 8) PWinGravity = (1 << 9) PAllHints = (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect) InputHint = (1 << 0) StateHint = (1 << 1) IconPixmapHint = (1 << 2) IconWindowHint = (1 << 3) IconPositionHint = (1 << 4) IconMaskHint = (1 << 5) WindowGroupHint = (1 << 6) MessageHint = (1 << 7) UrgencyHint = (1 << 8) AllHints = (InputHint|StateHint|IconPixmapHint|IconWindowHint| IconPositionHint|IconMaskHint|WindowGroupHint|MessageHint| UrgencyHint) WithdrawnState = 0 NormalState = 1 IconicState = 3 DontCareState = 0 ZoomState = 2 InactiveState = 4 RectangleOut = 0 RectangleIn = 1 RectanglePart = 2 VisualNoMask = 0x0 VisualIDMask = 0x1 VisualScreenMask = 0x2 VisualDepthMask = 0x4 VisualClassMask = 0x8 VisualRedMaskMask = 0x10 VisualGreenMaskMask = 0x20 VisualBlueMaskMask = 0x40 VisualColormapSizeMask = 0x80 VisualBitsPerRGBMask = 0x100 VisualAllMask = 0x1FF ReleaseByFreeingColormap = 1 BitmapSuccess = 0 BitmapOpenFailed = 1 BitmapFileInvalid = 2 BitmapNoMemory = 3 XCSUCCESS = 0 XCNOMEM = 1 XCNOENT = 2 python-xlib-0.14+20091101/Xlib/xobject/0000755000175000017500000000000011273361453015673 5ustar stewstewpython-xlib-0.14+20091101/Xlib/xobject/colormap.py0000644000175000017500000001316710770020473020064 0ustar stewstew# Xlib.xobject.colormap -- colormap object # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from Xlib import error from Xlib.protocol import request import resource import re import string rgb_res = [ re.compile(r'\Argb:([0-9a-fA-F]{1,4})/([0-9a-fA-F]{1,4})/([0-9a-fA-F]{1,4})\Z'), re.compile(r'\A#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\Z'), re.compile(r'\A#([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])\Z'), ] class Colormap(resource.Resource): __colormap__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreeColormap(display = self.display, onerror = onerror, cmap = self.id) self.display.free_resource_id(self.id) def copy_colormap_and_free(self, scr_cmap): mid = self.display.allocate_resource_id() request.CopyColormapAndFree(display = self.display, mid = mid, src_cmap = src_cmap) cls = self.display.get_resource_class('colormap', Colormap) return cls(self.display, mid, owner = 1) def install_colormap(self, onerror = None): request.InstallColormap(display = self.display, onerror = onerror, cmap = self.id) def uninstall_colormap(self, onerror = None): request.UninstallColormap(display = self.display, onerror = onerror, cmap = self.id) def alloc_color(self, red, green, blue): return request.AllocColor(display = self.display, cmap = self.id, red = red, green = green, blue = blue) def alloc_named_color(self, name): for r in rgb_res: m = r.match(name) if m: rs = m.group(1) r = string.atoi(rs + '0' * (4 - len(rs)), 16) gs = m.group(2) g = string.atoi(gs + '0' * (4 - len(gs)), 16) bs = m.group(3) b = string.atoi(bs + '0' * (4 - len(bs)), 16) return self.alloc_color(r, g, b) try: return request.AllocNamedColor(display = self.display, cmap = self.id, name = name) except error.BadName: return None def alloc_color_cells(self, contiguous, colors, planes): return request.AllocColorCells(display = self.display, contiguous = contiguous, cmap = self.id, colors = colors, planes = planes) def alloc_color_planes(self, contiguous, colors, red, green, blue): return request.AllocColorPlanes(display = self.display, contiguous = contiguous, cmap = self.id, colors = colors, red = red, green = green, blue = blue) def free_colors(self, pixels, plane_mask, onerror = None): request.FreeColors(display = self.display, onerror = onerror, cmap = self.id, plane_mask = plane_mask, pixels = pixels) def store_colors(self, items, onerror = None): request.StoreColors(display = self.display, onerror = onerror, cmap = self.id, items = items) def store_named_color(self, name, pixel, flags, onerror = None): request.StoreNamedColor(display = self.display, onerror = onerror, flags = flags, cmap = self.id, pixel = pixel, name = name) def query_colors(self, pixels): r = request.QueryColors(display = self.display, cmap = self.id, pixels = pixels) return r.colors def lookup_color(self, name): return request.LookupColor(display = self.display, cmap = self.id, name = name) python-xlib-0.14+20091101/Xlib/xobject/icccm.py0000644000175000017500000000644110770020473017323 0ustar stewstew# Xlib.xobject.icccm -- ICCCM structures # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from Xlib import X, Xutil from Xlib.protocol import rq Aspect = rq.Struct( rq.Int32('num'), rq.Int32('denum') ) WMNormalHints = rq.Struct( rq.Card32('flags'), rq.Pad(16), rq.Int32('min_width', default = 0), rq.Int32('min_height', default = 0), rq.Int32('max_width', default = 0), rq.Int32('max_height', default = 0), rq.Int32('width_inc', default = 0), rq.Int32('height_inc', default = 0), rq.Object('min_aspect', Aspect, default = (0, 0)), rq.Object('max_aspect', Aspect, default = (0, 0)), rq.Int32('base_width', default = 0), rq.Int32('base_height', default = 0), rq.Int32('win_gravity', default = 0), ) WMHints = rq.Struct( rq.Card32('flags'), rq.Card32('input', default = 0), rq.Set('initial_state', 4, # withdrawn is totally bogus according to # ICCCM, but some window managers seem to # use this value to identify dockapps. # Oh well. ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState ), default = Xutil.NormalState), rq.Pixmap('icon_pixmap', default = 0), rq.Window('icon_window', default = 0), rq.Int32('icon_x', default = 0), rq.Int32('icon_y', default = 0), rq.Pixmap('icon_mask', default = 0), rq.Window('window_group', default = 0), ) WMState = rq.Struct( rq.Set('state', 4, ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState )), rq.Window('icon', ( X.NONE, )), ) WMIconSize = rq.Struct( rq.Card32('min_width'), rq.Card32('min_height'), rq.Card32('max_width'), rq.Card32('max_height'), rq.Card32('width_inc'), rq.Card32('height_inc'), ) python-xlib-0.14+20091101/Xlib/xobject/fontable.py0000644000175000017500000001013410770020473020031 0ustar stewstew# Xlib.xobject.fontable -- fontable objects (GC, font) # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from Xlib.protocol import request import resource import cursor class Fontable(resource.Resource): __fontable__ = resource.Resource.__resource__ def query(self): return request.QueryFont(display = self.display, font = self.id) def query_text_extents(self, string): return request.QueryTextExtents(display = self.display, font = self.id, string = string) class GC(Fontable): __gc__ = resource.Resource.__resource__ def change(self, onerror = None, **keys): request.ChangeGC(display = self.display, onerror = onerror, gc = self.id, attrs = keys) def copy(self, src_gc, mask, onerror = None): request.CopyGC(display = self.display, onerror = onerror, src_gc = src_gc, dst_gc = self.id, mask = mask) def set_dashes(self, offset, dashes, onerror = None): request.SetDashes(display = self.display, onerror = onerror, gc = self.id, dash_offset = offset, dashes = dashes) def set_clip_rectangles(self, x_origin, y_origin, rectangles, ordering, onerror = None): request.SetClipRectangles(display = self.display, onerror = onerror, ordering = ordering, gc = self.id, x_origin = x_origin, y_origin = y_origin, rectangles = rectangles) def free(self, onerror = None): request.FreeGC(display = self.display, onerror = onerror, gc = self.id) self.display.free_resource_id(self.id) class Font(Fontable): __font__ = resource.Resource.__resource__ def close(self, onerror = None): request.CloseFont(display = self.display, onerror = onerror, font = self.id) self.display.free_resource_id(self.id) def create_glyph_cursor(self, mask, source_char, mask_char, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue)): cid = self.display.allocate_resource_id() request.CreateGlyphCursor(display = self.display, cid = cid, source = self.id, mask = mask, source_char = source_char, mask_char = mask_char, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue) cls = self.display.get_resource_class('cursor', cursor.Cursor) return cls(self.display, cid, owner = 1) python-xlib-0.14+20091101/Xlib/xobject/__init__.py0000644000175000017500000000170710770020473020004 0ustar stewstew# Xlib.xobject.__init__ -- glue for Xlib.xobject package # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __all__ = [ 'colormap', 'cursor', 'drawable', 'fontable', 'icccm', 'resource', ] python-xlib-0.14+20091101/Xlib/xobject/drawable.py0000644000175000017500000010103411017347610020020 0ustar stewstew# Xlib.xobject.drawable -- drawable objects (window and pixmap) # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import string from Xlib import X, Xatom, Xutil from Xlib.protocol import request, rq # Other X resource objects import resource import colormap import cursor import fontable # Inter-client communication conventions import icccm class Drawable(resource.Resource): __drawable__ = resource.Resource.__resource__ def get_geometry(self): return request.GetGeometry(display = self.display, drawable = self) def create_pixmap(self, width, height, depth): pid = self.display.allocate_resource_id() request.CreatePixmap(display = self.display, depth = depth, pid = pid, drawable = self.id, width = width, height = height) cls = self.display.get_resource_class('pixmap', Pixmap) return cls(self.display, pid, owner = 1) def create_gc(self, **keys): cid = self.display.allocate_resource_id() request.CreateGC(display = self.display, cid = cid, drawable = self.id, attrs = keys) cls = self.display.get_resource_class('gc', fontable.GC) return cls(self.display, cid, owner = 1) def copy_area(self, gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, onerror = None): request.CopyArea(display = self.display, onerror = onerror, src_drawable = src_drawable, dst_drawable = self.id, gc = gc, src_x = src_x, src_y = src_y, dst_x = dst_x, dst_y = dst_y, width = width, height = height) def copy_plane(self, gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, bit_plane, onerror = None): request.CopyPlane(display = self.display, onerror = onerror, src_drawable = src_drawable, dst_drawable = self.id, gc = gc, src_x = src_x, src_y = src_y, dst_x = dst_x, dst_y = dst_y, width = width, height = height, bit_plane = bit_plane) def poly_point(self, gc, coord_mode, points, onerror = None): request.PolyPoint(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def point(self, gc, x, y, onerror = None): request.PolyPoint(display = self.display, onerror = onerror, coord_mode = X.CoordModeOrigin, drawable = self.id, gc = gc, points = [(x, y)]) def poly_line(self, gc, coord_mode, points, onerror = None): request.PolyLine(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def line(self, gc, x1, y1, x2, y2, onerror = None): request.PolySegment(display = self.display, onerror = onerror, drawable = self.id, gc = gc, segments = [(x1, y1, x2, y2)]) def poly_segment(self, gc, segments, onerror = None): request.PolySegment(display = self.display, onerror = onerror, drawable = self.id, gc = gc, segments = segments) def poly_rectangle(self, gc, rectangles, onerror = None): request.PolyRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = rectangles) def rectangle(self, gc, x, y, width, height, onerror = None): request.PolyRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = [(x, y, width, height)]) def poly_arc(self, gc, arcs, onerror = None): request.PolyArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = arcs) def arc(self, gc, x, y, width, height, angle1, angle2, onerror = None): request.PolyArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = [(x, y, width, height, angle1, angle2)]) def fill_poly(self, gc, shape, coord_mode, points, onerror = None): request.FillPoly(display = self.display, onerror = onerror, shape = shape, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) def poly_fill_rectangle(self, gc, rectangles, onerror = None): request.PolyFillRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = rectangles) def fill_rectangle(self, gc, x, y, width, height, onerror = None): request.PolyFillRectangle(display = self.display, onerror = onerror, drawable = self.id, gc = gc, rectangles = [(x, y, width, height)]) def poly_fill_arc(self, gc, arcs, onerror = None): request.PolyFillArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = arcs) def fill_arc(self, gc, x, y, width, height, angle1, angle2, onerror = None): request.PolyFillArc(display = self.display, onerror = onerror, drawable = self.id, gc = gc, arcs = [(x, y, width, height, angle1, angle2)]) def put_image(self, gc, x, y, width, height, format, depth, left_pad, data, onerror = None): request.PutImage(display = self.display, onerror = onerror, format = format, drawable = self.id, gc = gc, width = width, height = height, dst_x = x, dst_y = y, left_pad = left_pad, depth = depth, data = data) # Trivial little method for putting PIL images. Will break on anything # but depth 1 or 24... def put_pil_image(self, gc, x, y, image, onerror = None): width, height = image.size if image.mode == '1': format = X.XYBitmap depth = 1 if self.display.info.bitmap_format_bit_order == 0: rawmode = '1;R' else: rawmode = '1' pad = self.display.info.bitmap_format_scanline_pad stride = roundup(width, pad) >> 3 elif image.mode == 'RGB': format = X.ZPixmap depth = 24 if self.display.info.image_byte_order == 0: rawmode = 'BGRX' else: rawmode = 'RGBX' pad = self.display.info.bitmap_format_scanline_pad unit = self.display.info.bitmap_format_scanline_unit stride = roundup(width * unit, pad) >> 3 else: raise ValueError, 'Unknown data format' maxlen = (self.display.info.max_request_length << 2) \ - request.PutImage._request.static_size split = maxlen / stride x1 = 0 x2 = width y1 = 0 while y1 < height: h = min(height, split) if h < height: subimage = image.crop((x1, y1, x2, y1 + h)) else: subimage = image w, h = subimage.size data = subimage.tostring("raw", rawmode, stride, 0) self.put_image(gc, x, y, w, h, format, depth, 0, data) y1 = y1 + h y = y + h def get_image(self, x, y, width, height, format, plane_mask): return request.GetImage(display = self.display, format = format, drawable = self.id, x = x, y = y, width = width, height = height, plane_mask = plane_mask) def draw_text(self, gc, x, y, text, onerror = None): request.PolyText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = [text]) def poly_text(self, gc, x, y, items, onerror = None): request.PolyText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = items) def poly_text_16(self, gc, x, y, items, onerror = None): request.PolyText16(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, items = items) def image_text(self, gc, x, y, string, onerror = None): request.ImageText8(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, string = string) def image_text_16(self, gc, x, y, string, onerror = None): request.ImageText16(display = self.display, onerror = onerror, drawable = self.id, gc = gc, x = x, y = y, string = string) def query_best_size(self, item_class, width, height): return request.QueryBestSize(display = self.display, item_class = item_class, drawable = self.id, width = width, height = height) class Window(Drawable): __window__ = resource.Resource.__resource__ def create_window(self, x, y, width, height, border_width, depth, window_class = X.CopyFromParent, visual = X.CopyFromParent, onerror = None, **keys): wid = self.display.allocate_resource_id() request.CreateWindow(display = self.display, onerror = onerror, depth = depth, wid = wid, parent = self.id, x = x, y = y, width = width, height = height, border_width = border_width, window_class = window_class, visual = visual, attrs = keys) cls = self.display.get_resource_class('window', Window) return cls(self.display, wid, owner = 1) def change_attributes(self, onerror = None, **keys): request.ChangeWindowAttributes(display = self.display, onerror = onerror, window = self.id, attrs = keys) def get_attributes(self): return request.GetWindowAttributes(display = self.display, window = self.id) def destroy(self, onerror = None): request.DestroyWindow(display = self.display, onerror = onerror, window = self.id) self.display.free_resource_id(self.id) def destroy_sub_windows(self, onerror = None): request.DestroySubWindows(display = self.display, onerror = onerror, window = self.id) def change_save_set(self, mode, onerror = None): request.ChangeSaveSet(display = self.display, onerror = onerror, mode = mode, window = self.id) def reparent(self, parent, x, y, onerror = None): request.ReparentWindow(display = self.display, onerror = onerror, window = self.id, parent = parent, x = x, y = y) def map(self, onerror = None): request.MapWindow(display = self.display, onerror = onerror, window = self.id) def map_sub_windows(self, onerror = None): request.MapSubwindows(display = self.display, onerror = onerror, window = self.id) def unmap(self, onerror = None): request.UnmapWindow(display = self.display, onerror = onerror, window = self.id) def unmap_sub_windows(self, onerror = None): request.UnmapSubwindows(display = self.display, onerror = onerror, window = self.id) def configure(self, onerror = None, **keys): request.ConfigureWindow(display = self.display, onerror = onerror, window = self.id, attrs = keys) def circulate(self, direction, onerror = None): request.CirculateWindow(display = self.display, onerror = onerror, direction = direction, window = self.id) def raise_window(self, onerror = None): """alias for raising the window to the top - as in XRaiseWindow""" self.configure(onerror, stack_mode = X.Above) def query_tree(self): return request.QueryTree(display = self.display, window = self.id) def change_property(self, property, type, format, data, mode = X.PropModeReplace, onerror = None): request.ChangeProperty(display = self.display, onerror = onerror, mode = mode, window = self.id, property = property, type = type, data = (format, data)) def delete_property(self, property, onerror = None): request.DeleteProperty(display = self.display, onerror = onerror, window = self.id, property = property) def get_property(self, property, type, offset, length, delete = 0): r = request.GetProperty(display = self.display, delete = delete, window = self.id, property = property, type = type, long_offset = offset, long_length = length) if r.property_type: fmt, value = r.value r.format = fmt r.value = value return r else: return None def get_full_property(self, property, type, sizehint = 10): prop = self.get_property(property, type, 0, sizehint) if prop: val = prop.value if prop.bytes_after: prop = self.get_property(property, type, sizehint, prop.bytes_after / 4 + 1) val = val + prop.value prop.value = val return prop else: return None def list_properties(self): r = request.ListProperties(display = self.display, window = self.id) return r.atoms def set_selection_owner(self, selection, time, onerror = None): request.SetSelectionOwner(display = self.display, onerror = onerror, window = self.id, selection = selection, time = time) def convert_selection(self, selection, target, property, time, onerror = None): request.ConvertSelection(display = self.display, onerror = onerror, requestor = self.id, selection = selection, target = target, property = property, time = time) def send_event(self, event, event_mask = 0, propagate = 0, onerror = None): request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, destination = self.id, event_mask = event_mask, event = event) def grab_pointer(self, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time): r = request.GrabPointer(display = self.display, owner_events = owner_events, grab_window = self.id, event_mask = event_mask, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode, confine_to = confine_to, cursor = cursor, time = time) return r.status def grab_button(self, button, modifiers, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, onerror = None): request.GrabButton(display = self.display, onerror = onerror, owner_events = owner_events, grab_window = self.id, event_mask = event_mask, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode, confine_to = confine_to, cursor = cursor, button = button, modifiers = modifiers) def ungrab_button(self, button, modifiers, onerror = None): request.UngrabButton(display = self.display, onerror = onerror, button = button, grab_window = self.id, modifiers = modifiers) def grab_keyboard(self, owner_events, pointer_mode, keyboard_mode, time): r = request.GrabKeyboard(display = self.display, owner_events = owner_events, grab_window = self.id, time = time, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode) return r.status def grab_key(self, key, modifiers, owner_events, pointer_mode, keyboard_mode, onerror = None): request.GrabKey(display = self.display, onerror = onerror, owner_events = owner_events, grab_window = self.id, modifiers = modifiers, key = key, pointer_mode = pointer_mode, keyboard_mode = keyboard_mode) def ungrab_key(self, key, modifiers, onerror = None): request.UngrabKey(display = self.display, onerror = onerror, key = key, grab_window = self.id, modifiers = modifiers) def query_pointer(self): return request.QueryPointer(display = self.display, window = self.id) def get_motion_events(self, start, stop): r = request.GetMotionEvents(display = self.display, window = self.id, start = start, stop = stop) return r.events def translate_coords(self, src_window, src_x, src_y): return request.TranslateCoords(display = self.display, src_wid = src_window, dst_wid = self.id, src_x = src_x, src_y = src_y) def warp_pointer(self, x, y, src_window = 0, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None): request.WarpPointer(display = self.display, onerror = onerror, src_window = src_window, dst_window = self.id, src_x = src_x, src_y = src_y, src_width = src_width, src_height = src_height, dst_x = x, dst_y = y) def set_input_focus(self, revert_to, time, onerror = None): request.SetInputFocus(display = self.display, onerror = onerror, revert_to = revert_to, focus = self.id, time = time) def clear_area(self, x = 0, y = 0, width = 0, height = 0, exposures = 0, onerror = None): request.ClearArea(display = self.display, onerror = onerror, exposures = exposures, window = self.id, x = x, y = y, width = width, height = height) def create_colormap(self, visual, alloc): mid = self.display.allocate_resource_id() request.CreateColormap(display = self.display, alloc = alloc, mid = mid, window = self.id, visual = visual) cls = self.display.get_resource_class('colormap', colormap.Colormap) return cls(self.display, mid, owner = 1) def list_installed_colormaps(self): r = request.ListInstalledColormaps(display = self.display, window = self.id) return r.cmaps def rotate_properties(self, properties, delta, onerror = None): request.RotateProperties(display = self.display, onerror = onerror, window = self.id, delta = delta, properties = properties) def set_wm_name(self, name, onerror = None): self.change_property(Xatom.WM_NAME, Xatom.STRING, 8, name, onerror = onerror) def get_wm_name(self): d = self.get_full_property(Xatom.WM_NAME, Xatom.STRING) if d is None or d.format != 8: return None else: return d.value def set_wm_icon_name(self, name, onerror = None): self.change_property(Xatom.WM_ICON_NAME, Xatom.STRING, 8, name, onerror = onerror) def get_wm_icon_name(self): d = self.get_full_property(Xatom.WM_ICON_NAME, Xatom.STRING) if d is None or d.format != 8: return None else: return d.value def set_wm_class(self, inst, cls, onerror = None): self.change_property(Xatom.WM_CLASS, Xatom.STRING, 8, '%s\0%s\0' % (inst, cls), onerror = onerror) def get_wm_class(self): d = self.get_full_property(Xatom.WM_CLASS, Xatom.STRING) if d is None or d.format != 8: return None else: parts = string.split(d.value, '\0') if len(parts) < 2: return None else: return parts[0], parts[1] def set_wm_transient_for(self, window, onerror = None): self.change_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, 32, window.id, onerror = onerror) def get_wm_transient_for(self): d = self.get_property(Xatom.WM_TRANSIENT_FOR, Xatom.WINDOW, 0, 1) if d is None or d.format != 32 or len(d.value) < 1: return None else: cls = self.display.get_resource_class('window', Window) return cls(self.display, d.value[0]) def set_wm_protocols(self, protocols, onerror = None): self.change_property(self.display.get_atom('WM_PROTOCOLS'), Xatom.ATOM, 32, protocols, onerror = onerror) def get_wm_protocols(self): d = self.get_full_property(self.display.get_atom('WM_PROTOCOLS'), Xatom.ATOM) if d is None or d.format != 32: return [] else: return d.value def set_wm_colormap_windows(self, windows, onerror = None): self.change_property(self.display.get_atom('WM_COLORMAP_WINDOWS'), Xatom.WINDOW, 32, map(lambda w: w.id, windows), onerror = onerror) def get_wm_colormap_windows(self): d = self.get_full_property(self.display.get_atom('WM_COLORMAP_WINDOWS'), Xatom.WINDOW) if d is None or d.format != 32: return [] else: cls = self.display.get_resource_class('window', Window) return map(lambda i, d = self.display, c = cls: c(d, i), d.value) def set_wm_client_machine(self, name, onerror = None): self.change_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING, 8, name, onerror = onerror) def get_wm_client_machine(self): d = self.get_full_property(Xatom.WM_CLIENT_MACHINE, Xatom.STRING) if d is None or d.format != 8: return None else: return d.value def set_wm_normal_hints(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_NORMAL_HINTS, Xatom.WM_SIZE_HINTS, icccm.WMNormalHints, hints, keys, onerror) def get_wm_normal_hints(self): return self._get_struct_prop(Xatom.WM_NORMAL_HINTS, Xatom.WM_SIZE_HINTS, icccm.WMNormalHints) def set_wm_hints(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, icccm.WMHints, hints, keys, onerror) def get_wm_hints(self): return self._get_struct_prop(Xatom.WM_HINTS, Xatom.WM_HINTS, icccm.WMHints) def set_wm_state(self, hints = {}, onerror = None, **keys): atom = self.display.get_atom('WM_STATE') self._set_struct_prop(atom, atom, icccm.WMState, hints, keys, onerror) def get_wm_state(self): atom = self.display.get_atom('WM_STATE') return self._get_struct_prop(atom, atom, icccm.WMState) def set_wm_icon_size(self, hints = {}, onerror = None, **keys): self._set_struct_prop(Xatom.WM_ICON_SIZE, Xatom.WM_ICON_SIZE, icccm.WMIconSize, hints, keys, onerror) def get_wm_icon_size(self): return self._get_struct_prop(Xatom.WM_ICON_SIZE, Xatom.WM_ICON_SIZE, icccm.WMIconSize) # Helper function for getting structured properties. # pname and ptype are atoms, and pstruct is a Struct object. # Returns a DictWrapper, or None def _get_struct_prop(self, pname, ptype, pstruct): r = self.get_property(pname, ptype, 0, pstruct.static_size / 4) if r and r.format == 32: value = r.value.tostring() if len(value) == pstruct.static_size: return pstruct.parse_binary(value, self.display)[0] return None # Helper function for setting structured properties. # pname and ptype are atoms, and pstruct is a Struct object. # hints is a mapping or a DictWrapper, keys is a mapping. keys # will be modified. onerror is the error handler. def _set_struct_prop(self, pname, ptype, pstruct, hints, keys, onerror): if isinstance(hints, rq.DictWrapper): keys.update(hints._data) else: keys.update(hints) value = apply(pstruct.to_binary, (), keys) self.change_property(pname, ptype, 32, value, onerror = onerror) class Pixmap(Drawable): __pixmap__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreePixmap(display = self.display, onerror = onerror, pixmap = self.id) self.display.free_resource_id(self.id) def create_cursor(self, mask, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), x, y): cid = self.display.allocate_resource_id() request.CreateCursor(display = self.display, cid = cid, source = self.id, mask = mask, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue, x = x, y = y) cls = self.display.get_resource_class('cursor', cursor.Cursor) return cls(self.display, cid, owner = 1) def roundup(value, unit): return (value + (unit - 1)) & ~(unit - 1) python-xlib-0.14+20091101/Xlib/xobject/cursor.py0000644000175000017500000000340310770020473017555 0ustar stewstew# Xlib.xobject.cursor -- cursor object # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from Xlib.protocol import request import resource class Cursor(resource.Resource): __cursor__ = resource.Resource.__resource__ def free(self, onerror = None): request.FreeCursor(display = self.display, onerror = onerror, cursor = self.id) self.display.free_resource_id(self.id) def recolor(self, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), onerror = None): request.RecolorCursor(display = self.display, onerror = onerror, cursor = self.id, fore_red = fore_red, fore_green = fore_green, fore_blue = fore_blue, back_red = back_red, back_green = back_green, back_blue = back_blue) python-xlib-0.14+20091101/Xlib/xobject/resource.py0000644000175000017500000000335010770020473020070 0ustar stewstew# Xlib.xobject.resource -- any X resource object # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA from Xlib.protocol import request class Resource: def __init__(self, display, rid, owner = 0): self.display = display self.id = rid self.owner = owner def __resource__(self): return self.id def __cmp__(self, obj): if isinstance(obj, Resource): if self.display == obj.display: return cmp(self.id, obj.id) else: return cmp(self.display, obj.display) else: return cmp(id(self), id(obj)) def __hash__(self): return int(self.id) def __str__(self): return '%s(0x%08x)' % (self.__class__, self.id) def __repr__(self): return '<%s 0x%08x>' % (self.__class__, self.id) def kill_client(self, onerror = None): request.KillClient(display = self.display, onerror = onerror, resource = self.id) python-xlib-0.14+20091101/Xlib/xauth.py0000644000175000017500000001001610770020473015731 0ustar stewstew# Xlib.xauth -- ~/.Xauthority access # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os import struct from Xlib import X, error FamilyInternet = X.FamilyInternet FamilyDECnet = X.FamilyDECnet FamilyChaos = X.FamilyChaos FamilyLocal = 256 class Xauthority: def __init__(self, filename = None): if filename is None: filename = os.environ.get('XAUTHORITY') if filename is None: try: filename = os.path.join(os.environ['HOME'], '.Xauthority') except KeyError: raise error.XauthError( '$HOME not set, cannot find ~/.Xauthority') try: raw = open(filename, 'rb').read() except IOError, err: raise error.XauthError('~/.Xauthority: %s' % err) self.entries = [] # entry format (all shorts in big-endian) # short family; # short addrlen; # char addr[addrlen]; # short numlen; # char num[numlen]; # short namelen; # char name[namelen]; # short datalen; # char data[datalen]; n = 0 try: while n < len(raw): family, = struct.unpack('>H', raw[n:n+2]) n = n + 2 length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 addr = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 num = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 name = raw[n - length : n] length, = struct.unpack('>H', raw[n:n+2]) n = n + length + 2 data = raw[n - length : n] if len(data) != length: break self.entries.append((family, addr, num, name, data)) except struct.error, e: print "Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename #pass if len(self.entries) == 0: print "Xlib.xauth: warning, no xauthority details available" # raise an error? this should get partially caught by the XNoAuthError in get_best_auth.. def __len__(self): return len(self.entries) def __getitem__(self, i): return self.entries[i] def get_best_auth(self, family, address, dispno, types = ( "MIT-MAGIC-COOKIE-1", )): """Find an authentication entry matching FAMILY, ADDRESS and DISPNO. The name of the auth scheme must match one of the names in TYPES. If several entries match, the first scheme in TYPES will be choosen. If an entry is found, the tuple (name, data) is returned, otherwise XNoAuthError is raised. """ num = str(dispno) matches = {} for efam, eaddr, enum, ename, edata in self.entries: if efam == family and eaddr == address and num == enum: matches[ename] = edata for t in types: try: return (t, matches[t]) except KeyError: pass raise error.XNoAuthError((family, address, dispno)) python-xlib-0.14+20091101/Xlib/rdb.py0000644000175000017500000004673210770020473015365 0ustar stewstew# Xlib.rdb -- X resource database implementation # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # See end of file for an explanation of the algorithm and # data structures used. # Standard modules import string import types import re import sys # Xlib modules from support import lock # Set up a few regexpes for parsing string representation of resources comment_re = re.compile(r'^\s*!') resource_spec_re = re.compile(r'^\s*([-_a-zA-Z0-9?.*]+)\s*:\s*(.*)$') value_escape_re = re.compile('\\\\([ \tn\\\\]|[0-7]{3,3})') resource_parts_re = re.compile(r'([.*]+)') # Constants used for determining which match is best NAME_MATCH = 0 CLASS_MATCH = 2 WILD_MATCH = 4 MATCH_SKIP = 6 # Option error class class OptionError(Exception): pass class ResourceDB: def __init__(self, file = None, string = None, resources = None): self.db = {} self.lock = lock.allocate_lock() if file is not None: self.insert_file(file) if string is not None: self.insert_string(string) if resources is not None: self.insert_resources(resources) def insert_file(self, file): """insert_file(file) Load resources entries from FILE, and insert them into the database. FILE can be a filename (a string)or a file object. """ if type(file) is types.StringType: file = open(file, 'r') self.insert_string(file.read()) def insert_string(self, data): """insert_string(data) Insert the resources entries in the string DATA into the database. """ # First split string into lines lines = string.split(data, '\n') while lines: line = lines[0] del lines[0] # Skip empty line if not line: continue # Skip comments if comment_re.match(line): continue # Handle continued lines while line[-1] == '\\': if lines: line = line[:-1] + lines[0] del lines[0] else: line = line[:-1] break # Split line into resource and value m = resource_spec_re.match(line) # Bad line, just ignore it silently if not m: continue res, value = m.group(1, 2) # Convert all escape sequences in value splits = value_escape_re.split(value) for i in range(1, len(splits), 2): s = splits[i] if len(s) == 3: splits[i] = chr(string.atoi(s, 8)) elif s == 'n': splits[i] = '\n' # strip the last value part to get rid of any # unescaped blanks splits[-1] = string.rstrip(splits[-1]) value = string.join(splits, '') self.insert(res, value) def insert_resources(self, resources): """insert_resources(resources) Insert all resources entries in the list RESOURCES into the database. Each element in RESOURCES should be a tuple: (resource, value) Where RESOURCE is a string and VALUE can be any Python value. """ for res, value in resources: self.insert(res, value) def insert(self, resource, value): """insert(resource, value) Insert a resource entry into the database. RESOURCE is a string and VALUE can be any Python value. """ # Split res into components and bindings parts = resource_parts_re.split(resource) # If the last part is empty, this is an invalid resource # which we simply ignore if parts[-1] == '': return self.lock.acquire() db = self.db for i in range(1, len(parts), 2): # Create a new mapping/value group if not db.has_key(parts[i - 1]): db[parts[i - 1]] = ({}, {}) # Use second mapping if a loose binding, first otherwise if '*' in parts[i]: db = db[parts[i - 1]][1] else: db = db[parts[i - 1]][0] # Insert value into the derived db if db.has_key(parts[-1]): db[parts[-1]] = db[parts[-1]][:2] + (value, ) else: db[parts[-1]] = ({}, {}, value) self.lock.release() def __getitem__(self, (name, cls)): """db[name, class] Return the value matching the resource identified by NAME and CLASS. If no match is found, KeyError is raised. """ # Split name and class into their parts namep = string.split(name, '.') clsp = string.split(cls, '.') # It is an error for name and class to have different number # of parts if len(namep) != len(clsp): raise ValueError('Different number of parts in resource name/class: %s/%s' % (name, cls)) complen = len(namep) matches = [] # Lock database and wrap the lookup code in a try-finally # block to make sure that it is unlocked. self.lock.acquire() try: # Precedence order: name -> class -> ? if self.db.has_key(namep[0]): bin_insert(matches, _Match((NAME_MATCH, ), self.db[namep[0]])) if self.db.has_key(clsp[0]): bin_insert(matches, _Match((CLASS_MATCH, ), self.db[clsp[0]])) if self.db.has_key('?'): bin_insert(matches, _Match((WILD_MATCH, ), self.db['?'])) # Special case for the unlikely event that the resource # only has one component if complen == 1 and matches: x = matches[0] if x.final(complen): return x.value() else: raise KeyError((name, cls)) # Special case for resources which begins with a loose # binding, e.g. '*foo.bar' if self.db.has_key(''): bin_insert(matches, _Match((), self.db[''][1])) # Now iterate over all components until we find the best match. # For each component, we choose the best partial match among # the mappings by applying these rules in order: # Rule 1: If the current group contains a match for the # name, class or '?', we drop all previously found loose # binding mappings. # Rule 2: A matching name has precedence over a matching # class, which in turn has precedence over '?'. # Rule 3: Tight bindings have precedence over loose # bindings. while matches: # Work on the first element == the best current match x = matches[0] del matches[0] # print 'path: ', x.path # if x.skip: # print 'skip: ', x.db # else: # print 'group: ', x.group # print i = x.match_length() for part, score in ((namep[i], NAME_MATCH), (clsp[i], CLASS_MATCH), ('?', WILD_MATCH)): # Attempt to find a match in x match = x.match(part, score) if match: # Hey, we actually found a value! if match.final(complen): return match.value() # Else just insert the new match else: bin_insert(matches, match) # Generate a new loose match match = x.skip_match(complen) if match: bin_insert(matches, match) # Oh well, nothing matched raise KeyError((name, cls)) finally: self.lock.release() def get(self, res, cls, default = None): """get(name, class [, default]) Return the value matching the resource identified by NAME and CLASS. If no match is found, DEFAULT is returned, or None if DEFAULT isn't specified. """ try: return self[(res, cls)] except KeyError: return default def update(self, db): """update(db) Update this database with all resources entries in the resource database DB. """ self.lock.acquire() update_db(self.db, db.db) self.lock.release() def output(self): """output() Return the resource database in text representation. """ self.lock.acquire() text = output_db('', self.db) self.lock.release() return text def getopt(self, name, argv, opts): """getopt(name, argv, opts) Parse X command line options, inserting the recognised options into the resource database. NAME is the application name, and will be prepended to all specifiers. ARGV is the list of command line arguments, typically sys.argv[1:]. OPTS is a mapping of options to resource specifiers. The key is the option flag (with leading -), and the value is an instance of some Option subclass: NoArg(specifier, value): set resource to value. IsArg(specifier): set resource to option itself SepArg(specifier): value is next argument ResArg: resource and value in next argument SkipArg: ignore this option and next argument SkipLine: ignore rest of arguments SkipNArgs(count): ignore this option and count arguments The remaining, non-option, oparguments is returned. rdb.OptionError is raised if there is an error in the argument list. """ while argv and argv[0] and argv[0][0] == '-': try: argv = opts[argv[0]].parse(name, self, argv) except KeyError: raise OptionError('unknown option: %s' % argv[0]) except IndexError: raise OptionError('missing argument to option: %s' % argv[0]) return argv class _Match: def __init__(self, path, dbs): self.path = path if type(dbs) is types.TupleType: self.skip = 0 self.group = dbs else: self.skip = 1 self.db = dbs def __cmp__(self, other): return cmp(self.path, other.path) def match_length(self): return len(self.path) def match(self, part, score): if self.skip: if self.db.has_key(part): return _Match(self.path + (score, ), self.db[part]) else: return None else: if self.group[0].has_key(part): return _Match(self.path + (score, ), self.group[0][part]) elif self.group[1].has_key(part): return _Match(self.path + (score + 1, ), self.group[1][part]) else: return None def skip_match(self, complen): # Can't make another skip if we have run out of components if len(self.path) + 1 >= complen: return None # If this already is a skip match, clone a new one if self.skip: if self.db: return _Match(self.path + (MATCH_SKIP, ), self.db) else: return None # Only generate a skip match if the loose binding mapping # is non-empty elif self.group[1]: return _Match(self.path + (MATCH_SKIP, ), self.group[1]) # This is a dead end match else: return None def final(self, complen): if not self.skip and len(self.path) == complen and len(self.group) > 2: return 1 else: return 0 def value(self): return self.group[2] # # Helper function for ResourceDB.__getitem__() # def bin_insert(list, element): """bin_insert(list, element) Insert ELEMENT into LIST. LIST must be sorted, and ELEMENT will be inserted to that LIST remains sorted. If LIST already contains ELEMENT, it will not be duplicated. """ if not list: list.append(element) return lower = 0 upper = len(list) - 1 while lower <= upper: center = (lower + upper) / 2 if element < list[center]: upper = center - 1 elif element > list[center]: lower = center + 1 elif element == list[center]: return if element < list[upper]: list.insert(upper, element) elif element > list[upper]: list.insert(upper + 1, element) # # Helper functions for ResourceDB.update() # def update_db(dest, src): for comp, group in src.items(): # DEST already contains this component, update it if dest.has_key(comp): # Update tight and loose binding databases update_db(dest[comp][0], group[0]) update_db(dest[comp][1], group[1]) # If a value has been set in SRC, update # value in DEST if len(group) > 2: dest[comp] = dest[comp][:2] + group[2:] # COMP not in src, make a deep copy else: dest[comp] = copy_group(group) def copy_group(group): return (copy_db(group[0]), copy_db(group[1])) + group[2:] def copy_db(db): newdb = {} for comp, group in db.items(): newdb[comp] = copy_group(group) return newdb # # Helper functions for output # def output_db(prefix, db): res = '' for comp, group in db.items(): # There's a value for this component if len(group) > 2: res = res + '%s%s: %s\n' % (prefix, comp, output_escape(group[2])) # Output tight and loose bindings res = res + output_db(prefix + comp + '.', group[0]) res = res + output_db(prefix + comp + '*', group[1]) return res def output_escape(value): value = str(value) if not value: return value for char, esc in (('\\', '\\\\'), ('\000', '\\000'), ('\n', '\\n')): value = string.replace(value, char, esc) # If first or last character is space or tab, escape them. if value[0] in ' \t': value = '\\' + value if value[-1] in ' \t' and value[-2:-1] != '\\': value = value[:-1] + '\\' + value[-1] return value # # Option type definitions # class Option: def __init__(self): pass def parse(self, name, db, args): pass class NoArg(Option): """Value is provided to constructor.""" def __init__(self, specifier, value): self.specifier = specifier self.value = value def parse(self, name, db, args): db.insert(name + self.specifier, self.value) return args[1:] class IsArg(Option): """Value is the option string itself.""" def __init__(self, specifier): self.specifier = specifier def parse(self, name, db, args): db.insert(name + self.specifier, args[0]) return args[1:] class SepArg(Option): """Value is the next argument.""" def __init__(self, specifier): self.specifier = specifier def parse(self, name, db, args): db.insert(name + self.specifier, args[1]) return args[2:] class ResArgClass(Option): """Resource and value in the next argument.""" def parse(self, name, db, args): db.insert_string(args[1]) return args[2:] ResArg = ResArgClass() class SkipArgClass(Option): """Ignore this option and next argument.""" def parse(self, name, db, args): return args[2:] SkipArg = SkipArgClass() class SkipLineClass(Option): """Ignore rest of the arguments.""" def parse(self, name, db, args): return [] SkipLine = SkipLineClass() class SkipNArgs(Option): """Ignore this option and the next COUNT arguments.""" def __init__(self, count): self.count = count def parse(self, name, db, args): return args[1 + self.count:] def get_display_opts(options, argv = sys.argv): """display, name, db, args = get_display_opts(options, [argv]) Parse X OPTIONS from ARGV (or sys.argv if not provided). Connect to the display specified by a *.display resource if one is set, or to the default X display otherwise. Extract the RESOURCE_MANAGER property and insert all resources from ARGV. The four return values are: DISPLAY -- the display object NAME -- the application name (the filname of ARGV[0]) DB -- the created resource database ARGS -- any remaining arguments """ from Xlib import display, Xatom import os name = os.path.splitext(os.path.basename(argv[0]))[0] optdb = ResourceDB() leftargv = optdb.getopt(name, argv[1:], options) dname = optdb.get(name + '.display', name + '.Display', None) d = display.Display(dname) rdbstring = d.screen(0).root.get_full_property(Xatom.RESOURCE_MANAGER, Xatom.STRING) if rdbstring: data = rdbstring.value else: data = None db = ResourceDB(string = data) db.update(optdb) return d, name, db, leftargv # Common X options stdopts = {'-bg': SepArg('*background'), '-background': SepArg('*background'), '-fg': SepArg('*foreground'), '-foreground': SepArg('*foreground'), '-fn': SepArg('*font'), '-font': SepArg('*font'), '-name': SepArg('.name'), '-title': SepArg('.title'), '-synchronous': NoArg('*synchronous', 'on'), '-xrm': ResArg, '-display': SepArg('.display'), '-d': SepArg('.display'), } # Notes on the implementation: # Resource names are split into their components, and each component # is stored in a mapping. The value for a component is a tuple of two # or three elements: # (tightmapping, loosemapping [, value]) # tightmapping contains the next components which are connected with a # tight binding (.). loosemapping contains the ones connected with # loose binding (*). If value is present, then this component is the # last component for some resource which that value. # The top level components are stored in the mapping r.db, where r is # the resource object. # Example: Inserting "foo.bar*gazonk: yep" into an otherwise empty # resource database would give the folliwing structure: # { 'foo': ( { 'bar': ( { }, # { 'gazonk': ( { }, # { }, # 'yep') # } # ) # }, # {}) # } python-xlib-0.14+20091101/Xlib/keysymdef/0000755000175000017500000000000011273361453016235 5ustar stewstewpython-xlib-0.14+20091101/Xlib/keysymdef/katakana.py0000644000175000017500000000256510201300703020347 0ustar stewstewXK_overline = 0x47e XK_kana_fullstop = 0x4a1 XK_kana_openingbracket = 0x4a2 XK_kana_closingbracket = 0x4a3 XK_kana_comma = 0x4a4 XK_kana_conjunctive = 0x4a5 XK_kana_middledot = 0x4a5 XK_kana_WO = 0x4a6 XK_kana_a = 0x4a7 XK_kana_i = 0x4a8 XK_kana_u = 0x4a9 XK_kana_e = 0x4aa XK_kana_o = 0x4ab XK_kana_ya = 0x4ac XK_kana_yu = 0x4ad XK_kana_yo = 0x4ae XK_kana_tsu = 0x4af XK_kana_tu = 0x4af XK_prolongedsound = 0x4b0 XK_kana_A = 0x4b1 XK_kana_I = 0x4b2 XK_kana_U = 0x4b3 XK_kana_E = 0x4b4 XK_kana_O = 0x4b5 XK_kana_KA = 0x4b6 XK_kana_KI = 0x4b7 XK_kana_KU = 0x4b8 XK_kana_KE = 0x4b9 XK_kana_KO = 0x4ba XK_kana_SA = 0x4bb XK_kana_SHI = 0x4bc XK_kana_SU = 0x4bd XK_kana_SE = 0x4be XK_kana_SO = 0x4bf XK_kana_TA = 0x4c0 XK_kana_CHI = 0x4c1 XK_kana_TI = 0x4c1 XK_kana_TSU = 0x4c2 XK_kana_TU = 0x4c2 XK_kana_TE = 0x4c3 XK_kana_TO = 0x4c4 XK_kana_NA = 0x4c5 XK_kana_NI = 0x4c6 XK_kana_NU = 0x4c7 XK_kana_NE = 0x4c8 XK_kana_NO = 0x4c9 XK_kana_HA = 0x4ca XK_kana_HI = 0x4cb XK_kana_FU = 0x4cc XK_kana_HU = 0x4cc XK_kana_HE = 0x4cd XK_kana_HO = 0x4ce XK_kana_MA = 0x4cf XK_kana_MI = 0x4d0 XK_kana_MU = 0x4d1 XK_kana_ME = 0x4d2 XK_kana_MO = 0x4d3 XK_kana_YA = 0x4d4 XK_kana_YU = 0x4d5 XK_kana_YO = 0x4d6 XK_kana_RA = 0x4d7 XK_kana_RI = 0x4d8 XK_kana_RU = 0x4d9 XK_kana_RE = 0x4da XK_kana_RO = 0x4db XK_kana_WA = 0x4dc XK_kana_N = 0x4dd XK_voicedsound = 0x4de XK_semivoicedsound = 0x4df XK_kana_switch = 0xFF7E python-xlib-0.14+20091101/Xlib/keysymdef/special.py0000644000175000017500000000075210201300703020210 0ustar stewstewXK_blank = 0x9df XK_soliddiamond = 0x9e0 XK_checkerboard = 0x9e1 XK_ht = 0x9e2 XK_ff = 0x9e3 XK_cr = 0x9e4 XK_lf = 0x9e5 XK_nl = 0x9e8 XK_vt = 0x9e9 XK_lowrightcorner = 0x9ea XK_uprightcorner = 0x9eb XK_upleftcorner = 0x9ec XK_lowleftcorner = 0x9ed XK_crossinglines = 0x9ee XK_horizlinescan1 = 0x9ef XK_horizlinescan3 = 0x9f0 XK_horizlinescan5 = 0x9f1 XK_horizlinescan7 = 0x9f2 XK_horizlinescan9 = 0x9f3 XK_leftt = 0x9f4 XK_rightt = 0x9f5 XK_bott = 0x9f6 XK_topt = 0x9f7 XK_vertbar = 0x9f8 python-xlib-0.14+20091101/Xlib/keysymdef/latin4.py0000644000175000017500000000124610201300703017762 0ustar stewstewXK_kra = 0x3a2 XK_kappa = 0x3a2 XK_Rcedilla = 0x3a3 XK_Itilde = 0x3a5 XK_Lcedilla = 0x3a6 XK_Emacron = 0x3aa XK_Gcedilla = 0x3ab XK_Tslash = 0x3ac XK_rcedilla = 0x3b3 XK_itilde = 0x3b5 XK_lcedilla = 0x3b6 XK_emacron = 0x3ba XK_gcedilla = 0x3bb XK_tslash = 0x3bc XK_ENG = 0x3bd XK_eng = 0x3bf XK_Amacron = 0x3c0 XK_Iogonek = 0x3c7 XK_Eabovedot = 0x3cc XK_Imacron = 0x3cf XK_Ncedilla = 0x3d1 XK_Omacron = 0x3d2 XK_Kcedilla = 0x3d3 XK_Uogonek = 0x3d9 XK_Utilde = 0x3dd XK_Umacron = 0x3de XK_amacron = 0x3e0 XK_iogonek = 0x3e7 XK_eabovedot = 0x3ec XK_imacron = 0x3ef XK_ncedilla = 0x3f1 XK_omacron = 0x3f2 XK_kcedilla = 0x3f3 XK_uogonek = 0x3f9 XK_utilde = 0x3fd XK_umacron = 0x3fe python-xlib-0.14+20091101/Xlib/keysymdef/greek.py0000644000175000017500000000346010201300703017664 0ustar stewstewXK_Greek_ALPHAaccent = 0x7a1 XK_Greek_EPSILONaccent = 0x7a2 XK_Greek_ETAaccent = 0x7a3 XK_Greek_IOTAaccent = 0x7a4 XK_Greek_IOTAdiaeresis = 0x7a5 XK_Greek_OMICRONaccent = 0x7a7 XK_Greek_UPSILONaccent = 0x7a8 XK_Greek_UPSILONdieresis = 0x7a9 XK_Greek_OMEGAaccent = 0x7ab XK_Greek_accentdieresis = 0x7ae XK_Greek_horizbar = 0x7af XK_Greek_alphaaccent = 0x7b1 XK_Greek_epsilonaccent = 0x7b2 XK_Greek_etaaccent = 0x7b3 XK_Greek_iotaaccent = 0x7b4 XK_Greek_iotadieresis = 0x7b5 XK_Greek_iotaaccentdieresis = 0x7b6 XK_Greek_omicronaccent = 0x7b7 XK_Greek_upsilonaccent = 0x7b8 XK_Greek_upsilondieresis = 0x7b9 XK_Greek_upsilonaccentdieresis = 0x7ba XK_Greek_omegaaccent = 0x7bb XK_Greek_ALPHA = 0x7c1 XK_Greek_BETA = 0x7c2 XK_Greek_GAMMA = 0x7c3 XK_Greek_DELTA = 0x7c4 XK_Greek_EPSILON = 0x7c5 XK_Greek_ZETA = 0x7c6 XK_Greek_ETA = 0x7c7 XK_Greek_THETA = 0x7c8 XK_Greek_IOTA = 0x7c9 XK_Greek_KAPPA = 0x7ca XK_Greek_LAMDA = 0x7cb XK_Greek_LAMBDA = 0x7cb XK_Greek_MU = 0x7cc XK_Greek_NU = 0x7cd XK_Greek_XI = 0x7ce XK_Greek_OMICRON = 0x7cf XK_Greek_PI = 0x7d0 XK_Greek_RHO = 0x7d1 XK_Greek_SIGMA = 0x7d2 XK_Greek_TAU = 0x7d4 XK_Greek_UPSILON = 0x7d5 XK_Greek_PHI = 0x7d6 XK_Greek_CHI = 0x7d7 XK_Greek_PSI = 0x7d8 XK_Greek_OMEGA = 0x7d9 XK_Greek_alpha = 0x7e1 XK_Greek_beta = 0x7e2 XK_Greek_gamma = 0x7e3 XK_Greek_delta = 0x7e4 XK_Greek_epsilon = 0x7e5 XK_Greek_zeta = 0x7e6 XK_Greek_eta = 0x7e7 XK_Greek_theta = 0x7e8 XK_Greek_iota = 0x7e9 XK_Greek_kappa = 0x7ea XK_Greek_lamda = 0x7eb XK_Greek_lambda = 0x7eb XK_Greek_mu = 0x7ec XK_Greek_nu = 0x7ed XK_Greek_xi = 0x7ee XK_Greek_omicron = 0x7ef XK_Greek_pi = 0x7f0 XK_Greek_rho = 0x7f1 XK_Greek_sigma = 0x7f2 XK_Greek_finalsmallsigma = 0x7f3 XK_Greek_tau = 0x7f4 XK_Greek_upsilon = 0x7f5 XK_Greek_phi = 0x7f6 XK_Greek_chi = 0x7f7 XK_Greek_psi = 0x7f8 XK_Greek_omega = 0x7f9 XK_Greek_switch = 0xFF7E python-xlib-0.14+20091101/Xlib/keysymdef/xk3270.py0000644000175000017500000000134210201300703017522 0ustar stewstewXK_3270_Duplicate = 0xFD01 XK_3270_FieldMark = 0xFD02 XK_3270_Right2 = 0xFD03 XK_3270_Left2 = 0xFD04 XK_3270_BackTab = 0xFD05 XK_3270_EraseEOF = 0xFD06 XK_3270_EraseInput = 0xFD07 XK_3270_Reset = 0xFD08 XK_3270_Quit = 0xFD09 XK_3270_PA1 = 0xFD0A XK_3270_PA2 = 0xFD0B XK_3270_PA3 = 0xFD0C XK_3270_Test = 0xFD0D XK_3270_Attn = 0xFD0E XK_3270_CursorBlink = 0xFD0F XK_3270_AltCursor = 0xFD10 XK_3270_KeyClick = 0xFD11 XK_3270_Jump = 0xFD12 XK_3270_Ident = 0xFD13 XK_3270_Rule = 0xFD14 XK_3270_Copy = 0xFD15 XK_3270_Play = 0xFD16 XK_3270_Setup = 0xFD17 XK_3270_Record = 0xFD18 XK_3270_ChangeScreen = 0xFD19 XK_3270_DeleteWord = 0xFD1A XK_3270_ExSelect = 0xFD1B XK_3270_CursorSelect = 0xFD1C XK_3270_PrintScreen = 0xFD1D XK_3270_Enter = 0xFD1E python-xlib-0.14+20091101/Xlib/keysymdef/xkb.py0000644000175000017500000000555210201300703017357 0ustar stewstewXK_ISO_Lock = 0xFE01 XK_ISO_Level2_Latch = 0xFE02 XK_ISO_Level3_Shift = 0xFE03 XK_ISO_Level3_Latch = 0xFE04 XK_ISO_Level3_Lock = 0xFE05 XK_ISO_Group_Shift = 0xFF7E XK_ISO_Group_Latch = 0xFE06 XK_ISO_Group_Lock = 0xFE07 XK_ISO_Next_Group = 0xFE08 XK_ISO_Next_Group_Lock = 0xFE09 XK_ISO_Prev_Group = 0xFE0A XK_ISO_Prev_Group_Lock = 0xFE0B XK_ISO_First_Group = 0xFE0C XK_ISO_First_Group_Lock = 0xFE0D XK_ISO_Last_Group = 0xFE0E XK_ISO_Last_Group_Lock = 0xFE0F XK_ISO_Left_Tab = 0xFE20 XK_ISO_Move_Line_Up = 0xFE21 XK_ISO_Move_Line_Down = 0xFE22 XK_ISO_Partial_Line_Up = 0xFE23 XK_ISO_Partial_Line_Down = 0xFE24 XK_ISO_Partial_Space_Left = 0xFE25 XK_ISO_Partial_Space_Right = 0xFE26 XK_ISO_Set_Margin_Left = 0xFE27 XK_ISO_Set_Margin_Right = 0xFE28 XK_ISO_Release_Margin_Left = 0xFE29 XK_ISO_Release_Margin_Right = 0xFE2A XK_ISO_Release_Both_Margins = 0xFE2B XK_ISO_Fast_Cursor_Left = 0xFE2C XK_ISO_Fast_Cursor_Right = 0xFE2D XK_ISO_Fast_Cursor_Up = 0xFE2E XK_ISO_Fast_Cursor_Down = 0xFE2F XK_ISO_Continuous_Underline = 0xFE30 XK_ISO_Discontinuous_Underline = 0xFE31 XK_ISO_Emphasize = 0xFE32 XK_ISO_Center_Object = 0xFE33 XK_ISO_Enter = 0xFE34 XK_dead_grave = 0xFE50 XK_dead_acute = 0xFE51 XK_dead_circumflex = 0xFE52 XK_dead_tilde = 0xFE53 XK_dead_macron = 0xFE54 XK_dead_breve = 0xFE55 XK_dead_abovedot = 0xFE56 XK_dead_diaeresis = 0xFE57 XK_dead_abovering = 0xFE58 XK_dead_doubleacute = 0xFE59 XK_dead_caron = 0xFE5A XK_dead_cedilla = 0xFE5B XK_dead_ogonek = 0xFE5C XK_dead_iota = 0xFE5D XK_dead_voiced_sound = 0xFE5E XK_dead_semivoiced_sound = 0xFE5F XK_dead_belowdot = 0xFE60 XK_First_Virtual_Screen = 0xFED0 XK_Prev_Virtual_Screen = 0xFED1 XK_Next_Virtual_Screen = 0xFED2 XK_Last_Virtual_Screen = 0xFED4 XK_Terminate_Server = 0xFED5 XK_AccessX_Enable = 0xFE70 XK_AccessX_Feedback_Enable = 0xFE71 XK_RepeatKeys_Enable = 0xFE72 XK_SlowKeys_Enable = 0xFE73 XK_BounceKeys_Enable = 0xFE74 XK_StickyKeys_Enable = 0xFE75 XK_MouseKeys_Enable = 0xFE76 XK_MouseKeys_Accel_Enable = 0xFE77 XK_Overlay1_Enable = 0xFE78 XK_Overlay2_Enable = 0xFE79 XK_AudibleBell_Enable = 0xFE7A XK_Pointer_Left = 0xFEE0 XK_Pointer_Right = 0xFEE1 XK_Pointer_Up = 0xFEE2 XK_Pointer_Down = 0xFEE3 XK_Pointer_UpLeft = 0xFEE4 XK_Pointer_UpRight = 0xFEE5 XK_Pointer_DownLeft = 0xFEE6 XK_Pointer_DownRight = 0xFEE7 XK_Pointer_Button_Dflt = 0xFEE8 XK_Pointer_Button1 = 0xFEE9 XK_Pointer_Button2 = 0xFEEA XK_Pointer_Button3 = 0xFEEB XK_Pointer_Button4 = 0xFEEC XK_Pointer_Button5 = 0xFEED XK_Pointer_DblClick_Dflt = 0xFEEE XK_Pointer_DblClick1 = 0xFEEF XK_Pointer_DblClick2 = 0xFEF0 XK_Pointer_DblClick3 = 0xFEF1 XK_Pointer_DblClick4 = 0xFEF2 XK_Pointer_DblClick5 = 0xFEF3 XK_Pointer_Drag_Dflt = 0xFEF4 XK_Pointer_Drag1 = 0xFEF5 XK_Pointer_Drag2 = 0xFEF6 XK_Pointer_Drag3 = 0xFEF7 XK_Pointer_Drag4 = 0xFEF8 XK_Pointer_Drag5 = 0xFEFD XK_Pointer_EnableKeys = 0xFEF9 XK_Pointer_Accelerate = 0xFEFA XK_Pointer_DfltBtnNext = 0xFEFB XK_Pointer_DfltBtnPrev = 0xFEFC python-xlib-0.14+20091101/Xlib/keysymdef/latin2.py0000644000175000017500000000206310201300703017756 0ustar stewstewXK_Aogonek = 0x1a1 XK_breve = 0x1a2 XK_Lstroke = 0x1a3 XK_Lcaron = 0x1a5 XK_Sacute = 0x1a6 XK_Scaron = 0x1a9 XK_Scedilla = 0x1aa XK_Tcaron = 0x1ab XK_Zacute = 0x1ac XK_Zcaron = 0x1ae XK_Zabovedot = 0x1af XK_aogonek = 0x1b1 XK_ogonek = 0x1b2 XK_lstroke = 0x1b3 XK_lcaron = 0x1b5 XK_sacute = 0x1b6 XK_caron = 0x1b7 XK_scaron = 0x1b9 XK_scedilla = 0x1ba XK_tcaron = 0x1bb XK_zacute = 0x1bc XK_doubleacute = 0x1bd XK_zcaron = 0x1be XK_zabovedot = 0x1bf XK_Racute = 0x1c0 XK_Abreve = 0x1c3 XK_Lacute = 0x1c5 XK_Cacute = 0x1c6 XK_Ccaron = 0x1c8 XK_Eogonek = 0x1ca XK_Ecaron = 0x1cc XK_Dcaron = 0x1cf XK_Dstroke = 0x1d0 XK_Nacute = 0x1d1 XK_Ncaron = 0x1d2 XK_Odoubleacute = 0x1d5 XK_Rcaron = 0x1d8 XK_Uring = 0x1d9 XK_Udoubleacute = 0x1db XK_Tcedilla = 0x1de XK_racute = 0x1e0 XK_abreve = 0x1e3 XK_lacute = 0x1e5 XK_cacute = 0x1e6 XK_ccaron = 0x1e8 XK_eogonek = 0x1ea XK_ecaron = 0x1ec XK_dcaron = 0x1ef XK_dstroke = 0x1f0 XK_nacute = 0x1f1 XK_ncaron = 0x1f2 XK_odoubleacute = 0x1f5 XK_udoubleacute = 0x1fb XK_rcaron = 0x1f8 XK_uring = 0x1f9 XK_tcedilla = 0x1fe XK_abovedot = 0x1ff python-xlib-0.14+20091101/Xlib/keysymdef/publishing.py0000644000175000017500000000367110201300703020737 0ustar stewstewXK_emspace = 0xaa1 XK_enspace = 0xaa2 XK_em3space = 0xaa3 XK_em4space = 0xaa4 XK_digitspace = 0xaa5 XK_punctspace = 0xaa6 XK_thinspace = 0xaa7 XK_hairspace = 0xaa8 XK_emdash = 0xaa9 XK_endash = 0xaaa XK_signifblank = 0xaac XK_ellipsis = 0xaae XK_doubbaselinedot = 0xaaf XK_onethird = 0xab0 XK_twothirds = 0xab1 XK_onefifth = 0xab2 XK_twofifths = 0xab3 XK_threefifths = 0xab4 XK_fourfifths = 0xab5 XK_onesixth = 0xab6 XK_fivesixths = 0xab7 XK_careof = 0xab8 XK_figdash = 0xabb XK_leftanglebracket = 0xabc XK_decimalpoint = 0xabd XK_rightanglebracket = 0xabe XK_marker = 0xabf XK_oneeighth = 0xac3 XK_threeeighths = 0xac4 XK_fiveeighths = 0xac5 XK_seveneighths = 0xac6 XK_trademark = 0xac9 XK_signaturemark = 0xaca XK_trademarkincircle = 0xacb XK_leftopentriangle = 0xacc XK_rightopentriangle = 0xacd XK_emopencircle = 0xace XK_emopenrectangle = 0xacf XK_leftsinglequotemark = 0xad0 XK_rightsinglequotemark = 0xad1 XK_leftdoublequotemark = 0xad2 XK_rightdoublequotemark = 0xad3 XK_prescription = 0xad4 XK_minutes = 0xad6 XK_seconds = 0xad7 XK_latincross = 0xad9 XK_hexagram = 0xada XK_filledrectbullet = 0xadb XK_filledlefttribullet = 0xadc XK_filledrighttribullet = 0xadd XK_emfilledcircle = 0xade XK_emfilledrect = 0xadf XK_enopencircbullet = 0xae0 XK_enopensquarebullet = 0xae1 XK_openrectbullet = 0xae2 XK_opentribulletup = 0xae3 XK_opentribulletdown = 0xae4 XK_openstar = 0xae5 XK_enfilledcircbullet = 0xae6 XK_enfilledsqbullet = 0xae7 XK_filledtribulletup = 0xae8 XK_filledtribulletdown = 0xae9 XK_leftpointer = 0xaea XK_rightpointer = 0xaeb XK_club = 0xaec XK_diamond = 0xaed XK_heart = 0xaee XK_maltesecross = 0xaf0 XK_dagger = 0xaf1 XK_doubledagger = 0xaf2 XK_checkmark = 0xaf3 XK_ballotcross = 0xaf4 XK_musicalsharp = 0xaf5 XK_musicalflat = 0xaf6 XK_malesymbol = 0xaf7 XK_femalesymbol = 0xaf8 XK_telephone = 0xaf9 XK_telephonerecorder = 0xafa XK_phonographcopyright = 0xafb XK_caret = 0xafc XK_singlelowquotemark = 0xafd XK_doublelowquotemark = 0xafe XK_cursor = 0xaff python-xlib-0.14+20091101/Xlib/keysymdef/korean.py0000644000175000017500000000545410201300703020053 0ustar stewstewXK_Hangul = 0xff31 XK_Hangul_Start = 0xff32 XK_Hangul_End = 0xff33 XK_Hangul_Hanja = 0xff34 XK_Hangul_Jamo = 0xff35 XK_Hangul_Romaja = 0xff36 XK_Hangul_Codeinput = 0xff37 XK_Hangul_Jeonja = 0xff38 XK_Hangul_Banja = 0xff39 XK_Hangul_PreHanja = 0xff3a XK_Hangul_PostHanja = 0xff3b XK_Hangul_SingleCandidate = 0xff3c XK_Hangul_MultipleCandidate = 0xff3d XK_Hangul_PreviousCandidate = 0xff3e XK_Hangul_Special = 0xff3f XK_Hangul_switch = 0xFF7E XK_Hangul_Kiyeog = 0xea1 XK_Hangul_SsangKiyeog = 0xea2 XK_Hangul_KiyeogSios = 0xea3 XK_Hangul_Nieun = 0xea4 XK_Hangul_NieunJieuj = 0xea5 XK_Hangul_NieunHieuh = 0xea6 XK_Hangul_Dikeud = 0xea7 XK_Hangul_SsangDikeud = 0xea8 XK_Hangul_Rieul = 0xea9 XK_Hangul_RieulKiyeog = 0xeaa XK_Hangul_RieulMieum = 0xeab XK_Hangul_RieulPieub = 0xeac XK_Hangul_RieulSios = 0xead XK_Hangul_RieulTieut = 0xeae XK_Hangul_RieulPhieuf = 0xeaf XK_Hangul_RieulHieuh = 0xeb0 XK_Hangul_Mieum = 0xeb1 XK_Hangul_Pieub = 0xeb2 XK_Hangul_SsangPieub = 0xeb3 XK_Hangul_PieubSios = 0xeb4 XK_Hangul_Sios = 0xeb5 XK_Hangul_SsangSios = 0xeb6 XK_Hangul_Ieung = 0xeb7 XK_Hangul_Jieuj = 0xeb8 XK_Hangul_SsangJieuj = 0xeb9 XK_Hangul_Cieuc = 0xeba XK_Hangul_Khieuq = 0xebb XK_Hangul_Tieut = 0xebc XK_Hangul_Phieuf = 0xebd XK_Hangul_Hieuh = 0xebe XK_Hangul_A = 0xebf XK_Hangul_AE = 0xec0 XK_Hangul_YA = 0xec1 XK_Hangul_YAE = 0xec2 XK_Hangul_EO = 0xec3 XK_Hangul_E = 0xec4 XK_Hangul_YEO = 0xec5 XK_Hangul_YE = 0xec6 XK_Hangul_O = 0xec7 XK_Hangul_WA = 0xec8 XK_Hangul_WAE = 0xec9 XK_Hangul_OE = 0xeca XK_Hangul_YO = 0xecb XK_Hangul_U = 0xecc XK_Hangul_WEO = 0xecd XK_Hangul_WE = 0xece XK_Hangul_WI = 0xecf XK_Hangul_YU = 0xed0 XK_Hangul_EU = 0xed1 XK_Hangul_YI = 0xed2 XK_Hangul_I = 0xed3 XK_Hangul_J_Kiyeog = 0xed4 XK_Hangul_J_SsangKiyeog = 0xed5 XK_Hangul_J_KiyeogSios = 0xed6 XK_Hangul_J_Nieun = 0xed7 XK_Hangul_J_NieunJieuj = 0xed8 XK_Hangul_J_NieunHieuh = 0xed9 XK_Hangul_J_Dikeud = 0xeda XK_Hangul_J_Rieul = 0xedb XK_Hangul_J_RieulKiyeog = 0xedc XK_Hangul_J_RieulMieum = 0xedd XK_Hangul_J_RieulPieub = 0xede XK_Hangul_J_RieulSios = 0xedf XK_Hangul_J_RieulTieut = 0xee0 XK_Hangul_J_RieulPhieuf = 0xee1 XK_Hangul_J_RieulHieuh = 0xee2 XK_Hangul_J_Mieum = 0xee3 XK_Hangul_J_Pieub = 0xee4 XK_Hangul_J_PieubSios = 0xee5 XK_Hangul_J_Sios = 0xee6 XK_Hangul_J_SsangSios = 0xee7 XK_Hangul_J_Ieung = 0xee8 XK_Hangul_J_Jieuj = 0xee9 XK_Hangul_J_Cieuc = 0xeea XK_Hangul_J_Khieuq = 0xeeb XK_Hangul_J_Tieut = 0xeec XK_Hangul_J_Phieuf = 0xeed XK_Hangul_J_Hieuh = 0xeee XK_Hangul_RieulYeorinHieuh = 0xeef XK_Hangul_SunkyeongeumMieum = 0xef0 XK_Hangul_SunkyeongeumPieub = 0xef1 XK_Hangul_PanSios = 0xef2 XK_Hangul_KkogjiDalrinIeung = 0xef3 XK_Hangul_SunkyeongeumPhieuf = 0xef4 XK_Hangul_YeorinHieuh = 0xef5 XK_Hangul_AraeA = 0xef6 XK_Hangul_AraeAE = 0xef7 XK_Hangul_J_PanSios = 0xef8 XK_Hangul_J_KkogjiDalrinIeung = 0xef9 XK_Hangul_J_YeorinHieuh = 0xefa XK_Korean_Won = 0xeff python-xlib-0.14+20091101/Xlib/keysymdef/thai.py0000644000175000017500000000372410201300703017517 0ustar stewstewXK_Thai_kokai = 0xda1 XK_Thai_khokhai = 0xda2 XK_Thai_khokhuat = 0xda3 XK_Thai_khokhwai = 0xda4 XK_Thai_khokhon = 0xda5 XK_Thai_khorakhang = 0xda6 XK_Thai_ngongu = 0xda7 XK_Thai_chochan = 0xda8 XK_Thai_choching = 0xda9 XK_Thai_chochang = 0xdaa XK_Thai_soso = 0xdab XK_Thai_chochoe = 0xdac XK_Thai_yoying = 0xdad XK_Thai_dochada = 0xdae XK_Thai_topatak = 0xdaf XK_Thai_thothan = 0xdb0 XK_Thai_thonangmontho = 0xdb1 XK_Thai_thophuthao = 0xdb2 XK_Thai_nonen = 0xdb3 XK_Thai_dodek = 0xdb4 XK_Thai_totao = 0xdb5 XK_Thai_thothung = 0xdb6 XK_Thai_thothahan = 0xdb7 XK_Thai_thothong = 0xdb8 XK_Thai_nonu = 0xdb9 XK_Thai_bobaimai = 0xdba XK_Thai_popla = 0xdbb XK_Thai_phophung = 0xdbc XK_Thai_fofa = 0xdbd XK_Thai_phophan = 0xdbe XK_Thai_fofan = 0xdbf XK_Thai_phosamphao = 0xdc0 XK_Thai_moma = 0xdc1 XK_Thai_yoyak = 0xdc2 XK_Thai_rorua = 0xdc3 XK_Thai_ru = 0xdc4 XK_Thai_loling = 0xdc5 XK_Thai_lu = 0xdc6 XK_Thai_wowaen = 0xdc7 XK_Thai_sosala = 0xdc8 XK_Thai_sorusi = 0xdc9 XK_Thai_sosua = 0xdca XK_Thai_hohip = 0xdcb XK_Thai_lochula = 0xdcc XK_Thai_oang = 0xdcd XK_Thai_honokhuk = 0xdce XK_Thai_paiyannoi = 0xdcf XK_Thai_saraa = 0xdd0 XK_Thai_maihanakat = 0xdd1 XK_Thai_saraaa = 0xdd2 XK_Thai_saraam = 0xdd3 XK_Thai_sarai = 0xdd4 XK_Thai_saraii = 0xdd5 XK_Thai_saraue = 0xdd6 XK_Thai_sarauee = 0xdd7 XK_Thai_sarau = 0xdd8 XK_Thai_sarauu = 0xdd9 XK_Thai_phinthu = 0xdda XK_Thai_maihanakat_maitho = 0xdde XK_Thai_baht = 0xddf XK_Thai_sarae = 0xde0 XK_Thai_saraae = 0xde1 XK_Thai_sarao = 0xde2 XK_Thai_saraaimaimuan = 0xde3 XK_Thai_saraaimaimalai = 0xde4 XK_Thai_lakkhangyao = 0xde5 XK_Thai_maiyamok = 0xde6 XK_Thai_maitaikhu = 0xde7 XK_Thai_maiek = 0xde8 XK_Thai_maitho = 0xde9 XK_Thai_maitri = 0xdea XK_Thai_maichattawa = 0xdeb XK_Thai_thanthakhat = 0xdec XK_Thai_nikhahit = 0xded XK_Thai_leksun = 0xdf0 XK_Thai_leknung = 0xdf1 XK_Thai_leksong = 0xdf2 XK_Thai_leksam = 0xdf3 XK_Thai_leksi = 0xdf4 XK_Thai_lekha = 0xdf5 XK_Thai_lekhok = 0xdf6 XK_Thai_lekchet = 0xdf7 XK_Thai_lekpaet = 0xdf8 XK_Thai_lekkao = 0xdf9 python-xlib-0.14+20091101/Xlib/keysymdef/latin1.py0000644000175000017500000000654210201300703017763 0ustar stewstewXK_space = 0x020 XK_exclam = 0x021 XK_quotedbl = 0x022 XK_numbersign = 0x023 XK_dollar = 0x024 XK_percent = 0x025 XK_ampersand = 0x026 XK_apostrophe = 0x027 XK_quoteright = 0x027 XK_parenleft = 0x028 XK_parenright = 0x029 XK_asterisk = 0x02a XK_plus = 0x02b XK_comma = 0x02c XK_minus = 0x02d XK_period = 0x02e XK_slash = 0x02f XK_0 = 0x030 XK_1 = 0x031 XK_2 = 0x032 XK_3 = 0x033 XK_4 = 0x034 XK_5 = 0x035 XK_6 = 0x036 XK_7 = 0x037 XK_8 = 0x038 XK_9 = 0x039 XK_colon = 0x03a XK_semicolon = 0x03b XK_less = 0x03c XK_equal = 0x03d XK_greater = 0x03e XK_question = 0x03f XK_at = 0x040 XK_A = 0x041 XK_B = 0x042 XK_C = 0x043 XK_D = 0x044 XK_E = 0x045 XK_F = 0x046 XK_G = 0x047 XK_H = 0x048 XK_I = 0x049 XK_J = 0x04a XK_K = 0x04b XK_L = 0x04c XK_M = 0x04d XK_N = 0x04e XK_O = 0x04f XK_P = 0x050 XK_Q = 0x051 XK_R = 0x052 XK_S = 0x053 XK_T = 0x054 XK_U = 0x055 XK_V = 0x056 XK_W = 0x057 XK_X = 0x058 XK_Y = 0x059 XK_Z = 0x05a XK_bracketleft = 0x05b XK_backslash = 0x05c XK_bracketright = 0x05d XK_asciicircum = 0x05e XK_underscore = 0x05f XK_grave = 0x060 XK_quoteleft = 0x060 XK_a = 0x061 XK_b = 0x062 XK_c = 0x063 XK_d = 0x064 XK_e = 0x065 XK_f = 0x066 XK_g = 0x067 XK_h = 0x068 XK_i = 0x069 XK_j = 0x06a XK_k = 0x06b XK_l = 0x06c XK_m = 0x06d XK_n = 0x06e XK_o = 0x06f XK_p = 0x070 XK_q = 0x071 XK_r = 0x072 XK_s = 0x073 XK_t = 0x074 XK_u = 0x075 XK_v = 0x076 XK_w = 0x077 XK_x = 0x078 XK_y = 0x079 XK_z = 0x07a XK_braceleft = 0x07b XK_bar = 0x07c XK_braceright = 0x07d XK_asciitilde = 0x07e XK_nobreakspace = 0x0a0 XK_exclamdown = 0x0a1 XK_cent = 0x0a2 XK_sterling = 0x0a3 XK_currency = 0x0a4 XK_yen = 0x0a5 XK_brokenbar = 0x0a6 XK_section = 0x0a7 XK_diaeresis = 0x0a8 XK_copyright = 0x0a9 XK_ordfeminine = 0x0aa XK_guillemotleft = 0x0ab XK_notsign = 0x0ac XK_hyphen = 0x0ad XK_registered = 0x0ae XK_macron = 0x0af XK_degree = 0x0b0 XK_plusminus = 0x0b1 XK_twosuperior = 0x0b2 XK_threesuperior = 0x0b3 XK_acute = 0x0b4 XK_mu = 0x0b5 XK_paragraph = 0x0b6 XK_periodcentered = 0x0b7 XK_cedilla = 0x0b8 XK_onesuperior = 0x0b9 XK_masculine = 0x0ba XK_guillemotright = 0x0bb XK_onequarter = 0x0bc XK_onehalf = 0x0bd XK_threequarters = 0x0be XK_questiondown = 0x0bf XK_Agrave = 0x0c0 XK_Aacute = 0x0c1 XK_Acircumflex = 0x0c2 XK_Atilde = 0x0c3 XK_Adiaeresis = 0x0c4 XK_Aring = 0x0c5 XK_AE = 0x0c6 XK_Ccedilla = 0x0c7 XK_Egrave = 0x0c8 XK_Eacute = 0x0c9 XK_Ecircumflex = 0x0ca XK_Ediaeresis = 0x0cb XK_Igrave = 0x0cc XK_Iacute = 0x0cd XK_Icircumflex = 0x0ce XK_Idiaeresis = 0x0cf XK_ETH = 0x0d0 XK_Eth = 0x0d0 XK_Ntilde = 0x0d1 XK_Ograve = 0x0d2 XK_Oacute = 0x0d3 XK_Ocircumflex = 0x0d4 XK_Otilde = 0x0d5 XK_Odiaeresis = 0x0d6 XK_multiply = 0x0d7 XK_Ooblique = 0x0d8 XK_Ugrave = 0x0d9 XK_Uacute = 0x0da XK_Ucircumflex = 0x0db XK_Udiaeresis = 0x0dc XK_Yacute = 0x0dd XK_THORN = 0x0de XK_Thorn = 0x0de XK_ssharp = 0x0df XK_agrave = 0x0e0 XK_aacute = 0x0e1 XK_acircumflex = 0x0e2 XK_atilde = 0x0e3 XK_adiaeresis = 0x0e4 XK_aring = 0x0e5 XK_ae = 0x0e6 XK_ccedilla = 0x0e7 XK_egrave = 0x0e8 XK_eacute = 0x0e9 XK_ecircumflex = 0x0ea XK_ediaeresis = 0x0eb XK_igrave = 0x0ec XK_iacute = 0x0ed XK_icircumflex = 0x0ee XK_idiaeresis = 0x0ef XK_eth = 0x0f0 XK_ntilde = 0x0f1 XK_ograve = 0x0f2 XK_oacute = 0x0f3 XK_ocircumflex = 0x0f4 XK_otilde = 0x0f5 XK_odiaeresis = 0x0f6 XK_division = 0x0f7 XK_oslash = 0x0f8 XK_ugrave = 0x0f9 XK_uacute = 0x0fa XK_ucircumflex = 0x0fb XK_udiaeresis = 0x0fc XK_yacute = 0x0fd XK_thorn = 0x0fe XK_ydiaeresis = 0x0ff python-xlib-0.14+20091101/Xlib/keysymdef/xf86.py0000644000175000017500000001350711127230246017401 0ustar stewstewXK_XF86_MonBrightnessUp = 0x1008FF02 XK_XF86_MonBrightnessDown = 0x1008FF03 XK_XF86_KbdLightOnOff = 0x1008FF04 XK_XF86_KbdBrightnessUp = 0x1008FF05 XK_XF86_KbdBrightnessDown = 0x1008FF06 XK_XF86_Standby = 0x1008FF10 XK_XF86_AudioLowerVolume = 0x1008FF11 XK_XF86_AudioMute = 0x1008FF12 XK_XF86_AudioRaiseVolume = 0x1008FF13 XK_XF86_AudioPlay = 0x1008FF14 XK_XF86_AudioStop = 0x1008FF15 XK_XF86_AudioPrev = 0x1008FF16 XK_XF86_AudioNext = 0x1008FF17 XK_XF86_HomePage = 0x1008FF18 XK_XF86_Mail = 0x1008FF19 XK_XF86_Start = 0x1008FF1A XK_XF86_Search = 0x1008FF1B XK_XF86_AudioRecord = 0x1008FF1C XK_XF86_Calculator = 0x1008FF1D XK_XF86_Memo = 0x1008FF1E XK_XF86_ToDoList = 0x1008FF1F XK_XF86_Calendar = 0x1008FF20 XK_XF86_PowerDown = 0x1008FF21 XK_XF86_ContrastAdjust = 0x1008FF22 XK_XF86_RockerUp = 0x1008FF23 XK_XF86_RockerDown = 0x1008FF24 XK_XF86_RockerEnter = 0x1008FF25 XK_XF86_Back = 0x1008FF26 XK_XF86_Forward = 0x1008FF27 XK_XF86_Stop = 0x1008FF28 XK_XF86_Refresh = 0x1008FF29 XK_XF86_PowerOff = 0x1008FF2A XK_XF86_WakeUp = 0x1008FF2B XK_XF86_Eject = 0x1008FF2C XK_XF86_ScreenSaver = 0x1008FF2D XK_XF86_WWW = 0x1008FF2E XK_XF86_Sleep = 0x1008FF2F XK_XF86_Favorites = 0x1008FF30 XK_XF86_AudioPause = 0x1008FF31 XK_XF86_AudioMedia = 0x1008FF32 XK_XF86_MyComputer = 0x1008FF33 XK_XF86_VendorHome = 0x1008FF34 XK_XF86_LightBulb = 0x1008FF35 XK_XF86_Shop = 0x1008FF36 XK_XF86_History = 0x1008FF37 XK_XF86_OpenURL = 0x1008FF38 XK_XF86_AddFavorite = 0x1008FF39 XK_XF86_HotLinks = 0x1008FF3A XK_XF86_BrightnessAdjust = 0x1008FF3B XK_XF86_Finance = 0x1008FF3C XK_XF86_Community = 0x1008FF3D XK_XF86_AudioRewind = 0x1008FF3E XK_XF86_XF86BackForward = 0x1008FF3F XK_XF86_Launch0 = 0x1008FF40 XK_XF86_Launch1 = 0x1008FF41 XK_XF86_Launch2 = 0x1008FF42 XK_XF86_Launch3 = 0x1008FF43 XK_XF86_Launch4 = 0x1008FF44 XK_XF86_Launch5 = 0x1008FF45 XK_XF86_Launch6 = 0x1008FF46 XK_XF86_Launch7 = 0x1008FF47 XK_XF86_Launch8 = 0x1008FF48 XK_XF86_Launch9 = 0x1008FF49 XK_XF86_LaunchA = 0x1008FF4A XK_XF86_LaunchB = 0x1008FF4B XK_XF86_LaunchC = 0x1008FF4C XK_XF86_LaunchD = 0x1008FF4D XK_XF86_LaunchE = 0x1008FF4E XK_XF86_LaunchF = 0x1008FF4F XK_XF86_ApplicationLeft = 0x1008FF50 XK_XF86_ApplicationRight = 0x1008FF51 XK_XF86_Book = 0x1008FF52 XK_XF86_CD = 0x1008FF53 XK_XF86_Calculater = 0x1008FF54 XK_XF86_Clear = 0x1008FF55 XK_XF86_Close = 0x1008FF56 XK_XF86_Copy = 0x1008FF57 XK_XF86_Cut = 0x1008FF58 XK_XF86_Display = 0x1008FF59 XK_XF86_DOS = 0x1008FF5A XK_XF86_Documents = 0x1008FF5B XK_XF86_Excel = 0x1008FF5C XK_XF86_Explorer = 0x1008FF5D XK_XF86_Game = 0x1008FF5E XK_XF86_Go = 0x1008FF5F XK_XF86_iTouch = 0x1008FF60 XK_XF86_LogOff = 0x1008FF61 XK_XF86_Market = 0x1008FF62 XK_XF86_Meeting = 0x1008FF63 XK_XF86_MenuKB = 0x1008FF65 XK_XF86_MenuPB = 0x1008FF66 XK_XF86_MySites = 0x1008FF67 XK_XF86_New = 0x1008FF68 XK_XF86_News = 0x1008FF69 XK_XF86_OfficeHome = 0x1008FF6A XK_XF86_Open = 0x1008FF6B XK_XF86_Option = 0x1008FF6C XK_XF86_Paste = 0x1008FF6D XK_XF86_Phone = 0x1008FF6E XK_XF86_Q = 0x1008FF70 XK_XF86_Reply = 0x1008FF72 XK_XF86_Reload = 0x1008FF73 XK_XF86_RotateWindows = 0x1008FF74 XK_XF86_RotationPB = 0x1008FF75 XK_XF86_RotationKB = 0x1008FF76 XK_XF86_Save = 0x1008FF77 XK_XF86_ScrollUp = 0x1008FF78 XK_XF86_ScrollDown = 0x1008FF79 XK_XF86_ScrollClick = 0x1008FF7A XK_XF86_Send = 0x1008FF7B XK_XF86_Spell = 0x1008FF7C XK_XF86_SplitScreen = 0x1008FF7D XK_XF86_Support = 0x1008FF7E XK_XF86_TaskPane = 0x1008FF7F XK_XF86_Terminal = 0x1008FF80 XK_XF86_Tools = 0x1008FF81 XK_XF86_Travel = 0x1008FF82 XK_XF86_UserPB = 0x1008FF84 XK_XF86_User1KB = 0x1008FF85 XK_XF86_User2KB = 0x1008FF86 XK_XF86_Video = 0x1008FF87 XK_XF86_WheelButton = 0x1008FF88 XK_XF86_Word = 0x1008FF89 XK_XF86_Xfer = 0x1008FF8A XK_XF86_ZoomIn = 0x1008FF8B XK_XF86_ZoomOut = 0x1008FF8C XK_XF86_Away = 0x1008FF8D XK_XF86_Messenger = 0x1008FF8E XK_XF86_WebCam = 0x1008FF8F XK_XF86_MailForward = 0x1008FF90 XK_XF86_Pictures = 0x1008FF91 XK_XF86_Music = 0x1008FF92 XK_XF86_Battery = 0x1008FF93 XK_XF86_Bluetooth = 0x1008FF94 XK_XF86_WLAN = 0x1008FF95 XK_XF86_UWB = 0x1008FF96 XK_XF86_AudioForward = 0x1008FF97 XK_XF86_AudioRepeat = 0x1008FF98 XK_XF86_AudioRandomPlay = 0x1008FF99 XK_XF86_Subtitle = 0x1008FF9A XK_XF86_AudioCycleTrack = 0x1008FF9B XK_XF86_CycleAngle = 0x1008FF9C XK_XF86_FrameBack = 0x1008FF9D XK_XF86_FrameForward = 0x1008FF9E XK_XF86_Time = 0x1008FF9F XK_XF86_Select = 0x1008FFA0 XK_XF86_View = 0x1008FFA1 XK_XF86_TopMenu = 0x1008FFA2 XK_XF86_Red = 0x1008FFA3 XK_XF86_Green = 0x1008FFA4 XK_XF86_Yellow = 0x1008FFA5 XK_XF86_Blue = 0x1008FFA6 XK_XF86_Switch_VT_1 = 0x1008FE01 XK_XF86_Switch_VT_2 = 0x1008FE02 XK_XF86_Switch_VT_3 = 0x1008FE03 XK_XF86_Switch_VT_4 = 0x1008FE04 XK_XF86_Switch_VT_5 = 0x1008FE05 XK_XF86_Switch_VT_6 = 0x1008FE06 XK_XF86_Switch_VT_7 = 0x1008FE07 XK_XF86_Switch_VT_8 = 0x1008FE08 XK_XF86_Switch_VT_9 = 0x1008FE09 XK_XF86_Switch_VT_10 = 0x1008FE0A XK_XF86_Switch_VT_11 = 0x1008FE0B XK_XF86_Switch_VT_12 = 0x1008FE0C XK_XF86_Ungrab = 0x1008FE20 XK_XF86_ClearGrab = 0x1008FE21 XK_XF86_Next_VMode = 0x1008FE22 XK_XF86_Prev_VMode = 0x1008FE23 python-xlib-0.14+20091101/Xlib/keysymdef/miscellany.py0000644000175000017500000000607510201300703020734 0ustar stewstewXK_BackSpace = 0xFF08 XK_Tab = 0xFF09 XK_Linefeed = 0xFF0A XK_Clear = 0xFF0B XK_Return = 0xFF0D XK_Pause = 0xFF13 XK_Scroll_Lock = 0xFF14 XK_Sys_Req = 0xFF15 XK_Escape = 0xFF1B XK_Delete = 0xFFFF XK_Multi_key = 0xFF20 XK_SingleCandidate = 0xFF3C XK_MultipleCandidate = 0xFF3D XK_PreviousCandidate = 0xFF3E XK_Kanji = 0xFF21 XK_Muhenkan = 0xFF22 XK_Henkan_Mode = 0xFF23 XK_Henkan = 0xFF23 XK_Romaji = 0xFF24 XK_Hiragana = 0xFF25 XK_Katakana = 0xFF26 XK_Hiragana_Katakana = 0xFF27 XK_Zenkaku = 0xFF28 XK_Hankaku = 0xFF29 XK_Zenkaku_Hankaku = 0xFF2A XK_Touroku = 0xFF2B XK_Massyo = 0xFF2C XK_Kana_Lock = 0xFF2D XK_Kana_Shift = 0xFF2E XK_Eisu_Shift = 0xFF2F XK_Eisu_toggle = 0xFF30 XK_Zen_Koho = 0xFF3D XK_Mae_Koho = 0xFF3E XK_Home = 0xFF50 XK_Left = 0xFF51 XK_Up = 0xFF52 XK_Right = 0xFF53 XK_Down = 0xFF54 XK_Prior = 0xFF55 XK_Page_Up = 0xFF55 XK_Next = 0xFF56 XK_Page_Down = 0xFF56 XK_End = 0xFF57 XK_Begin = 0xFF58 XK_Select = 0xFF60 XK_Print = 0xFF61 XK_Execute = 0xFF62 XK_Insert = 0xFF63 XK_Undo = 0xFF65 XK_Redo = 0xFF66 XK_Menu = 0xFF67 XK_Find = 0xFF68 XK_Cancel = 0xFF69 XK_Help = 0xFF6A XK_Break = 0xFF6B XK_Mode_switch = 0xFF7E XK_script_switch = 0xFF7E XK_Num_Lock = 0xFF7F XK_KP_Space = 0xFF80 XK_KP_Tab = 0xFF89 XK_KP_Enter = 0xFF8D XK_KP_F1 = 0xFF91 XK_KP_F2 = 0xFF92 XK_KP_F3 = 0xFF93 XK_KP_F4 = 0xFF94 XK_KP_Home = 0xFF95 XK_KP_Left = 0xFF96 XK_KP_Up = 0xFF97 XK_KP_Right = 0xFF98 XK_KP_Down = 0xFF99 XK_KP_Prior = 0xFF9A XK_KP_Page_Up = 0xFF9A XK_KP_Next = 0xFF9B XK_KP_Page_Down = 0xFF9B XK_KP_End = 0xFF9C XK_KP_Begin = 0xFF9D XK_KP_Insert = 0xFF9E XK_KP_Delete = 0xFF9F XK_KP_Equal = 0xFFBD XK_KP_Multiply = 0xFFAA XK_KP_Add = 0xFFAB XK_KP_Separator = 0xFFAC XK_KP_Subtract = 0xFFAD XK_KP_Decimal = 0xFFAE XK_KP_Divide = 0xFFAF XK_KP_0 = 0xFFB0 XK_KP_1 = 0xFFB1 XK_KP_2 = 0xFFB2 XK_KP_3 = 0xFFB3 XK_KP_4 = 0xFFB4 XK_KP_5 = 0xFFB5 XK_KP_6 = 0xFFB6 XK_KP_7 = 0xFFB7 XK_KP_8 = 0xFFB8 XK_KP_9 = 0xFFB9 XK_F1 = 0xFFBE XK_F2 = 0xFFBF XK_F3 = 0xFFC0 XK_F4 = 0xFFC1 XK_F5 = 0xFFC2 XK_F6 = 0xFFC3 XK_F7 = 0xFFC4 XK_F8 = 0xFFC5 XK_F9 = 0xFFC6 XK_F10 = 0xFFC7 XK_F11 = 0xFFC8 XK_L1 = 0xFFC8 XK_F12 = 0xFFC9 XK_L2 = 0xFFC9 XK_F13 = 0xFFCA XK_L3 = 0xFFCA XK_F14 = 0xFFCB XK_L4 = 0xFFCB XK_F15 = 0xFFCC XK_L5 = 0xFFCC XK_F16 = 0xFFCD XK_L6 = 0xFFCD XK_F17 = 0xFFCE XK_L7 = 0xFFCE XK_F18 = 0xFFCF XK_L8 = 0xFFCF XK_F19 = 0xFFD0 XK_L9 = 0xFFD0 XK_F20 = 0xFFD1 XK_L10 = 0xFFD1 XK_F21 = 0xFFD2 XK_R1 = 0xFFD2 XK_F22 = 0xFFD3 XK_R2 = 0xFFD3 XK_F23 = 0xFFD4 XK_R3 = 0xFFD4 XK_F24 = 0xFFD5 XK_R4 = 0xFFD5 XK_F25 = 0xFFD6 XK_R5 = 0xFFD6 XK_F26 = 0xFFD7 XK_R6 = 0xFFD7 XK_F27 = 0xFFD8 XK_R7 = 0xFFD8 XK_F28 = 0xFFD9 XK_R8 = 0xFFD9 XK_F29 = 0xFFDA XK_R9 = 0xFFDA XK_F30 = 0xFFDB XK_R10 = 0xFFDB XK_F31 = 0xFFDC XK_R11 = 0xFFDC XK_F32 = 0xFFDD XK_R12 = 0xFFDD XK_F33 = 0xFFDE XK_R13 = 0xFFDE XK_F34 = 0xFFDF XK_R14 = 0xFFDF XK_F35 = 0xFFE0 XK_R15 = 0xFFE0 XK_Shift_L = 0xFFE1 XK_Shift_R = 0xFFE2 XK_Control_L = 0xFFE3 XK_Control_R = 0xFFE4 XK_Caps_Lock = 0xFFE5 XK_Shift_Lock = 0xFFE6 XK_Meta_L = 0xFFE7 XK_Meta_R = 0xFFE8 XK_Alt_L = 0xFFE9 XK_Alt_R = 0xFFEA XK_Super_L = 0xFFEB XK_Super_R = 0xFFEC XK_Hyper_L = 0xFFED XK_Hyper_R = 0xFFEE python-xlib-0.14+20091101/Xlib/keysymdef/arabic.py0000644000175000017500000000230510201300703020005 0ustar stewstewXK_Arabic_comma = 0x5ac XK_Arabic_semicolon = 0x5bb XK_Arabic_question_mark = 0x5bf XK_Arabic_hamza = 0x5c1 XK_Arabic_maddaonalef = 0x5c2 XK_Arabic_hamzaonalef = 0x5c3 XK_Arabic_hamzaonwaw = 0x5c4 XK_Arabic_hamzaunderalef = 0x5c5 XK_Arabic_hamzaonyeh = 0x5c6 XK_Arabic_alef = 0x5c7 XK_Arabic_beh = 0x5c8 XK_Arabic_tehmarbuta = 0x5c9 XK_Arabic_teh = 0x5ca XK_Arabic_theh = 0x5cb XK_Arabic_jeem = 0x5cc XK_Arabic_hah = 0x5cd XK_Arabic_khah = 0x5ce XK_Arabic_dal = 0x5cf XK_Arabic_thal = 0x5d0 XK_Arabic_ra = 0x5d1 XK_Arabic_zain = 0x5d2 XK_Arabic_seen = 0x5d3 XK_Arabic_sheen = 0x5d4 XK_Arabic_sad = 0x5d5 XK_Arabic_dad = 0x5d6 XK_Arabic_tah = 0x5d7 XK_Arabic_zah = 0x5d8 XK_Arabic_ain = 0x5d9 XK_Arabic_ghain = 0x5da XK_Arabic_tatweel = 0x5e0 XK_Arabic_feh = 0x5e1 XK_Arabic_qaf = 0x5e2 XK_Arabic_kaf = 0x5e3 XK_Arabic_lam = 0x5e4 XK_Arabic_meem = 0x5e5 XK_Arabic_noon = 0x5e6 XK_Arabic_ha = 0x5e7 XK_Arabic_heh = 0x5e7 XK_Arabic_waw = 0x5e8 XK_Arabic_alefmaksura = 0x5e9 XK_Arabic_yeh = 0x5ea XK_Arabic_fathatan = 0x5eb XK_Arabic_dammatan = 0x5ec XK_Arabic_kasratan = 0x5ed XK_Arabic_fatha = 0x5ee XK_Arabic_damma = 0x5ef XK_Arabic_kasra = 0x5f0 XK_Arabic_shadda = 0x5f1 XK_Arabic_sukun = 0x5f2 XK_Arabic_switch = 0xFF7E python-xlib-0.14+20091101/Xlib/keysymdef/hebrew.py0000644000175000017500000000167510201300703020051 0ustar stewstewXK_hebrew_doublelowline = 0xcdf XK_hebrew_aleph = 0xce0 XK_hebrew_bet = 0xce1 XK_hebrew_beth = 0xce1 XK_hebrew_gimel = 0xce2 XK_hebrew_gimmel = 0xce2 XK_hebrew_dalet = 0xce3 XK_hebrew_daleth = 0xce3 XK_hebrew_he = 0xce4 XK_hebrew_waw = 0xce5 XK_hebrew_zain = 0xce6 XK_hebrew_zayin = 0xce6 XK_hebrew_chet = 0xce7 XK_hebrew_het = 0xce7 XK_hebrew_tet = 0xce8 XK_hebrew_teth = 0xce8 XK_hebrew_yod = 0xce9 XK_hebrew_finalkaph = 0xcea XK_hebrew_kaph = 0xceb XK_hebrew_lamed = 0xcec XK_hebrew_finalmem = 0xced XK_hebrew_mem = 0xcee XK_hebrew_finalnun = 0xcef XK_hebrew_nun = 0xcf0 XK_hebrew_samech = 0xcf1 XK_hebrew_samekh = 0xcf1 XK_hebrew_ayin = 0xcf2 XK_hebrew_finalpe = 0xcf3 XK_hebrew_pe = 0xcf4 XK_hebrew_finalzade = 0xcf5 XK_hebrew_finalzadi = 0xcf5 XK_hebrew_zade = 0xcf6 XK_hebrew_zadi = 0xcf6 XK_hebrew_qoph = 0xcf7 XK_hebrew_kuf = 0xcf7 XK_hebrew_resh = 0xcf8 XK_hebrew_shin = 0xcf9 XK_hebrew_taw = 0xcfa XK_hebrew_taf = 0xcfa XK_Hebrew_switch = 0xFF7E python-xlib-0.14+20091101/Xlib/keysymdef/apl.py0000644000175000017500000000056110201300703017342 0ustar stewstewXK_leftcaret = 0xba3 XK_rightcaret = 0xba6 XK_downcaret = 0xba8 XK_upcaret = 0xba9 XK_overbar = 0xbc0 XK_downtack = 0xbc2 XK_upshoe = 0xbc3 XK_downstile = 0xbc4 XK_underbar = 0xbc6 XK_jot = 0xbca XK_quad = 0xbcc XK_uptack = 0xbce XK_circle = 0xbcf XK_upstile = 0xbd3 XK_downshoe = 0xbd6 XK_rightshoe = 0xbd8 XK_leftshoe = 0xbda XK_lefttack = 0xbdc XK_righttack = 0xbfc python-xlib-0.14+20091101/Xlib/keysymdef/cyrillic.py0000644000175000017500000000475410201300703020410 0ustar stewstewXK_Serbian_dje = 0x6a1 XK_Macedonia_gje = 0x6a2 XK_Cyrillic_io = 0x6a3 XK_Ukrainian_ie = 0x6a4 XK_Ukranian_je = 0x6a4 XK_Macedonia_dse = 0x6a5 XK_Ukrainian_i = 0x6a6 XK_Ukranian_i = 0x6a6 XK_Ukrainian_yi = 0x6a7 XK_Ukranian_yi = 0x6a7 XK_Cyrillic_je = 0x6a8 XK_Serbian_je = 0x6a8 XK_Cyrillic_lje = 0x6a9 XK_Serbian_lje = 0x6a9 XK_Cyrillic_nje = 0x6aa XK_Serbian_nje = 0x6aa XK_Serbian_tshe = 0x6ab XK_Macedonia_kje = 0x6ac XK_Byelorussian_shortu = 0x6ae XK_Cyrillic_dzhe = 0x6af XK_Serbian_dze = 0x6af XK_numerosign = 0x6b0 XK_Serbian_DJE = 0x6b1 XK_Macedonia_GJE = 0x6b2 XK_Cyrillic_IO = 0x6b3 XK_Ukrainian_IE = 0x6b4 XK_Ukranian_JE = 0x6b4 XK_Macedonia_DSE = 0x6b5 XK_Ukrainian_I = 0x6b6 XK_Ukranian_I = 0x6b6 XK_Ukrainian_YI = 0x6b7 XK_Ukranian_YI = 0x6b7 XK_Cyrillic_JE = 0x6b8 XK_Serbian_JE = 0x6b8 XK_Cyrillic_LJE = 0x6b9 XK_Serbian_LJE = 0x6b9 XK_Cyrillic_NJE = 0x6ba XK_Serbian_NJE = 0x6ba XK_Serbian_TSHE = 0x6bb XK_Macedonia_KJE = 0x6bc XK_Byelorussian_SHORTU = 0x6be XK_Cyrillic_DZHE = 0x6bf XK_Serbian_DZE = 0x6bf XK_Cyrillic_yu = 0x6c0 XK_Cyrillic_a = 0x6c1 XK_Cyrillic_be = 0x6c2 XK_Cyrillic_tse = 0x6c3 XK_Cyrillic_de = 0x6c4 XK_Cyrillic_ie = 0x6c5 XK_Cyrillic_ef = 0x6c6 XK_Cyrillic_ghe = 0x6c7 XK_Cyrillic_ha = 0x6c8 XK_Cyrillic_i = 0x6c9 XK_Cyrillic_shorti = 0x6ca XK_Cyrillic_ka = 0x6cb XK_Cyrillic_el = 0x6cc XK_Cyrillic_em = 0x6cd XK_Cyrillic_en = 0x6ce XK_Cyrillic_o = 0x6cf XK_Cyrillic_pe = 0x6d0 XK_Cyrillic_ya = 0x6d1 XK_Cyrillic_er = 0x6d2 XK_Cyrillic_es = 0x6d3 XK_Cyrillic_te = 0x6d4 XK_Cyrillic_u = 0x6d5 XK_Cyrillic_zhe = 0x6d6 XK_Cyrillic_ve = 0x6d7 XK_Cyrillic_softsign = 0x6d8 XK_Cyrillic_yeru = 0x6d9 XK_Cyrillic_ze = 0x6da XK_Cyrillic_sha = 0x6db XK_Cyrillic_e = 0x6dc XK_Cyrillic_shcha = 0x6dd XK_Cyrillic_che = 0x6de XK_Cyrillic_hardsign = 0x6df XK_Cyrillic_YU = 0x6e0 XK_Cyrillic_A = 0x6e1 XK_Cyrillic_BE = 0x6e2 XK_Cyrillic_TSE = 0x6e3 XK_Cyrillic_DE = 0x6e4 XK_Cyrillic_IE = 0x6e5 XK_Cyrillic_EF = 0x6e6 XK_Cyrillic_GHE = 0x6e7 XK_Cyrillic_HA = 0x6e8 XK_Cyrillic_I = 0x6e9 XK_Cyrillic_SHORTI = 0x6ea XK_Cyrillic_KA = 0x6eb XK_Cyrillic_EL = 0x6ec XK_Cyrillic_EM = 0x6ed XK_Cyrillic_EN = 0x6ee XK_Cyrillic_O = 0x6ef XK_Cyrillic_PE = 0x6f0 XK_Cyrillic_YA = 0x6f1 XK_Cyrillic_ER = 0x6f2 XK_Cyrillic_ES = 0x6f3 XK_Cyrillic_TE = 0x6f4 XK_Cyrillic_U = 0x6f5 XK_Cyrillic_ZHE = 0x6f6 XK_Cyrillic_VE = 0x6f7 XK_Cyrillic_SOFTSIGN = 0x6f8 XK_Cyrillic_YERU = 0x6f9 XK_Cyrillic_ZE = 0x6fa XK_Cyrillic_SHA = 0x6fb XK_Cyrillic_E = 0x6fc XK_Cyrillic_SHCHA = 0x6fd XK_Cyrillic_CHE = 0x6fe XK_Cyrillic_HARDSIGN = 0x6ff python-xlib-0.14+20091101/Xlib/keysymdef/__init__.py0000644000175000017500000000214411127230246020340 0ustar stewstew# Xlib.keysymdef -- X keysym defs # # Copyright (C) 2001 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __all__ = [ 'apl', 'arabic', 'cyrillic', 'greek', 'hebrew', 'katakana', 'korean', 'latin1', 'latin2', 'latin3', 'latin4', 'miscellany', 'publishing', 'special', 'technical', 'thai', 'xf86', 'xk3270', 'xkb', ] python-xlib-0.14+20091101/Xlib/keysymdef/latin3.py0000644000175000017500000000072110201300703017756 0ustar stewstewXK_Hstroke = 0x2a1 XK_Hcircumflex = 0x2a6 XK_Iabovedot = 0x2a9 XK_Gbreve = 0x2ab XK_Jcircumflex = 0x2ac XK_hstroke = 0x2b1 XK_hcircumflex = 0x2b6 XK_idotless = 0x2b9 XK_gbreve = 0x2bb XK_jcircumflex = 0x2bc XK_Cabovedot = 0x2c5 XK_Ccircumflex = 0x2c6 XK_Gabovedot = 0x2d5 XK_Gcircumflex = 0x2d8 XK_Ubreve = 0x2dd XK_Scircumflex = 0x2de XK_cabovedot = 0x2e5 XK_ccircumflex = 0x2e6 XK_gabovedot = 0x2f5 XK_gcircumflex = 0x2f8 XK_ubreve = 0x2fd XK_scircumflex = 0x2fe python-xlib-0.14+20091101/Xlib/keysymdef/technical.py0000644000175000017500000000226310201300703020521 0ustar stewstewXK_leftradical = 0x8a1 XK_topleftradical = 0x8a2 XK_horizconnector = 0x8a3 XK_topintegral = 0x8a4 XK_botintegral = 0x8a5 XK_vertconnector = 0x8a6 XK_topleftsqbracket = 0x8a7 XK_botleftsqbracket = 0x8a8 XK_toprightsqbracket = 0x8a9 XK_botrightsqbracket = 0x8aa XK_topleftparens = 0x8ab XK_botleftparens = 0x8ac XK_toprightparens = 0x8ad XK_botrightparens = 0x8ae XK_leftmiddlecurlybrace = 0x8af XK_rightmiddlecurlybrace = 0x8b0 XK_topleftsummation = 0x8b1 XK_botleftsummation = 0x8b2 XK_topvertsummationconnector = 0x8b3 XK_botvertsummationconnector = 0x8b4 XK_toprightsummation = 0x8b5 XK_botrightsummation = 0x8b6 XK_rightmiddlesummation = 0x8b7 XK_lessthanequal = 0x8bc XK_notequal = 0x8bd XK_greaterthanequal = 0x8be XK_integral = 0x8bf XK_therefore = 0x8c0 XK_variation = 0x8c1 XK_infinity = 0x8c2 XK_nabla = 0x8c5 XK_approximate = 0x8c8 XK_similarequal = 0x8c9 XK_ifonlyif = 0x8cd XK_implies = 0x8ce XK_identical = 0x8cf XK_radical = 0x8d6 XK_includedin = 0x8da XK_includes = 0x8db XK_intersection = 0x8dc XK_union = 0x8dd XK_logicaland = 0x8de XK_logicalor = 0x8df XK_partialderivative = 0x8ef XK_function = 0x8f6 XK_leftarrow = 0x8fb XK_uparrow = 0x8fc XK_rightarrow = 0x8fd XK_downarrow = 0x8fe python-xlib-0.14+20091101/Xlib/error.py0000644000175000017500000001123510770020473015735 0ustar stewstew# Xlib.error -- basic error classes # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Standard modules import string # Xlib modules import X # Xlib.protocol modules from Xlib.protocol import rq class DisplayError(Exception): def __init__(self, display): self.display = display def __str__(self): return 'Display error "%s"' % self.display class DisplayNameError(DisplayError): def __str__(self): return 'Bad display name "%s"' % self.display class DisplayConnectionError(DisplayError): def __init__(self, display, msg): self.display = display self.msg = msg def __str__(self): return 'Can\'t connect to display "%s": %s' % (self.display, self.msg) class ConnectionClosedError(Exception): def __init__(self, whom): self.whom = whom def __str__(self): return 'Display connection closed by %s' % self.whom class XauthError(Exception): pass class XNoAuthError(Exception): pass class ResourceIDError(Exception): pass class XError(rq.GetAttrData, Exception): _fields = rq.Struct( rq.Card8('type'), # Always 0 rq.Card8('code'), rq.Card16('sequence_number'), rq.Card32('resource_id'), rq.Card16('minor_opcode'), rq.Card8('major_opcode'), rq.Pad(21) ) def __init__(self, display, data): self._data, data = self._fields.parse_binary(data, display, rawdict = 1) def __str__(self): s = [] for f in ('code', 'resource_id', 'sequence_number', 'major_opcode', 'minor_opcode'): s.append('%s = %s' % (f, self._data[f])) return '%s: %s' % (self.__class__, string.join(s, ', ')) class XResourceError(XError): _fields = rq.Struct( rq.Card8('type'), # Always 0 rq.Card8('code'), rq.Card16('sequence_number'), rq.Resource('resource_id'), rq.Card16('minor_opcode'), rq.Card8('major_opcode'), rq.Pad(21) ) class BadRequest(XError): pass class BadValue(XError): pass class BadWindow(XResourceError): pass class BadPixmap(XResourceError): pass class BadAtom(XError): pass class BadCursor(XResourceError): pass class BadFont(XResourceError): pass class BadMatch(XError): pass class BadDrawable(XResourceError): pass class BadAccess(XError): pass class BadAlloc(XError): pass class BadColor(XResourceError): pass class BadGC(XResourceError): pass class BadIDChoice(XResourceError): pass class BadName(XError): pass class BadLength(XError): pass class BadImplementation(XError): pass xerror_class = { X.BadRequest: BadRequest, X.BadValue: BadValue, X.BadWindow: BadWindow, X.BadPixmap: BadPixmap, X.BadAtom: BadAtom, X.BadCursor: BadCursor, X.BadFont: BadFont, X.BadMatch: BadMatch, X.BadDrawable: BadDrawable, X.BadAccess: BadAccess, X.BadAlloc: BadAlloc, X.BadColor: BadColor, X.BadGC: BadGC, X.BadIDChoice: BadIDChoice, X.BadName: BadName, X.BadLength: BadLength, X.BadImplementation: BadImplementation, } class CatchError: def __init__(self, *errors): self.error_types = errors self.error = None self.request = None def __call__(self, error, request): if self.error_types: for etype in self.error_types: if isinstance(error, etype): self.error = error self.request = request return 1 return 0 else: self.error = error self.request = request return 1 def get_error(self): return self.error def get_request(self): return self.request def reset(self): self.error = None self.request = None python-xlib-0.14+20091101/Xlib/__init__.py0000644000175000017500000000223310770020473016341 0ustar stewstew# Xlib.__init__ -- glue for Xlib package # # Copyright (C) 2000-2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __version__ = (0, 14) __version_extra__ = '' __version_string__ = '.'.join(map(str, __version__)) + __version_extra__ __all__ = [ 'X', 'XK', 'Xatom', 'Xcursorfont', 'Xutil', 'display', 'error', 'rdb', # Explicitly exclude threaded, so that it isn't imported by # from Xlib import * ] python-xlib-0.14+20091101/NEWS0000644000175000017500000001615011127230246014032 0ustar stewstew-*-outline-*- NEWS for Python X Library * Version 0.15 ??? ** Composite extension Support for the composite extension, used to implement a composition manager (added for plcm work in plwm). By itself this extension is not very useful, it is intended to be used together with the DAMAGE and XFIXES extensions. Typically you would also need RENDER or glX or some similar method of creating fancy graphics. ** XF86 special function keysyms Keysym definitions for special function keys found on modern keyboards, e.g. raise and lower volume, start specific applications, etc. Have a look in Xlib/keysymdef/xf86.py to see what there are and experiment with xev to see what your keyboard generates. These definitions aren't brought in by default, so you must do this after importing Xlib.XK: Xlib.XK.load_keysym_group('xf86') * Version 0.14 1 Oct 2007 (trialed as 0.14rc1 on 10 Jun 2007) A couple of new extensions, a Python 2.5 fix and a couple of aliases (Display.get_atom() now uses the internal cache and added Window.raise_window()). Tabs converted to spaces (SF id: 1559082). ** RECORD extension (SF id: 1538663) Alex Badea contributed a RECORD extension module, allowing Python Xlib programs to capture mouse and keyboard events (or all other core or extension events) easily. A demo is in the examples directory. See http://refspecs.freestandards.org/X11/recordlib.pdf for more information. ** XINERAMA extension Mike Meyer contributed a Xinerama extension module, allowing Python Xlib programs to interrogate the X server about positions and sizes of multiple screens. Specifications are a bit tricky to find - http://sourceforge.net/projects/xinerama/ has some older specs and the source code of the xorg project (libs & server code) has "definitive" information. ** Python 2.5 fix (SF id: 1623900) Bugfix to correct handling of XAuthority file parsing under Python 2.5 causing failed authentication. * Version 0.13 6 Aug 2006 (trialed as 0.13pre1 on 22 Jul 2006) A small release to incorporate a number of minor corrections and bug fixes, including small changes to keysym handling, .Xauthority parsing, several fixes to sending/receiving/flushing data, addition of WithdrawnState to WMHints. petli completed documentation for Display objects. * Version 0.12 29 Mar 2002 ** SHAPE extension Jeffrey Boser contributed a SHAPE extension module, allowing Python Xlib programs to use shaped windows. Take a look at examples/shapewin.py for ideas on how to use it. For more information on shaped windows, see http://ftp.x.org/pub/R6.6/xc/doc/hardcopy/Xext/shape.PS.gz ** Python 2.2 fix In Python 2.2 FCNTL.FD_CLOEXEC has disappeared and FCNTL on the whole is deprecated, so that had to be dealt with to make the Xlib work with that version. * Version 0.11 23 Feb 2002 ** Regression tests for the protocol definition Regressions tests have been created for all requests, replies and events. The tests use PyUnit, and the old resource database test has been updated to use it too. ** A lot of protocol bugfixes The bugs discovered by the regression tests have been fixed. Additionally, a subtle bug in the core engine which could cause a "can't happen"-error has also been found and fixed. * Version 0.10 16 Dec 2001 ** Event bugfix The xlib failed to parse the type code of events sent from other clients using SendEvent. This has been fixed, adding the field `send_event' to all event objects. ** Event documentation The section "Event Types" in the manual has been written, detailing all event types in the core protocol. The manual is now ten pages thicker. ** Basic support for GetImage/PutImage The Drawable methods put_image() and get_image() have been implemented, but handling image data is still up to the user. There is however, thanks to Ilpo Nyyssönen, a trivial method put_pil_image() that will work on some combinations of image and drawable depth. It's not perfect, but it's a start. * Version 0.9 4 Dec 2001 ** Documentation improved The documentation has been augmented with a chapter about event handling, and a chapter listing all X objects and their methods provided by the library. They are not described in any detail, though. ** Keysym handling improved The module Xlib.XK, which listed all keysyms, have been split up into several sub-modules providing different sets of keysyms. By importing Xlib.XK only the miscellany and latin1 sets are loaded, thus removing some unnecessary clutter. Xlib.display.Display has two new methods (lookup_string() and rebind_string()) for translating keysyms into characters. ** Small changes to library interface The order of the Xlib.display.Display method send_event() parameters event_mask and propagate has changed. Some of the class names in Xlib.protocol.event have changed, to have the same namse as the corresponding. event type constant. ** A few bugfixes If a display has more than one screen, the default screen was always set to the highest numbered one, irrespective of what the user specified in $DISPLAY. Some response attributes in Xlib.protocol.request accidentally included a comma. * Version 0.8 12 Jan 2001 ** Uses distutils Python Xlib now uses distutils to make installation and distribution building easier. ** Tested with Python 2.0 A few incompatibilities with Python 2.0 has been fixed. * Version 0.7 8 Jan 2001 ** Fixed the 64-bit platform fix. As it turns out, the attempted fix for 64-bit platforms in v0.6 didn't really work. Close study of structmodules.c gave the answer why, and now it really should work. Yeah. ** Optimizations of core protocol engine Python Xlib is now at least 25% faster after the core of the protocol engine has been rewritten. This is some quite cute code: tailor-made methods are generated for all structures, resulting in a 650% speed-up in generating binary data, and a 75% speed-up in parsing binary data. Interested Python hackers are recommended to take a look at the Struct class in Xlib/protocol/rq.py. * Version 0.6 29 Dec 2000 ** Fix to make python-xlib work on 64-bytes architectures. The struct and array modules uses sizeof(long) to determine the number of bytes used when representing the type code 'l'. On Intel and VAX, this is 32 bits as expected. On Alpha, it's 64 bits. python-xlib now probes how large each type code is to avoid this problem. * Version 0.5 28 Dec 2000 ** Functions implemented to get and set all ICCCM WM properties on Window objects. ** Keymap cache implemented, with external Xlib.display.Display methods keycode_to_keysym, keysym_to_keycode, keysym_to_keycodes and refresh_keyboard_mapping. ** Two utils for debugging X traffic implemented. utils/tcpbug.py forwards a TCP connection and outputs the communication between the client and the server. This output can then be fed into utils/parsexbug.py, which will output all requests, responses, errors and events in a readable format. * Version 0.4 4 Oct 2000 ** Thread support completed, but not really stresstested yet. ** A framework for handling different platforms has been implemented, together with generic Unix code and some simple VMS code. ** Some documentation has been written. ** The usual bunch of bugfixes. python-xlib-0.14+20091101/examples/0000755000175000017500000000000011273361453015155 5ustar stewstewpython-xlib-0.14+20091101/examples/draw-proto.py0000755000175000017500000001600511170222467017627 0ustar stewstew#!/usr/bin/python # # examples/draw.py -- protocol test application. # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X from Xlib.protocol import display from Xlib.protocol.request import * # Application window (only one) class Window: def __init__(self, display): self.d = display self.objects = [] # Find which screen to open the window on self.screen = self.d.info.roots[self.d.default_screen] # Allocate ids to the window and gc self.window = self.d.allocate_resource_id() self.gc = self.d.allocate_resource_id() # Create a window CreateWindow(self.d, None, self.screen.root_depth, self.window, self.screen.root, 50, 50, 300, 200, 2, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent) # Create a gc for drawing CreateGC(self.d, None, self.gc, self.window, # special attribute values foreground = self.screen.black_pixel, background = self.screen.white_pixel) # Map the window, making it visible MapWindow(self.d, None, self.window) # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) # A drawed objects, consisting of either a single # romboid, or two romboids connected by a winding line class Movement: def __init__(self, win, ev): self.win = win self.left = ev.event_x - 5 self.right = ev.event_x + 5 self.top = ev.event_y - 5 self.bottom = ev.event_y + 5 self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] self.first = Romboid(self.win, ev) self.last = None def motion(self, ev): # Find all the mouse coordinates since the # last event received r = GetMotionEvents(self.win.d, window = self.win.window, start = self.time, stop = ev.time) # Record the previous last coordinate, and append # the new coordinates firstline = len(self.lines) - 1 if r.events: # Discard the first coordinate if that is identical to # the last recorded coordinate pos = r.events[0] if (pos.x, pos.y) == self.lines[-1]: events = r.events[1:] else: events = r.events # Append all coordinates for pos in events: x = pos.x y = pos.y if x < self.left: self.left = x if x > self.right: self.right = x if y < self.top: self.top = y if y > self.bottom: self.bottom = y self.lines.append((x, y)) # Append the event coordinate, if that is different from the # last movement coordinate if (ev.event_x, ev.event_y) != self.lines[-1]: self.lines.append((ev.event_x, ev.event_y)) # Draw a line between the new coordinates PolyLine(self.win.d, None, X.CoordModeOrigin, self.win.window, self.win.gc, self.lines[firstline:]) self.time = ev.time def finish(self, ev): self.motion(ev) if len(self.lines) > 1: self.last = Romboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) self.top = min(ev.event_y - 5, self.top) self.bottom = max(ev.event_y + 5, self.bottom) def expose(self, ev): # We should check if this object is in the exposed # area, but I can't be bothered right now, so just # redraw on the last Expose in every batch if ev.count == 0: self.first.draw() if self.last: # Redraw all the lines PolyLine(self.win.d, None, X.CoordModeOrigin, self.win.window, self.win.gc, self.lines) self.last.draw() # A romboid, drawed around the Movement endpoints class Romboid: def __init__(self, win, ev): self.win = win self.x = ev.event_x self.y = ev.event_y self.draw() def draw(self): # Draw the segments of the romboid PolyLine(self.win.d, None, X.CoordModePrevious, self.win.window, self.win.gc, [(self.x, self.y - 5), (5, 5), (-5, 5), (-5, -5), (5, -5)]) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/examples/record_demo.py0000644000175000017500000000721410770020473020010 0ustar stewstew#!/usr/bin/python # # examples/record_demo.py -- demonstrate record extension # # Copyright (C) 2006 Alex Badea # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Simple demo for the RECORD extension # Not very much unlike the xmacrorec2 program in the xmacro package. import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, XK, display from Xlib.ext import record from Xlib.protocol import rq local_dpy = display.Display() record_dpy = display.Display() def lookup_keysym(keysym): for name in dir(XK): if name[:3] == "XK_" and getattr(XK, name) == keysym: return name[3:] return "[%d]" % keysym def record_callback(reply): if reply.category != record.FromServer: return if reply.client_swapped: print "* received swapped protocol data, cowardly ignored" return if not len(reply.data) or ord(reply.data[0]) < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, record_dpy.display, None, None) if event.type in [X.KeyPress, X.KeyRelease]: pr = event.type == X.KeyPress and "Press" or "Release" keysym = local_dpy.keycode_to_keysym(event.detail, 0) if not keysym: print "KeyCode%s" % pr, event.detail else: print "KeyStr%s" % pr, lookup_keysym(keysym) if event.type == X.KeyPress and keysym == XK.XK_Escape: local_dpy.record_disable_context(ctx) local_dpy.flush() return elif event.type == X.ButtonPress: print "ButtonPress", event.detail elif event.type == X.ButtonRelease: print "ButtonRelease", event.detail elif event.type == X.MotionNotify: print "MotionNotify", event.root_x, event.root_y # Check if the extension is present if not record_dpy.has_extension("RECORD"): print "RECORD extension not found" sys.exit(1) r = record_dpy.record_get_version(0, 0) print "RECORD extension version %d.%d" % (r.major_version, r.minor_version) # Create a recording context; we only want key and mouse events ctx = record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': (X.KeyPress, X.MotionNotify), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime record_dpy.record_enable_context(ctx, record_callback) # Finally free the context record_dpy.record_free_context(ctx) python-xlib-0.14+20091101/examples/draw.py0000755000175000017500000001643311170222467016473 0ustar stewstew#!/usr/bin/python # # examples/draw.py -- high-level xlib test application. # # Copyright (C) 2000 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xutil # Application window (only one) class Window: def __init__(self, display): self.d = display self.objects = [] # Find which screen to open the window on self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: draw.py') self.window.set_wm_icon_name('draw.py') self.window.set_wm_class('draw', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) if e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) # A drawed objects, consisting of either a single # romboid, or two romboids connected by a winding line class Movement: def __init__(self, win, ev): self.win = win self.left = ev.event_x - 5 self.right = ev.event_x + 5 self.top = ev.event_y - 5 self.bottom = ev.event_y + 5 self.time = ev.time self.lines = [(ev.event_x, ev.event_y)] self.first = Romboid(self.win, ev) self.last = None def motion(self, ev): # Find all the mouse coordinates since the # last event received events = self.win.window.get_motion_events(self.time, ev.time) self.time = ev.time # Record the previous last coordinate, and append # the new coordinates firstline = len(self.lines) - 1 if events: # Discard the first coordinate if that is identical to # the last recorded coordinate pos = events[0] if (pos.x, pos.y) == self.lines[-1]: events = events[1:] # Append all coordinates for pos in events: x = pos.x y = pos.y if x < self.left: self.left = x if x > self.right: self.right = x if y < self.top: self.top = y if y > self.bottom: self.bottom = y self.lines.append((x, y)) # Append the event coordinate, if that is different from the # last movement coordinate if (ev.event_x, ev.event_y) != self.lines[-1]: self.lines.append((ev.event_x, ev.event_y)) # Draw a line between the new coordinates self.win.window.poly_line(self.win.gc, X.CoordModeOrigin, self.lines[firstline:]) def finish(self, ev): self.motion(ev) if len(self.lines) > 1: self.last = Romboid(self.win, ev) self.left = min(ev.event_x - 5, self.left) self.right = max(ev.event_x + 5, self.right) self.top = min(ev.event_y - 5, self.top) self.bottom = max(ev.event_y + 5, self.bottom) def expose(self, ev): # We should check if this object is in the exposed # area, but I can't be bothered right now, so just # redraw on the last Expose in every batch if ev.count == 0: self.first.draw() if self.last: # Redraw all the lines self.win.window.poly_line(self.win.gc, X.CoordModeOrigin, self.lines) self.last.draw() # A romboid, drawed around the Movement endpoints class Romboid: def __init__(self, win, ev): self.win = win self.x = ev.event_x self.y = ev.event_y self.draw() def draw(self): # Draw the segments of the romboid self.win.window.poly_line(self.win.gc, X.CoordModePrevious, [(self.x, self.y - 5), (5, 5), (-5, 5), (-5, -5), (5, -5)]) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/examples/xrandr.py0000644000175000017500000001450111211313074017012 0ustar stewstew#!/usr/bin/python # # examples/xrandr.py -- demonstrate the RandR extension # # Copyright (C) 2009 David H. Bronke # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys, os, pprint # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xutil from Xlib.ext import randr # Application window (only one) class Window: def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('RANDR'): sys.stderr.write('%s: server does not have the RANDR extension\n' % sys.argv[0]) print self.d.query_extension('RANDR') sys.stderr.write("\n".join(self.d.list_extensions())) if self.d.query_extension('RANDR') is None: sys.exit(1) # print version r = self.d.xrandr_query_version() print 'RANDR version %d.%d' % (r.major_version, r.minor_version) # Grab the current screen self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: xrandr.py') self.window.set_wm_icon_name('xrandr.py') self.window.set_wm_class('xrandr', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() # Enable all RandR events. self.window.xrandr_select_input( randr.RRScreenChangeNotifyMask | randr.RRCrtcChangeNotifyMask | randr.RROutputChangeNotifyMask | randr.RROutputPropertyNotifyMask ) self.pp = pprint.PrettyPrinter(indent=4) print "Screen info:" self.pp.pprint(self.window.xrandr_get_screen_info()._data) print "Screen size range:" self.pp.pprint(self.window.xrandr_get_screen_size_range()._data) print "Primary output:" self.pp.pprint(self.window.xrandr_get_output_primary()._data) resources = self.window.xrandr_get_screen_resources()._data print "Modes:" for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).iteritems(): print " %d: %s" % (mode_id, mode['name']) for output in resources['outputs']: print "Output %d info:" % (output, ) self.pp.pprint(self.d.xrandr_get_output_info(output, resources['config_timestamp'])._data) for crtc in resources['crtcs']: print "CRTC %d info:" % (crtc, ) self.pp.pprint(self.d.xrandr_get_crtc_info(crtc, resources['config_timestamp'])._data) print "Raw screen resources:" self.pp.pprint(resources) def parseModes(self, mode_names, modes): lastIdx = 0 modedatas = dict() for mode in modes: modedata = dict(mode._data) modedata['name'] = mode_names[lastIdx:lastIdx + modedata['name_length']] modedatas[modedata['id']] = modedata lastIdx += modedata['name_length'] return modedatas # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Screen information has changed elif e.type == self.d.extension_event.ScreenChangeNotify: print 'Screen change' print self.pp.pprint(e._data) # CRTC information has changed elif e.type == self.d.extension_event.CrtcChangeNotify: print 'CRTC change' print self.pp.pprint(e._data) # Output information has changed elif e.type == self.d.extension_event.OutputChangeNotify: print 'Output change' print self.pp.pprint(e._data) # Output property information has changed elif e.type == self.d.extension_event.OutputPropertyNotify: print 'Output property change' print self.pp.pprint(e._data) # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/examples/profilex.py0000755000175000017500000000207710700264510017356 0ustar stewstew#!/usr/bin/python # # Program to generate profiling data. Run with one argument, # the profile stats file to generate. import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xatom import profile def dostuff(): d = display.Display() r = d.screen().root cm = d.screen().default_colormap for i in xrange(0, 1000): if i % 50 == 0: print 'Iteration', i r.delete_property(Xatom.WM_NORMAL_HINTS) r.delete_property(Xatom.WM_NORMAL_HINTS) r.get_geometry() r.get_geometry() r.delete_property(Xatom.WM_NORMAL_HINTS) r.delete_property(Xatom.WM_NORMAL_HINTS) r.change_property(Xatom.WM_NORMAL_HINTS, Xatom.STRING, 32, [1, 2, 3, 4]) r.query_tree() cm.query_colors([0, 1, 2, 3, 4, 5, 6, 7]) def main(filename): profile.run('dostuff()', filename) if __name__ == '__main__': if len(sys.argv) == 2: main(sys.argv[1]) else: print sys.argv[0], "" python-xlib-0.14+20091101/examples/xinerama.py0000644000175000017500000001201111211313074017312 0ustar stewstew#!/usr/bin/python # # examples/xinerama.py -- demonstrate the Xinerama extension # # Copyright (C) 2009 David H. Bronke # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys, os, pprint # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xutil from Xlib.ext import xinerama # Application window (only one) class Window: def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('XINERAMA'): sys.stderr.write('%s: server does not have the XINERAMA extension\n' % sys.argv[0]) print self.d.query_extension('XINERAMA') sys.stderr.write("\n".join(self.d.list_extensions())) if self.d.query_extension('XINERAMA') is None: sys.exit(1) # print version r = self.d.xinerama_query_version() print 'XINERAMA version %d.%d' % (r.major_version, r.minor_version) # Grab the current screen self.screen = self.d.screen() self.window = self.screen.root.create_window( 50, 50, 300, 200, 2, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixel = self.screen.white_pixel, event_mask = (X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask | X.ButtonReleaseMask | X.Button1MotionMask), colormap = X.CopyFromParent, ) self.gc = self.window.create_gc( foreground = self.screen.black_pixel, background = self.screen.white_pixel, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: xinerama.py') self.window.set_wm_icon_name('xinerama.py') self.window.set_wm_class('xinerama', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 20, min_height = 20) # Map the window, making it visible self.window.map() self.pp = pprint.PrettyPrinter(indent=4) print "Xinerama active:", bool(self.d.xinerama_is_active()) print "Screen info:" self.pp.pprint(self.d.xinerama_query_screens()._data) # FIXME: This doesn't work! #print "Xinerama info:" #self.pp.pprint(self.d.xinerama_get_info(self.d.screen().root_visual)._data) print "Xinerama state:" self.pp.pprint(self.window.xinerama_get_state()._data) print "Screen count:" self.pp.pprint(self.window.xinerama_get_screen_count()._data) for screennum in range(self.window.xinerama_get_screen_count().screen_count): print "Screen %d size:" % (screennum, ) self.pp.pprint(self.window.xinerama_get_screen_size(screennum)._data) def parseModes(self, mode_names, modes): lastIdx = 0 modedatas = dict() for mode in modes: modedata = dict(mode._data) modedata['name'] = mode_names[lastIdx:lastIdx + modedata['name_length']] modedatas[modedata['id']] = modedata lastIdx += modedata['name_length'] return modedatas # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/examples/shapewin.py0000755000175000017500000001533510770020473017352 0ustar stewstew#!/usr/bin/python # # examples/shapewin.py -- demonstrate shape extension # # Copyright (C) 2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xutil from Xlib.ext import shape # Application window (only one) class Window: def __init__(self, display): self.d = display # Check for extension if not self.d.has_extension('SHAPE'): sys.stderr.write('%s: server does not have SHAPE extension\n' % sys.argv[1]) sys.exit(1) # print version r = self.d.shape_query_version() print 'SHAPE version %d.%d' % (r.major_version, r.minor_version) # Find which screen to open the window on self.screen = self.d.screen() # background pattern bgsize = 20 bgpm = self.screen.root.create_pixmap(bgsize, bgsize, self.screen.root_depth) bggc = self.screen.root.create_gc(foreground = self.screen.black_pixel, background = self.screen.black_pixel) bgpm.fill_rectangle(bggc, 0, 0, bgsize, bgsize) bggc.change(foreground = self.screen.white_pixel) bgpm.arc(bggc, -bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, -bgsize / 2, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, bgsize / 2, bgsize, bgsize, 0, 360 * 64) # Actual window self.window = self.screen.root.create_window( 100, 100, 400, 300, 0, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixmap = bgpm, event_mask = (X.StructureNotifyMask | X.ButtonReleaseMask), colormap = X.CopyFromParent, ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: shapewin.py') self.window.set_wm_icon_name('shapewin.py') self.window.set_wm_class('shapewin', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints(flags = Xutil.StateHint, initial_state = Xutil.NormalState) self.window.set_wm_normal_hints(flags = (Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width = 50, min_height = 50) # The add and subtract shapes self.add_size = 60 self.add_pm = self.window.create_pixmap(self.add_size, self.add_size, 1) gc = self.add_pm.create_gc(foreground = 0, background = 0) self.add_pm.fill_rectangle(gc, 0, 0, self.add_size, self.add_size) gc.change(foreground = 1) self.add_pm.fill_arc(gc, 0, 0, self.add_size, self.add_size, 0, 360 * 64) gc.free() self.sub_size = 59 self.sub_pm = self.window.create_pixmap(self.sub_size, self.sub_size, 1) gc = self.sub_pm.create_gc(foreground = 0, background = 0) self.sub_pm.fill_rectangle(gc, 0, 0, self.sub_size, self.sub_size) gc.change(foreground = 1) self.sub_pm.fill_poly(gc, X.Convex, X.CoordModeOrigin, [(self.sub_size / 2, 0), (self.sub_size, self.sub_size / 2), (self.sub_size / 2, self.sub_size), (0, self.sub_size / 2)]) gc.free() # Set initial mask self.window.shape_mask(shape.ShapeSet, shape.ShapeBounding, 0, 0, self.add_pm) self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, 400 - self.add_size, 0, self.add_pm) self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, 0, 300 - self.add_size, self.add_pm) self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, 400 - self.add_size, 300 - self.add_size, self.add_pm) # Tell X server to send us mask events self.window.shape_select_input(1) # Map the window, making it visible self.window.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: self.window.shape_mask(shape.ShapeUnion, shape.ShapeBounding, e.event_x - self.add_size / 2, e.event_y - self.add_size / 2, self.add_pm) elif e.detail == 3: self.window.shape_mask(shape.ShapeSubtract, shape.ShapeBounding, e.event_x - self.sub_size / 2, e.event_y - self.sub_size / 2, self.sub_pm) # Shape has changed elif e.type == self.d.extension_event.ShapeNotify: print 'Shape change' # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/examples/threadtest.py0000755000175000017500000000265310770020473017702 0ustar stewstew#!/usr/bin/python import sys import os sys.path[1:1] = [os.path.join(sys.path[0], '..')] from Xlib import display, X, threaded import time import thread def redraw(win, gc): # win.clear_area() win.fill_rectangle(gc, 20, 20, 60, 60) def blink(display, win, gc, cols): while 1: time.sleep(2) print 'Changing color', cols[0] gc.change(foreground = cols[0]) cols = (cols[1], cols[0]) redraw(win, gc) display.flush() def main(): d = display.Display() root = d.screen().root colormap = d.screen().default_colormap red = colormap.alloc_named_color("red").pixel blue = colormap.alloc_named_color("blue").pixel background = colormap.alloc_named_color("white").pixel window = root.create_window(100, 100, 100, 100, 1, X.CopyFromParent, X.InputOutput, X.CopyFromParent, background_pixel = background, event_mask = X.StructureNotifyMask | X.ExposureMask) window.map() gc = window.create_gc(foreground = red) thread.start_new_thread(blink, (d, window, gc, (blue, red))) while 1: event = d.next_event() if event.type == X.Expose: if event.count == 0: redraw(window, gc) elif event.type == X.DestroyNotify: sys.exit(0) if __name__ == "__main__": main() python-xlib-0.14+20091101/examples/childwin.py0000755000175000017500000000745411040733100017325 0ustar stewstew#!/usr/bin/python # # examples/childwin.py -- demonstrate child windows. # # Copyright (C) 2008 David Bronke # Copyright (C) 2002 Peter Liljenberg # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import sys import os # Change path so we find Xlib sys.path.insert(1, os.path.join(sys.path[0], '..')) from Xlib import X, display, Xutil # Application window class Window: def __init__(self, display): self.d = display # Find which screen to open the window on self.screen = self.d.screen() # background pattern bgsize = 20 bgpm = self.screen.root.create_pixmap( bgsize, bgsize, self.screen.root_depth ) bggc = self.screen.root.create_gc( foreground=self.screen.black_pixel, background=self.screen.black_pixel ) bgpm.fill_rectangle(bggc, 0, 0, bgsize, bgsize) bggc.change(foreground=self.screen.white_pixel) bgpm.arc(bggc, -bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, -bgsize / 2, bgsize, bgsize, 0, 360 * 64) bgpm.arc(bggc, 0, bgsize / 2, bgsize, bgsize, 0, 360 * 64) # Actual window self.window = self.screen.root.create_window( 100, 100, 400, 300, 0, self.screen.root_depth, X.InputOutput, X.CopyFromParent, # special attribute values background_pixmap=bgpm, event_mask=( X.StructureNotifyMask | X.ButtonReleaseMask ), colormap=X.CopyFromParent ) # Set some WM info self.WM_DELETE_WINDOW = self.d.intern_atom('WM_DELETE_WINDOW') self.WM_PROTOCOLS = self.d.intern_atom('WM_PROTOCOLS') self.window.set_wm_name('Xlib example: childwin.py') self.window.set_wm_icon_name('childwin.py') self.window.set_wm_class('childwin', 'XlibExample') self.window.set_wm_protocols([self.WM_DELETE_WINDOW]) self.window.set_wm_hints( flags=Xutil.StateHint, initial_state=Xutil.NormalState ) self.window.set_wm_normal_hints( flags=(Xutil.PPosition | Xutil.PSize | Xutil.PMinSize), min_width=50, min_height=50 ) # Map the window, making it visible self.window.map() # Child window (self.childWidth, self.childHeight) = (20, 20) self.childWindow = self.window.create_window( 20, 20, self.childWidth, self.childHeight, 0, self.screen.root_depth, X.CopyFromParent, X.CopyFromParent, # special attribute values background_pixel=self.screen.white_pixel, colormap=X.CopyFromParent, ) self.childWindow.map() # Main loop, handling events def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Button released, add or subtract elif e.type == X.ButtonRelease: if e.detail == 1: print "Moving child window." self.childWindow.configure( x=e.event_x - self.childWidth / 2, y=e.event_y - self.childHeight / 2 ) self.d.flush() # Somebody wants to tell us something elif e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) if __name__ == '__main__': Window(display.Display()).loop() python-xlib-0.14+20091101/COPYING0000644000175000017500000004312707136025553014402 0ustar stewstew GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. python-xlib-0.14+20091101/MANIFEST.in0000644000175000017500000000101107447453025015073 0ustar stewstewinclude MANIFEST.in include README COPYING NEWS TODO global-include .cvsignore recursive-include doc Makefile include doc/src/*.texi include doc/info/python-xlib.info doc/info/python-xlib.info-*[0-9] include doc/html/index.html doc/html/python-xlib_toc.html include doc/html/python-xlib_*.html doc/html/texi2html include doc/ps/python-xlib.ps include utils/tcpbug.py utils/parsexbug.py include examples/draw.py examples/draw-proto.py examples/profilex.py include examples/shapewin.py include examples/threadtest.py python-xlib-0.14+20091101/doc/0000755000175000017500000000000011273361453014104 5ustar stewstewpython-xlib-0.14+20091101/doc/src/0000755000175000017500000000000011273361453014673 5ustar stewstewpython-xlib-0.14+20091101/doc/src/python-xlib.texi0000644000175000017500000001001210770020473020030 0ustar stewstew\input texinfo @c -*-texinfo-*- @c @c %**start of header @setfilename python-xlib.info @settitle The Python X Library @setchapternewpage odd @c %**end of header @ifinfo This file documents the Python X Library. Copyright 2000-2001 Peter Liljenberg Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries a copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Copying'' and ``GNU General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. @end ifinfo @titlepage @title The Python X Library @author Peter Liljenberg @c The following two commands @c start the copyright page. @page @vskip 0pt plus 1filll Copyright @copyright{} 2000--2001 Peter Liljenberg Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Copying'' and ``GNU General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. @end titlepage @contents @node Top @top Introduction The Python X Library is a complete library for writing X Windows client applications in Python. It implements the entire X11R6 protocol and some extensions, and also some supplementary functionality such as a resource database. It is written entirely in Python, and is therefore entirely independent of the traditional C Xlib; it only requires a Python installation with network support. Although the X11R6 protocol is the basis of all X client applications, it is a little too low-level to be useful for writing advanced graphical interfaces. To this end, many different widget sets has been developed, a few of the more popular are Motif, Qt and Gtk. The Python X Library is not compatible with any of these, as they are based on the C Xlib. As a result the Python X Library isn't in itself very useful for writing GUIs, but is eminent for writing small X applications with no advanced GUI, e.g. simple monitor programs, or for that matter more advanced background applications such as window managers. @menu * Basic X Concepts:: The fundamental X Windows concepts. * Package Layout:: The layout of the Python Xlib package. * Connect to a Display:: Connecting to a X server display. * Error Handling:: Handling X errors. * Event Handling:: Handling X events. @c * Xlib and Threads:: Using the Python Xlib in threaded applications. @c * Asynchronicity:: The asynchronous nature of X. * X Objects:: X objects and their operations. @c * Extensions:: Various X protocol extensions. @end menu @include concepts.texi @include package.texi @include connect.texi @include errors.texi @include events.texi @include objects.texi @bye python-xlib-0.14+20091101/doc/src/connect.texi0000644000175000017500000000626710770020473017225 0ustar stewstew@c The Python X Library -- display connection @c @c Copyright 2000 Peter Liljenberg @c @node Connect to a Display @chapter Connect to a Display To be able to perform any X operations, you must first establish a connection to the display. This is done by instantiating a @code{display.Display} object: @deffn Class Display ( [ displayname ] ) Create a connection to the display called @var{displayname}. If @var{displayname} is None or not provided, connect to the default display. If the connection fails for some reason, one of the errors from the following error class tree is raised: @display @group Exception \_error.DisplayError \_error.DisplayNameError \_error.DisplayConnectionError @end group @end display @code{error.DisplayNameError} is raised if @var{displayname}, or the default display name, is malformed. @code{error.DisplayConnectionError} is raised if the connection to the X server fails. This might be caused by the network connection to the display failing, or if the client isn't authorized to connect to the display. @end deffn The syntax of a display name and how the library finds the default display name depends on the operating system where the client runs. @menu * Unix Display Names:: Most Unix-style operating systems. * OpenVMS Display Names:: Digital^H^H^H^H^H^H^HCompaq OpenVMS. @end menu @node Unix Display Names @section Unix Display Names A display name on Unix has the following syntax: @example [hostname]:displayno[.screenno] @end example If @var{hostname} is omitted this refers to a display on the same machine as the client is running on. A Unix socket is used to connect to the display identified by @code{displayno}, which must be an integer from 0 and upwards. If @var{hostname} is specified, it gives the network name or IP-number of the machine to contact. A TCP socket is used, connecting to port 6000+@var{displayno} on @var{hostname}. If the display contains more than one screen, @var{screenno} can be specified to make another screen than 0 the default screen. If the number is larger than the available maximum screen number, it will be set to the maximum. A few examples: @example :0 Display 0 on this host, connects to the Unix socket /tmp/.X11-unix/X0 :0.1 Same as above, but specifying a different default screen myhost:0 Display 0 on myhost, connects to TCP port 6000 myhost:10 Display 10 on myhost, connects to TCP port 6010 localhost:0 Display 0 on localhost, i.e. the same host as the client runs on. Uses a TCP socket, while :0 uses a Unix socket @end example The default display name is stored in the environmental variable @code{DISPLAY}. If that isn't set, @code{error.DisplayNameError} is raised. @node OpenVMS Display Names @section OpenVMS Display Names Currently the X Python Library only supports TCP connections on OpenVMS. Display names are identical to Unix display names, but if the hostname is omitted, @code{localhost} is used. The default display name is hard-coded to @code{localhost:0.0}. In the future, the native DECWindows system should be used. This means using LOCAL or DECNET transports if set, and using the logical name @code{DECW$DISPLAY} as the default display. python-xlib-0.14+20091101/doc/src/errors.texi0000644000175000017500000001101310770020473017071 0ustar stewstew@c The Python X Library -- error handling @c @c Copyright 2000 Peter Liljenberg @c @node Error Handling @chapter Error Handling If an X object method generates an error, it will be handled in one of two different ways depending on the kind of method. Errors are represented by X error objects in the Xlib. If the method @emph{does not} return data, the error will most likely be detected after the method has returned. All methods which does not return data has a parameter called @code{onerror}, which can be used to provide a error handler for any error generated by this method. The error handler is called with to arguments: the error object and the low-level request object. The error @emph{must not} do call any X object methods. If that is necessary, the error handler must store the error away for later retrieval. The class @code{error.CatchError} is provided for this purpose. If no error handler is given when calling a method which generates an error, the error will be passed to the default error handler. If no default error handler is specified, the error is simply printed on @code{sys.stderr}. If the method @emph{does} return data, the error will make it impossible for it to return any valid data. An exception is raised with the error object as the exception value. It is not passed to any error handlers. @menu * X Error Classes:: X error class hierarchy. * CatchError:: Error handler class. @end menu @node X Error Classes @section X Error Classes X errors are structured in the following class hierarchy: @example @group Exception \_ error.XError \_ error.BadRequest \_ error.BadValue \_ error.BadAtom \_ error.BadMatch \_ error.BadAccess \_ error.BadAlloc \_ error.BadName \_ error.BadLength \_ error.BadImplementation \_ error.XResourceError \_ error.BadWindow \_ error.BadPixmap \_ error.BadCursor \_ error.BadFont \_ error.BadDrawable \_ error.BadColor \_ error.BadGC \_ error.BadIDChoice @end group @end example All error objects has the following attributes: @table @code @item code The numeric error code @item sequence_number The sequence number of the failed request @item resource_id The bad resource id. For all the @code{error.XResourceError} this is a X resource object. For the other errors it is an integer, which for some errors might have no meaning @item major_opcode The major opcode for the failed request @item minor_opcode The minor opcode for the failed request. This will be zero for all base X11R6 request, but will be interesting for extension requests @end table @node CatchError @section CatchError @code{error.CatchError} is an object which can be used as an error handler. It collects an error matching any of the specified types, which can be retrieved later. If several errors occur, only the last one is remembered. @deffn Class CatchError ( *errors ) Create a new error handler object. Initialize by providing all error classes you are interested in as arguments. If no error classes are provided at all, this means that all errors will be considered. @end deffn Pass the @code{error.CatchError} object as the @code{onerror} parameter to X object methods. If these methods generated any errors matching the ones specified, it can be retrieved with the following functions: @defmethod CatchError get_error ( ) Return the last error object caught, or None if no matching errors has occured. @end defmethod @defmethod CatchError get_request ( ) Return the request object for the last error caught, or None if no matching errors has occured. @end defmethod @code{error.CatchError} objects can be reused: @defmethod CatchError reset ( ) Forget any caught error. @end defmethod Since the X protocol is mostly asynchronous any error we're watching for might not have been recieved when we call @code{get_error}. To make sure that the request has been processed by the server and any error generated has been received by the Xlib, we must synchronize with the server. An example of using @code{error.CatchError}: @example @group # Resize and the foo window # If it has been destroyed since we looked at it the last time, # reset variable foo to None # Create a error handler for BadWindow errors ec = error.CatchError(error.BadWindow) # Perform the operation foo.configure(width = 100, height = 200, onerror = ec) # Sync communication with server display.sync() # And check if there was any error if ec.get_error(): foo = None @end group @end example python-xlib-0.14+20091101/doc/src/defs0000644000175000017500000000042710770020473015535 0ustar stewstew# Definitions for documentation makefiles SRCDIR = ../src TOPSRC = $(SRCDIR)/python-xlib.texi SRCS = $(TOPSRC) \ $(SRCDIR)/concepts.texi $(SRCDIR)/package.texi \ $(SRCDIR)/connect.texi $(SRCDIR)/errors.texi \ $(SRCDIR)/events.texi $(SRCDIR)/objects.texi python-xlib-0.14+20091101/doc/src/concepts.texi0000644000175000017500000000061010770020473017374 0ustar stewstew@c The Python X Library -- concepts @c @c Copyright 2000 Peter Liljenberg @c @node Basic X Concepts @chapter Basic X Concepts Here you might find an introduction to X concepts sometime in the future. For now, I just refer to the introduction parts of the standard X documentation. A vast collection of X documentation links can be found at @uref{http://www.rahul.net/kenton/xsites.html}. python-xlib-0.14+20091101/doc/src/events.texi0000644000175000017500000006377607540167666017131 0ustar stewstew @node Event Handling @chapter Event Handling Events are sent from the X server to the X client. Most of the event types deal with user input, but there are also event types used for inter-client communication. Most X applications are built around an event loop, where the client waits for the server to send events. The client responds to the events, typically by doing one or more X requests. @menu * Getting Events:: Waiting for events. * Selecting Events:: Selecting interesting events. * Event Types:: Details on all event types. * Sending Events:: Clients sending events to other clients. @end menu @node Getting Events @section Getting Events Events can be sent at any time, not necessarily when the client is ready to recieve an event. Therefore they must be stored temporarily from that they are read from the network until the client is ready to handle them. Read but unhandled events are stored on an event queue in the Display object. There are two functions to access this queue: @defmethod Display next_event ( ) Return the next event in the event queue. If the event queue is empty, block until an event is read from the network, and return that one. @end defmethod @defmethod Display pending_events ( ) Return the number of events which can be returned without blocking. @end defmethod A trivial event loop would simply loop infinitely, waiting for an event and then handling it. It could look like this: @example while 1: event = disp.next_event() handle_event(event) @end example However, most applications need more control, e.g. to simultaneously handle a network connection or at regular intervals schedule timeouts. The module @code{select} is often used for this. @code{Display} objects can be used with @code{select}, since they have the required @code{fileno()} method. When @code{select} indicates that a @code{Display} object is ready for reading, that means that the server has sent some data to the client. That alone doesn't guarantee that an entire event has arrived, so one must first use @code{pending_events()} to make sure that @code{next_event()} will return without blocking. A simple event loop which waits for events or a one-second timeout looks like this: @example while 1: # Wait for display to send something, or a timeout of one second readable, w, e = select.select([disp], [], [], 1) # if no files are ready to be read, it's an timeout if not readable: handle_timeout() # if display is readable, handle as many events as have been recieved elif disp in readable: i = disp.pending_events() while i > 0: event = disp.next_event() handle_event(event) i = i - 1 # loop around to wait for more things to happen @end example @node Selecting Events @section Selecting Events To avoid flooding the clients with events in which they have no interest, they must explicitly tell the server which events they are interested in. This is done by providing the @code{event_mask} attribute when creating windows with @code{Window.create_window} or in calls to @code{Window.change_attributes}. The value of this attribute is a mask of all types of events the client is interested in on that particular window. Whenever the server generates an event for a window which matches the clients event mask on that window, the event will be sent to the client. The following table lists all event masks and the corresponding event types and classes. All event masks and types are integer constants defined in the module @code{Xlib.X}. Classes have the same name as the event type, and are defined in @code{Xlib.protocol.event}. @multitable {SubstructureRedirectMask} {VisibilityNotify} {Colormap changed or installed} @item @strong{Mask} @tab @strong{Type and Class} @tab @strong{Generated when} @item ButtonMotionMask @* Button1MotionMask @* Button2MotionMask @* Button3MotionMask @* Button4MotionMask @* Button5MotionMask @tab MotionNotify @tab Pointer moved with any or a certain button down @item @tab @tab @item ButtonPressMask @tab ButtonPress @tab Pointer button pressed @item ButtonReleaseMask @tab ButtonRelease @tab Pointer button released @item @tab @tab @item ColormapChangeMask @tab ColormapNotify @tab Colormap changed or installed @item @tab @tab @item EnterWindowMask @tab EnterNotify @tab Pointer enters window @item LeaveWindowMask @tab LeaveNotify @tab Pointer leaves window @item @tab @tab @item ExposureMask @tab Expose @* NoExpose @tab Window needs to be redrawn @item @tab @tab @item FocusChangeMask @tab FocusIn @* FocusOut @tab Focus changes @item KeymapStateMask @tab KeymapNotify @tab After EnterNotify and FocusIn @item @tab @tab @item KeyPressMask @tab KeyPress @tab Key is pressed @item KeyReleaseMask @tab ReleasePress @tab Key is released @item @tab @tab @item PointerMotionMask @tab MotionNotify @tab Pointer is moved @item @tab @tab @item PropertyChangeMask @tab PropertyNotify @tab Window properties change @item @tab @tab @item StructureNotifyMask @tab CirculateNotify @* ConfigureNotify @* DestroyNotify @* GravityNotify @* MapNotify @* ReparentNotify @* UnmapNotify @tab Window structure changes @item @tab @tab @item SubstructureNotifyMask @tab CirculateNotify @* ConfigureNotify @* CreateNotify @* DestroyNotify @* GravityNotify @* MapNotify @* ReparentNotify @* UnmapNotify @tab Child window structure changes @item @tab @tab @item ResizeRedirectMask @tab ResizeRequest @tab Controlling window size change @item @tab @tab @item SubstructureRedirectMask @tab CirculateRequest @* ConfigureRequest @* MapRequest @tab Controlling changes to child windows @item @tab @tab @item VisibilityChangeMask @tab VisibilityNotify @tab Window is obscured or visible @end multitable There are also some event types which are always sent to the clients, regardless of any event masks: @multitable {@strong{Type and Class}} {Other client sends message} @item @strong{Type and Class} @tab @strong{Cut'n'pasting between windows} @item ClientMessage @tab Other client sends message @item @tab @item MappingMotify @tab Keyboard mapping changes @item @tab @item SelectionClear @* SelectionNotify @* SelectionRequest @tab Cut'n'pasting between windows @end multitable @node Event Types @section Event Types This section describes all event types by listing their fields and basic information on when they are generated. All events are defined in the module @code{Xlib.protocol.event}. All event types have the following two attributes: @defivar Event type Stores the X type code of this event. Type codes are integers in the range 2-127, and are defined with symbolic names in @code{Xlib.X}. The symbolic names are the same as the event class names, except for the special event @code{AnyEvent}. @end defivar @defivar Event send_event This attribute is normally 0, meaning that the event was generated by the X server. It is set to 1 if this event was instead sent from another client. @end defivar Event object can be created by instantiating the corresponding event class, providing all the attributes described for the event as keyword arguments. @defvr Event KeyPress @defvrx Event KeyRelease @defvrx Event ButtonPress @defvrx Event ButtonRelease @defvrx Event MotionNotify These events are generated when a key or a button logically changes state, or when the pointer logically moves. In the discussion below, the @dfn{source window} is the window that the event occured in. The event may be generated on some other window than the source window, see XKeyEvent(3X11) for details. The same man page also describes @code{MotionNotify}. @defivar KeyButtonPointerEvent time The server X time when this event was generated. @end defivar @defivar KeyButtonPointerEvent root The root window which the source window is an inferior of. @end defivar @defivar KeyButtonPointerEvent window The window the event is reported on. @end defivar @defivar KeyButtonPointerEvent same_screen Set to 1 if @code{window} is on the same screen as @code{root}, 0 otherwise. @end defivar @defivar KeyButtonPointerEvent child If the source window is an inferior of @code{window}, @code{child} is set to the child of @code{window} that is the ancestor of (or is) the source window. Otherwise it is set to @code{X.NONE}. @end defivar @defivar KeyButtonPointerEvent root_x @defivarx KeyButtonPointerEvent root_y The pointer coordinates at the time of the event, relative to the root window. @end defivar @defivar KeyButtonPointerEvent event_x @defivarx KeyButtonPointerEvent event_y The pointer coordinates at the time of the event, relative to @code{window}. If @code{window} is not on the same screen as @code{root}, these are set to 0. @end defivar @defivar KeyButtonPointerEvent state The logical state of the button and modifier keys just before the event. @end defivar @defivar KeyButtonPointerEvent detail For @code{KeyPress} and @code{KeyRelease}, this is the keycode of the event key. For @code{ButtonPress} and @code{ButtonRelease}, this is the button of the event. For @code{MotionNotify}, this is either @code{X.NotifyNormal} or @code{X.NotifyHint}. @end defivar @end defvr @defvr Event EnterNotify @defvrx Event LeaveNotify If pointer motion or window hierarchy change causes the pointer to be in another window than before, these events are generated instead of a @code{MotionNotify} event. The semantics are quite complex, see XCrossingEvent(3X11) for details. @defivar EnterLeaveEvent time The server X time when this event was generated. @end defivar @defivar EnterLeaveEvent root The root window of the pointer at the end of this event. @end defivar @defivar EnterLeaveEvent window The window the event is reported for. @end defivar @defivar EnterLeaveEvent child In a @code{LeaveNotify} event, if a child of @code{window} contains the initial pointer position, this is set to that child window. In a @code{EnterNotify} event, if a child of @code{window} contains the final pointer position, this is set to that child window. Otherwise this is set to @code{X.NONE}. @end defivar @defivar EnterLeaveEvent root_x @defivarx EnterLeaveEvent root_y The final pointer position relative to @code{root}. @end defivar @defivar EnterLeaveEvent event_x @defivarx EnterLeaveEvent event_y The final pointer position relative to @code{window}. @end defivar @defivar EnterLeaveEvent state The modifier and button state at the time of the event. @end defivar @defivar EnterLeaveEvent mode One of @code{X.NotifyNormal}, @code{X.NotifyGrab} or @code{X.NotifyUngrab}. @end defivar @defivar EnterLeaveEvent detail One of @code{X.NotifyAncestor}, @code{X.NotifyVirtual}, @code{X.NotifyInferior}, @code{X.NotifyNonlinear}, or @code{X.NotifyNonlinearVirtual}. @end defivar @defivar EnterLeaveEvent flags If bit 0 is set, @code{window} is the focus window or an inferior of it. If bit 1 is set, @code{window} is on the same screen as @code{root}. @end defivar @end defvr @defvr Event FocusIn @defvrx Event FocusOut These events are generated when the focus changes. This is also very complex events, see XFocusChangeEvent(3X11) for details. @defivar FocusEvent window The window the event is generated for. @end defivar @defivar FocusEvent mode One of @code{X.NotifyNormal}, @code{X.NotifyWhileGrabbed}, @code{X.NotifyGrab}, or @code{X.NotifyUngrab}. @end defivar @defivar FocusEvent detail One of @code{X.NotifyAncestor}, @code{X.NotifyVirtual}, @code{X.NotifyInferior}, @code{X.NotifyNonlinear}, @code{X.NotifyNonlinearVirtual}, @code{X.NotifyPointer}, @code{X.NotifyPointerRoot}, or @code{X.NONE}. @end defivar @end defvr @defvr Event KeymapNotify This event is generated immediately after every @code{EnterNotify} and @code{FocusIn}. @defivar KeymapNotify data A list of 31 eight-bit integers, as returned by query_keymap. @end defivar @end defvr @defvr Event Expose This event is generated when regions of a window has to be redrawn. The regions are decomposed into a set of rectangles, and an @code{Expose} event is generated for each rectangle. @defivar Expose window The window containing regions to redraw. @end defivar @defivar Expose x @defivarx Expose y @defivarx Expose width @defivarx Expose height The coordinates of the rectangle to redraw. @end defivar @defivar Expose count At least this many more @code{Expose} events will immediately follow for this window. If this is the last event, @code{count} is set to 0. This allows a simple application to ignore all @code{Expose} events with a non-zero @code{count}, and then redraw the entire window when the zero event is received. @end defivar @end defvr @defvr Event GraphicsExpose @defvrx Event NoExpose These events may be generated for drawables when a graphics context with @code{graphics_exposures} selected is used. See XGraphicsExposeEvent(3X11) for details. Both events have these attributes: @defivar GraphicsExpose drawable The drawable of the event. @end defivar @defivar GraphicsExpose major_event @defivarx GraphicsExpose minor_event The major and minor number of the request that generated this event. For the core protocol @code{major_event} is always 62 (CopyArea) or 63 (CopyPlane), and @code{minor_event} is always 0. @end defivar GraphicsExpose have these additional attributes: @defivar GraphicsExpose x @defivarx GraphicsExpose y @defivarx GraphicsExpose width @defivarx GraphicsExpose height The coordinates of the event region. @end defivar @defivar GraphicsExpose count At least this many more @code{GraphicsExposure} events follows. The last one has @code{count} set to 0. @end defivar @end defvr @defvr Event VisibilityNotify These events are generated when the visibility of a viewable window is changed. See XVisibilityNotifyEvent(3X11). @defivar VisibiltyNotify window The window of the event. @end defivar @defivar VisibiltyNotify state One of @code{X.VisibilityUnobscured}, @code{X.VisibilityPartiallyObscured}, or @code{X.VisibilityFullyObscured}. @end defivar @end defvr @defvr Event CreateNotify This event is generated when a window is created. @code{X.SubstructureNotifyMask} must be selected on the parent of the new window to receive this event. @defivar CreateNotify parent The parent of the new window. @end defivar @defivar CreateNotify window The new window. @end defivar @defivar CreateNotify x @defivarx CreateNotify y @defivarx CreateNotify width @defivarx CreateNotify height @defivarx CreateNotify border_width @defivarx CreateNotify override These values are fetched from the @code{create_window} call. @end defivar @end defvr @defvr Event DestroyNotify This event is generated when a window is destroyed. @defivar DestroyNotify event The window that the event is generated for. @end defivar @defivar DestroyNotify window The window that was destroyed. @end defivar @end defvr @defvr Event UnmapNotify This event is generated when a window is unmapped. @defivar UnmapNotify event The window that the event is generated for. @end defivar @defivar UnmapNotify window The window that was unmapped. @end defivar @defivar Event from_configure This is true if @code{window} was unmapped because its parent was resized and @code{window} had win-gravity @code{X.UnmapGravity}. @end defivar @end defvr @defvr Event MapNotify This event is generated when a window is mapped. @defivar MapNotify event The window that the event is generated for. @end defivar @defivar MapNotify window The window that was mapped. @end defivar @defivar Event override This is set from the corresponding window attribute. @end defivar @end defvr @defvr Event MapRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on a window, and an unmapped child of that window attempts to be mapped by some other client, unless the child has override-redirect set. @defivar MapRequest parent The parent window. @end defivar @defivar MapRequest window The child window that attempts to be mapped. @end defivar @end defvr @defvr Event ReparentNotify This event is reported to clients selecting @code{X.SubstructureNotifyMask} on either the old or the new parent and to clients selecting @code{X.StructureNotifyMask} on the reparented window. @defivar ReparentNotify event The window the event is generated for. @end defivar @defivar ReparentNotify window The reparented window. @end defivar @defivar ReparentNotify parent The new parent window. @end defivar @defivar ReparentNotify x @defivarx ReparentNotify y The coordinates of the upper-left outer corner of @code{window} in @code{parent}. @end defivar @defivar ReparentNotify override This is set from the corresponding attribute on @code{window}. @end defivar @end defvr @defvr Event ConfigureNotify This event is generated when a configure request actually changes the state of the window. @defivar ConfigureNotify event The window that the event is generated for. @end defivar @defivar ConfigureNotify window The window that has been changed. @end defivar @defivar ConfigureNotify x @defivarx ConfigureNotify y @defivarx ConfigureNotify width @defivarx ConfigureNotify height @defivarx ConfigureNotify border_width The new coordinate and geometry of @code{window}. @end defivar @defivar ConfigureNotify above_sibling This is @code{X.NONE} if this window is at the bottom of the window stack. Otherwise it is the sibling window that @code{window} is immediately above. @end defivar @defivar ConfigureNotify override This is set from the corresponding attribute on @code{window}. @end defivar @end defvr @defvr Event ConfigureRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on the parent of a window that another client attempts to configure, unless the window has override-redirect set. @defivar ConfigureRequest parent The parent of the window being configured. @end defivar @defivar ConfigureRequest window The window being configured. @end defivar @defivar ConfigureRequest value_mask A bitmask indicating which values that the caller tries to change. @end defivar @defivar ConfigureRequest x @defivarx ConfigureRequest y @defivarx ConfigureRequest width @defivarx ConfigureRequest height @defivarx ConfigureRequest border_width The window geometry in the configure call. If @code{X.CWX}, @code{X.CWY}, @code{X.CWWidth}, @code{X.CWHeight}, or @code{X.CWBorderWidth} is set in @code{value_mask}, the corresponding attributes contains the new value as given in the configure call, otherwise the current value is used. @end defivar @defivar ConfigureRequest stack_mode If @code{X.CWStackMode} is set in @code{value_mask}, this is the stack mode specified in the configure call, one of @code{X.Above}, @code{X.Below}, @code{X.TopIf}, @code{X.BottomIf}, or @code{X.Opposite}. If the flag is not set, this is set to @code{X.Above}. @end defivar @defivar ConfigureRequest sibling If @code{X.CWSibling} is set in @code{value_mask}, this is the sibling window specified in the configure call. If the flag is not set, this is set to @code{X.NONE}. @end defivar @end defvr @defvr Event GravityNotify This event is generated when a window is moved because its parent's size has changed. @defivar GravityNotify event The window the event is generated for. @end defivar @defivar GravityNotify window The window that moved. @end defivar @defivar GravityNotify x @defivarx GravityNotify y The new coordinates of the upper-left outer corner of @code{window}. @end defivar @end defvr @defvr Event ResizeRequest This is reported to the client selecting @code{X.ResizeRedirectMask} on a window, and another client attempts to resize it. @defivar ResizeRedirect window The window that was attempted to be resized. @end defivar @defivar ResizeRedirect width @defivarx ResizeRedirect height The requested size of the window, excluding the border. @end defivar @end defvr @defvr Event CirculateNotify This event is generated when a window is restacked caused by a circulate call. @defivar Event event The window the event is reported on. @end defivar @defivar Event window The window that has been restacked. @end defivar @defivar Event place Either @code{X.PlaceOnTop} or @code{X.PlaceOnBottom}. @end defivar @end defvr @defvr Event CirculateRequest This event is reported to the client that has set @code{X.SubstructureRedirectMask} on the parent of a window that needs to be restacked as a result of a circulate call on the parent. @defivar CirculateRequest parent The parent window. @end defivar @defivar CirculateRequest window The window that should be restacked. @end defivar @defivar CirculateRequest place Where @code{window} should be placed, either @code{X.PlaceOnTop} or @code{X.PlaceOnBottom}. @end defivar @end defvr @defvr Event PropertyNotify This event is generated when a property on a window is changed. @defivar Event window The window which the property is or was set on. @end defivar @defivar Event atom The atom identifying the property. @end defivar @defivar Event time The server X time when the property was changed. @end defivar @defivar Event state What was changed, either @code{X.PropertyNewValue} or @code{X.PropertyDelete}. @end defivar @end defvr @defvr Event SelectionClear This event is reported to the owner of a selection when it has gotten a new owner. @defivar SelectionClear window The owner window of the selection. @end defivar @defivar SelectionClear atom The selection atom. @end defivar @defivar SelectionClear time The server X time when the selection was last changed. @end defivar @end defvr @defvr Event SelectionRequest This event is reported to the owner of a selection when a client requests it by calling convert_selection. @defivar SelectionRequest owner The owner window of the selection. @end defivar @defivar SelectionRequest requestor @defivarx SelectionRequest selection @defivarx SelectionRequest target @defivarx SelectionRequest property @defivarx SelectionRequest time These attributes are fetched from the convert_selection call. @end defivar @end defvr @defvr Event SelectionNotify This event is generated by the server if there are no owner of a selection when convert_selection is called. If there is an owner, it should send this event to the requestor when the selection has been converted. @defivar SelectionNotify requestor @defivarx SelectionNotify selection @defivarx SelectionNotify target @defivarx SelectionNotify property @defivarx SelectionNotify time See XSelectionEvent(3X11). @end defivar @end defvr @defvr Event ColormapNotify This event is generated when the colormap attribute of a window is set, or when a window's colormap is installed or uninstalled. @defivar ColormapNotify window The affected window. @end defivar @defivar ColormapNotify colormap The colormap of the window, or @code{X.NONE}. @end defivar @defivar ColormapNotify new Set to 1 if the colormap attribute has been set, 0 when the colormap is installed or uninstalled. @end defivar @defivar ColormapNotify state Indicates whether the colormap is installed or not, either @code{X.ColormapInstalled} or @code{X.ColormapUninstalled}. @end defivar @end defvr @defvr Event MappingNotify This event is sent to all clients, without any event mask having to be set. It is sent when the keyboard or pointer mapping is changed. @defivar MappingNotify request The mapping that has changed, one of @code{X.MappingModifier}, @code{X.MappingKeyboard} or @code{X.Pointer}. @end defivar @defivar MappingNotify first_keycode @defivarx MappingNotify count If the keyboard mapping has changed, this is the range of modified keycodes. @end defivar @end defvr @defvr Event ClientMessage This event is only generated by clients using send_event. @defivar ClientMessage window The destination window of the event. @end defivar @defivar ClientMessage client_type The type of message, an atom. @end defivar @defivar ClientMessage data The message data as a tuple: @code{(format, mdata)} Format must be one of 8, 16, or 32. mdata must either be a string of exactly 20 characters, or a list of exactly 20, 10 or 5 integers depending of the format. @end defivar @end defvr @defvr Event AnyEvent This event is represents an event the Xlib does not recognise. These should never be returned by @code{Display.next_event()}, but they might be useful for sending special events to other clients. @defivar AnyEvent detail An eight-bit integer. @end defivar @defivar AnyEvent data A string of exactly 28 characters. @end defivar @end defvr @node Sending Events @section Sending Events Clients can send events to each other. Most often these are general-purpose @code{ClientMessage} events, but any event type can be sent. To send an event, an event object must be created. This is done by instantiating an event class, providing values to all its fields as keyword parameters. The event is then sent with the @code{send_event()} method: @defmethod Window send_event ( event, event_mask = 0, propagate = 0, @w{onerror = None )} Send @var{event} to this window. If @var{event_mask} is 0, the event is sent to the client that created the window. Otherwise the event is sent to every client selecting any of the event types in @var{event_mask}. If no clients have selected any of the event types and @var{propagate} is true, the X server will search for an ancestor of this window on which some client has selected any of the event types. For details, see XSendEvent(3X11). @end defmethod @defmethod Display send_event ( destination, event, @w{event_mask = 0,} @w{propagate = 0,} @w{onerror = None )} Send @var{event} to @var{destination}, which can either be a @code{Window} object or a constant: If @code{X.PointerWindow} is specified, send the event to the window the pointer is in. If @code{X.InputFocus} is specified and the focus window contains the pointer, send the event to the window that the pointer is in. Otherwise, send the event to the focus window. @end defmethod As an example, this creates and sends a @code{ClientMessage} event of the client specific type @code{HELLO_WORLD} (an atom), to the window @code{dest} and with the 8-bitformat value @code{"G'day, mate"} (which must be exactly twenty bytes): @example cm_event = Xlib.protocol.event.ClientMessage( window = dest, client_type = HELLO_WORLD, data = (8, "G'day mate\0\0\0\0\0\0\0\0\0\0")) dest.send_event(cm_event) @end example python-xlib-0.14+20091101/doc/src/Makefile0000644000175000017500000000026007401660616016332 0ustar stewstew# When make:ing in the src dir, just do info info: (cd ..; make info) ps: (cd ..; make ps) html: (cd ..; make html) all: (cd ..; make all) clean: (cd ..; make clean) python-xlib-0.14+20091101/doc/src/package.texi0000644000175000017500000000331710770020473017160 0ustar stewstew@c The Python X Library -- package layout @c @c Copyright 2000 Peter Liljenberg @c @node Package Layout @chapter Package Layout The Python X Library is distributed as a Python package, named @code{Xlib}. It contains a number of modules providing the main library interface: @table @code @item display Contains the @code{Display} class, providing the X connection and access to all other X objects and operations. @item error Contains all @code{Xlib} exception classes. @item threaded Imported to set up the library to be thread-safe. @item rdb Contains @code{ResourceDB}, an X resource database class, and related code. @item X Contains symbolic names for all basic X protocol constants. @item Xutil Contains additional constants for mainly the ICCCM standard. @item XK Contains symbolic names for all X keysyms. @item Xatom Contains symbolic names for all standard X atoms. @item Xcursorfont Contains symbolic names for all standard X fonts. @end table There is also a number of subpackages, but they will mainly be of interest to developers of the Xlib itself: @table @code @item protocol The low-level protocol implementation. Contains definitions of all X request, responses, events and errors, in addition to the core network code. The high-level object oriented interface provided by @code{Xlib.display} is merely a wrapper around this package. @item support Miscellaneous supporting code for handling threads and operating system-specific features. @item xobject Contains classes for all X objects, which are returned by various display operations. @item ext Contains various X protocol extensions. Extensions supported by the server are loaded automatically at the display connection. @end table python-xlib-0.14+20091101/doc/src/objects.texi0000644000175000017500000010453007540167666017236 0ustar stewstew @node X Objects @chapter X Objects All X operations are performed by invoking object methods. The objects and their methods are listed in the following nodes, however with no detailed explanations. The reader are referred to other sources of X documentation for details, e.g. the X protocol specification, the C Xlib documentation or man pages. A vast collection of X documentation links can be found at @uref{http://www.rahul.net/kenton/xsites.html}. Methods returning a single value will return that directly. Otherwise, an object containing attributes for each of the result values is returned. Methods returning some value will raise an exception on error. Methods which does not return any value have instead an @code{on_error} parameter, which can be used to specify an error handler. @menu * Display:: Methods on Display objects. * Resource:: Methods common to all the following resource objects. * Colormap:: Methods on Colormap objects. * Cursor:: Methods on Cursor objects. * Drawable:: Methods common to Window and Pixmap objects. * Window:: Methods on Window objects. * Pixmap:: Methods on Pixmap objects. * Fontable:: Methods common to GC and Font objects. * GC:: Methods on GC objects. * Font:: Methods on Font objects. @end menu @node Display @section Display Display information retrieval methods: @defmethod Display get_display_name ( ) Returns the name used to connect to the server, either provided when creating the @code{Display} object, or fetched from the environmental variable @code{$DISPLAY}. @end defmethod @defmethod Display fileno ( ) Returns the file descriptor number of the underlying socket. This method is provided to allow @code{Display} objects to be passed @code{select.select()}. @end defmethod @defmethod Display close ( ) Close the display, freeing the resources that it holds. @end defmethod @defmethod Display set_error_handler ( handler ) Set the default error handler which will be called for all unhandled errors. @var{handler} should take two arguments as a normal request error handler, but the second argument (the request) will be None. @xref{Error Handling}. @end defmethod @defmethod Display flush ( ) Flush the request queue, building and sending the queued requests. This can be necessary in applications that never wait for events, and in threaded applications. @end defmethod @defmethod Display sync ( ) Flush the queue and wait until the server has processed all the queued requests. Use this e.g. when it is important that errors caused by a certain request is trapped. @end defmethod @defmethod Display next_event ( ) Return the next event. If there are no events queued, it will block until the next event is fetched from the server. @end defmethod @defmethod Display pending_events ( ) Return the number of events queued, i.e. the number of times that @code{Display.next_event()} can be called without blocking. @end defmethod @defmethod Display has_extension ( extension ) Check if both the server and the client library support the X extension named @var{extension}. @end defmethod @defmethod Display create_resource_object ( type, id ) Create a resource object of @var{type} for the integer @var{id}. @var{type} should be one of the following strings: @table @code @item resource @itemx drawable @itemx window @itemx pixmap @itemx fontable @itemx font @itemx gc @itemx colormap @itemx cursor @end table This function can be used when a resource ID has been fetched e.g. from an resource or a command line argument. Resource objects should never be created by instantiating the appropriate class directly, since any X extensions dynamically added by the library will not be available. @end defmethod @defmethod Display screen ( sno = None ) Return the information about screen number @var{sno}, or the default screen if @var{sno} is @code{None}. The return object has the following attributes: @table @code @item root The screen root window. @item default_colormap The default colormap for the root window and its children. @item white_pixel @itemx black_pixel The pixel values for white and black, respectively, in the default colormap. @item current_input_mask The event mask of the root window at the time the connection was set up. @item width_in_pixels @itemx height_in_pixels The size of the root window in pixels, i.e. the size of the entire screen. @item width_in_mms @itemx height_in_mms The physical size of the screen, in millimeters. @item min_installed_maps @itemx max_installed_maps The minimum and maximum number of colormaps that can be installed at the same time. @item root_visual The visual type of the root window. @item backing_store Whether the screen supports backing store, one of the values @code{X.WhenMapped}, @code{X.NotUseful}, or @code{X.Always}. @item save_unders True if the screen supports save unders. @item root_depth The depth of the root window. @item allowed_depths A list of the pixmap and windows depths that this screen supports. The list items have the following attributes: @table @code @item depth This depth is supported by the screen. @item visuals A list of visual types that is valid for this depth. If this list is empty, this depth is only valid for pixmaps and not for windows. The list items have the following attributes: @table @code @item visual_id The ID of this visual. @item visual_class One of @code{X.StaticGrey}, @code{X.StaticColor}, @code{X.TrueColor}, @code{X.GrayScale}, @code{X.PseudoColor}, or @code{X.DirectColor}. @item bits_per_rgb_value The number of bits used to represent an entire RGB-value, allowing a total of @code{2^bits_per_rgb_value} distinct colors. @item colormap_entries The number of free entries in a newly created colormap. @item red_mask @itemx blue_mask @itemx green_mask Bitmasks selecting the three color components from the entire RGB value. @end table @end table @end table @end defmethod @defmethod Display screen_count ( ) Return the total number of screens on the display. @end defmethod @defmethod Display get_default_screen ( ) Return the number of the default screen, extracted from the display name. @end defmethod @defmethod Display keycode_to_keysym ( keycode, index ) Convert a @var{keycode} to a keysym, looking in entry @var{index}. Normally index 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shift+alt grid. If that key entry is not bound, @code{X.NoSymbol} is returned. @end defmethod @defmethod Display keysym_to_keycode ( keysym ) Look up the primary keycode that is bound to @var{keysym}. If several keycodes are found, the one with the lowest index and lowest code is returned. If @var{keysym} is not bound to any key, 0 is returned. @end defmethod @defmethod Display keysym_to_keycodes ( keysym ) Look up all the keycodes that is bound to @code{keysym}. A list of tuples @code{(keycode, index)} is returned, sorted primarily on the lowest index and secondarily on the lowest keycode. @end defmethod @defmethod Display refresh_keyboard_mapping ( evt ) This method should be called once when a @code{MappingNotify} event is received, to update the keymap cache. @var{evt} should be the event object. @end defmethod @defmethod Display lookup_string ( keysym ) Attempt to convert @var{keysym} into a single character or a string. If no translation is found, @code{None} is returned. @end defmethod @defmethod Display rebind_string ( keysym, newstring ) Set the string representation of @code{keysym} to @code{newstring}, so that it will be returned by @code{Display.lookup_string()}. @end defmethod X requests methods: @defmethod Display intern_atom ( name, only_if_exists = 0 ) Intern the string @var{name}, returning its atom number. If @var{only_if_exists} is true and the atom does not already exist, it will not be created and @code{X.NONE} is returned. @end defmethod @defmethod Display get_atom_name ( atom ) Look up the name of @var{atom}, returning it as a string. Will raise @code{BadAtom} if @var{atom} does not exist. @end defmethod @defmethod Display get_selection_owner ( selection ) Return the window that owns @var{selection} (an atom), or @code{X.NONE} if there is no owner for the selection. Can raise @code{BadAtom}. @end defmethod @defmethod Display send_event ( destination, event, @w{event_mask = 0,} @w{propagate = 0,} @w{onerror = None )} Send a synthetic event to the window @code{destination} which can be a window object, or @code{X.PointerWindow} or @code{X.InputFocus}. @code{event} is the event object to send, instantiated from one of the classes in @code{protocol.events}. See XSendEvent(3X11) for details. There is also a @code{Window.send_event()} method. @end defmethod @defmethod Display ungrab_pointer ( time, onerror = None ) Release a grabbed pointer and any queued events. See XUngrabPointer(3X11). @end defmethod @defmethod Display change_active_pointer_grab ( event_mask, cursor, time, @w{onerror = None )} Change the dynamic parameters of a pointer grab. See XChangeActivePointerGrab(3X11). @end defmethod @defmethod Display ungrab_keyboard ( time, onerror = None ) Ungrab a grabbed keyboard and any queued events. See XUngrabKeyboard(3X11). @end defmethod @defmethod Display allow_events ( mode, time, @w{onerror = None )} Release some queued events. @var{mode} should be one of @code{X.AsyncPointer}, @code{X.SyncPointer}, @code{X.AsyncKeyboard}, @code{X.SyncKeyboard}, @code{X.ReplayPointer}, @code{X.ReplayKeyboard}, @code{X.AsyncBoth}, or @code{X.SyncBoth}. @var{time} should be a timestamp or @code{X.CurrentTime}. @end defmethod @defmethod Display grab_server ( onerror = None ) Disable processing of requests on all other client connections until the server is ungrabbed. Server grabbing should be avoided as much as possible. @end defmethod @defmethod Display ungrab_server ( onerror = None ) Release the server if it was previously grabbed by this client. @end defmethod @defmethod Display warp_pointer ( x, y, @w{src_window = X.NONE,} @w{src_x = 0,} @w{src_y = 0,} @w{src_width = 0,} @w{src_height = 0,} @w{onerror = None )} Move the pointer relative its current position by the offsets (@var{x}, @var{y}). However, if @var{src_window} is a window the pointer is only moved if the specified rectangle in @var{src_window} contains it. If @var{src_width} is 0 it will be replaced with the width of @var{src_window} - @var{src_x}. @var{src_height} is treated in a similar way. To move the pointer to absolute coordinates, use @code{Window.warp_pointer()}. @end defmethod @defmethod Display set_input_focus ( focus, revert_to, time, @w{onerror = None )} Set input focus to @var{focus}, which should be a window, @code{X.PointerRoot} or @code{X.NONE}. @var{revert_to} specifies where the focus reverts to if the focused window becomes not visible, and should be @code{X.RevertToParent}, @code{RevertToPointerRoot}, or @code{RevertToNone}. See XSetInputFocus(3X11) for details. There is also a @code{Window.set_input_focus()}. @end defmethod @defmethod Display get_input_focus ( ) Return an object with the following attributes: @table @code @item focus The window which currently holds the input focus, @code{X.NONE} or @code{X.PointerRoot}. @item revert_to Where the focus will revert, one of @code{X.RevertToParent}, @code{RevertToPointerRoot}, or @code{RevertToNone}. @end table @end defmethod @defmethod Display query_keymap ( ) Return a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as a list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. @end defmethod @defmethod Display open_font ( name ) Open the font identifed by the pattern @var{name} and return its font object. If @var{name} does not match any font, @code{None} is returned. @end defmethod @defmethod Display list_fonts ( pattern, max_names ) Return a list of font names matching @var{pattern}. No more than @var{max_names} will be returned. @end defmethod @defmethod Display list_fonts_with_info ( pattern, max_names ) Return a list of fonts matching @var{pattern}. No more than @var{max_names} will be returned. Each list item represents one font and has the following properties: @table @code @item name The name of the font. @item min_bounds @itemx max_bounds @itemx min_char_or_byte2 @itemx max_char_or_byte2 @itemx default_char @itemx draw_direction @itemx min_byte1 @itemx max_byte1 @itemx all_chars_exist @itemx font_ascent @itemx font_descent @itemx replies_hint See the descripton of XFontStruct in XGetFontProperty(3X11) for details on these values. @item properties A list of properties. Each entry has two attributes: @table @code @item name The atom identifying this property. @item value A 32-bit unsigned value. @end table @end table @end defmethod @defmethod Display set_font_path ( path, onerror = None ) Set the font path to @var{path}, which should be a list of strings. If @var{path} is empty, the default font path of the server will be restored. @end defmethod @defmethod Display get_font_path ( ) Return the current font path as a list of strings. @end defmethod @defmethod Display query_extension ( name ) Ask the server if it supports the extension @var{name}. If it is supported an object with the following attributes is returned: @table @code @item major_opcode The major opcode that the requests of this extension uses. @item first_event The base event code if the extension have additional events, or 0. @item first_error The base error code if the extension have additional errors, or 0. @end table If the extension is not supported, @code{None} is returned. @end defmethod @defmethod Display list_extensions ( ) Return a list of all the extensions provided by the server. @end defmethod @defmethod Display change_keyboard_mapping ( first_keycode, keysyms, @w{onerror = None )} Modify the keyboard mapping, starting with @var{first_keycode}. @var{keysyms} is a list of tuples of keysyms. @code{keysyms[n][i]} will be assigned to keycode @code{first_keycode+n} at index @code{i}. @end defmethod @defmethod Display get_keyboard_mapping ( first_keycode, count ) Return the current keyboard mapping as a list of tuples, starting at @var{first_keycount} and no more than @var{count}. @end defmethod @defmethod Display change_keyboard_control ( @w{onerror = None,} **keys ) Change the parameters provided as keyword arguments: @table @code @item key_click_percent The volume of key clicks between 0 (off) and 100 (load). -1 will restore default setting. @item bell_percent The base volume of the bell, coded as above. @item bell_pitch The pitch of the bell in Hz, -1 restores the default. @item bell_duration The duration of the bell in milliseconds, -1 restores the default. @item led @itemx led_mode @code{led_mode} should be @code{X.LedModeOff} or @code{X.LedModeOn}. If @code{led} is provided, it should be a 32-bit mask listing the LEDs that should change. If @code{led} is not provided, all LEDs are changed. @item key @itemx auto_repeat_mode @code{auto_repeat_mode} should be one of @code{X.AutoRepeatModeOff}, @code{X.AutoRepeatModeOn}, or @code{X.AutoRepeatModeDefault}. If @code{key} is provided, that key will be modified, otherwise the global state for the entire keyboard will be modified. @end table @end defmethod @defmethod Display get_keyboard_control ( ) Return an object with the following attributes: @table @code @item global_auto_repeat @code{X.AutoRepeatModeOn} or @code{X.AutoRepeatModeOff}. @item auto_repeats A list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the byte representing key 8N. If a bit is on, autorepeat is enabled for the corresponding key. @item led_mask A 32-bit mask indicating which LEDs are on. @item key_click_percent The volume of key click, from 0 to 100. @item bell_percent @itemx bell_pitch @itemx bell_duration The volume, pitch and duration of the bell. @end table @end defmethod @defmethod Display bell ( percent = 0, onerror = None ) Ring the bell at the volume @var{percent} which is relative the base volume. See XBell(3X11). @end defmethod @defmethod Display change_pointer_control ( @w{accel = None,} @w{threshold = None,} @w{onerror = None )} To change the pointer acceleration, set @var{accel} to a tuple @code{(num, denum)}. The pointer will then move @code{num/denum} times the normal speed if it moves beyond the threshold number of pixels at once. To change the threshold, set it to the number of pixels. -1 restores the default. @end defmethod @defmethod Display get_pointer_control ( ) Return an object with the following attributes: @table @code @item accel_num @itemx accel_denom The acceleration as numerator/denumerator. @item threshold The number of pixels the pointer must move before the acceleration kicks in. @end table @end defmethod @defmethod Display set_screen_saver ( timeout, interval, prefer_blank, allow_exposures, @w{onerror = None )} See XSetScreenSaver(3X11). @end defmethod @defmethod Display get_screen_saver ( ) Return an object with the attributes @code{timeout}, @code{interval}, @code{prefer_blanking}, @code{allow_exposures}. See XGetScreenSaver(3X11) for details. @end defmethod @defmethod Display change_hosts ( mode, host_family, host, @w{onerror = None )} @var{mode} is either @code{X.HostInsert} or @code{X.HostDelete}. @var{host_family} is one of @code{X.FamilyInternet}, @code{X.FamilyDECnet} or @code{X.FamilyChaos}. @var{host} is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address. @end defmethod @defmethod Display list_hosts ( ) Return an object with the following attributes: @table @code @item mode @code{X.EnableAccess} if the access control list is used, @code{X.DisableAccess} otherwise. @item hosts The hosts on the access list. Each entry has the following attributes: @table @code @item family @code{X.FamilyInternet}, @code{X.FamilyDECnet}, or @code{X.FamilyChaos}. @item name A list of byte values, the coding depends on @code{family}. For the Internet family, it is the 4 bytes of an IPv4 address. @end table @end table @end defmethod @defmethod Display set_access_control ( mode, onerror = None ) Enable use of access control lists at connection setup if @var{mode} is @code{X.EnableAccess}, disable if it is @code{X.DisableAccess}. @end defmethod @defmethod Display set_close_down_mode ( mode, onerror = None ) Control what will happen with the client's resources at connection close. The default is @code{X.DestroyAll}, the other values are @code{X.RetainPermanent} and @code{X.RetainTemporary}. @end defmethod @defmethod Display force_screen_saver ( mode, onerror = None ) If @var{mode} is @code{X.ScreenSaverActive} the screen saver is activated. If it is @code{X.ScreenSaverReset}, the screen saver is deactivated as if device input had been received. @end defmethod @defmethod Display set_pointer_mapping ( map ) Set the mapping of the pointer buttons. @var{map} is a list of logical button numbers. @var{map} must be of the same length as the list returned by @code{Display.get_pointer_mapping()}. @code{map[n]} sets the logical number for the physical button @code{n+1}. Logical number 0 disables the button. Two physical buttons cannot be mapped to the same logical number. If one of the buttons to be altered are logically in the down state, @code{X.MappingBusy} is returned and the mapping is not changed. Otherwise the mapping is changed and @code{X.MappingSuccess} is returned. @end defmethod @defmethod Display get_pointer_mapping ( ) Return a list of the pointer button mappings. Entry N in the list sets the logical button number for the physical button N+1. @end defmethod @defmethod Display set_modifier_mapping ( keycodes ) Set the keycodes for the eight modifiers @code{X.Shift}, @code{X.Lock}, @code{X.Control}, @code{X.Mod1}, @code{X.Mod2}, @code{X.Mod3}, @code{X.Mod4} and @code{X.Mod5}. @var{keycodes} should be a eight-element list where each entry is a list of the keycodes that should be bound to that modifier. If any changed key is logically in the down state, @code{X.MappingBusy} is returned and the mapping is not changed. If the mapping violates some server restriction, @code{X.MappingFailed} is returned. Otherwise the mapping is changed and @code{X.MappingSuccess} is returned. @end defmethod @defmethod Display get_modifier_mapping ( ) Return a list of eight lists, one for each modifier. The list can be indexed using @code{X.ShiftMapIndex}, @code{X.Mod1MapIndex}, and so on. The sublists list the keycodes bound to that modifier. @end defmethod @defmethod Display no_operation ( onerror = None ) Do nothing but send a request to the server. @end defmethod @node Resource @section Resource All resource objects can be compared and hashed, so they can be used as mapping indices. They also have this method: @defmethod Resource kill_client ( onerror = None ) @end defmethod @node Colormap @section Colormap @xref{Resource}, for additional methods on @code{Colormap} objects. @defmethod Colormap free ( onerror = None ) @end defmethod @defmethod Colormap copy_colormap_and_free ( scr_cmap ) Returns Colormap. @end defmethod @defmethod Colormap install_colormap ( onerror = None ) @end defmethod @defmethod Colormap uninstall_colormap ( onerror = None ) @end defmethod @defmethod Colormap alloc_color ( red, green, blue ) @end defmethod @defmethod Colormap alloc_named_color ( name ) Returns None or Card32('pixel'), Card16('exact_red'), Card16('exact_green'), Card16('exact_blue'), Card16('screen_red'), Card16('screen_green'), Card16('screen_blue'), @end defmethod @defmethod Colormap alloc_color_cells ( contiguous, colors, planes ) Returns List('pixels', Card32Obj), List('masks', Card32Obj), @end defmethod @defmethod Colormap alloc_color_planes ( contiguous, colors, red, green, blue ) Returns Card32('red_mask'), Card32('green_mask'), Card32('blue_mask'), List('pixels', Card32Obj), @end defmethod @defmethod Colormap free_colors ( pixels, plane_mask, onerror = None ) @end defmethod @defmethod Colormap store_colors ( items, onerror = None ) @end defmethod @defmethod Colormap store_named_color ( name, pixel, flags, onerror = None ) @end defmethod @defmethod Colormap query_colors ( pixels ) Returns List('colors', structs.RGB), @end defmethod @defmethod Colormap lookup_color ( name ) Returns Card16('exact_red'), Card16('exact_green'), Card16('exact_blue'), Card16('screen_red'), Card16('screen_green'), Card16('screen_blue'), @end defmethod @node Cursor @section Cursor @xref{Resource}, for additional methods on @code{Cursor} objects. @defmethod Cursor free ( onerror = None ) @end defmethod @defmethod Cursor recolor ( (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), onerror = None ) @end defmethod @node Drawable @section Drawable @code{Drawable} is a base class of @code{Window} and @code{Pixmap} objects. @xref{Window}, and @ref{Pixmap}. @xref{Resource}, for additional methods. @defmethod Drawable get_geometry ( ) Returns Window('root'), Int16('x'), Int16('y'), Card16('width'), Card16('height'), Card16('border_width'), @end defmethod @defmethod Drawable create_pixmap ( width, height, depth ) Returns Pixmap. @end defmethod @defmethod Drawable create_gc ( **keys ) Returns GC. @end defmethod @defmethod Drawable copy_area ( gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, onerror = None ) @end defmethod @defmethod Drawable copy_plane ( gc, src_drawable, src_x, src_y, width, height, dst_x, dst_y, bit_plane, onerror = None ) @end defmethod @defmethod Drawable poly_point ( gc, coord_mode, points, onerror = None ) @end defmethod request.PolyPoint(display = self.display, onerror = onerror, coord_mode = coord_mode, drawable = self.id, gc = gc, points = points) @defmethod Drawable point ( gc, x, y, onerror = None ) @end defmethod @defmethod Drawable poly_line ( gc, coord_mode, points, onerror = None ) @end defmethod @defmethod Drawable line ( gc, x1, y1, x2, y2, onerror = None ) @end defmethod @defmethod Drawable poly_segment ( gc, segments, onerror = None ) @end defmethod @defmethod Drawable poly_rectangle ( gc, rectangles, onerror = None ) @end defmethod @defmethod Drawable rectangle ( gc, x, y, width, height, onerror = None ) @end defmethod @defmethod Drawable poly_arc ( gc, arcs, onerror = None ) @end defmethod @defmethod Drawable arc ( gc, x, y, width, height, angle1, angle2, onerror = None ) @end defmethod @defmethod Drawable fill_poly ( gc, shape, coord_mode, points, onerror = None ) @end defmethod @defmethod Drawable poly_fill_rectangle ( gc, rectangles, onerror = None ) @end defmethod @defmethod Drawable fill_rectangle ( gc, x, y, width, height, onerror = None ) @end defmethod @defmethod Drawable poly_fill_arc ( gc, arcs, onerror = None ) @end defmethod @defmethod Drawable fill_arc ( gc, x, y, width, height, angle1, angle2, onerror = None ) @end defmethod @defmethod Drawable put_image ( ) Not implemented yet. @end defmethod @defmethod Drawable get_image ( ) Not implemented yet. @end defmethod @defmethod Drawable draw_text ( gc, x, y, text, onerror = None ) @end defmethod @defmethod Drawable poly_text ( gc, x, y, items, onerror = None ) @end defmethod @defmethod Drawable poly_text_16 ( gc, x, y, items, onerror = None ) @end defmethod @defmethod Drawable image_text ( gc, x, y, string, onerror = None ) @end defmethod @defmethod Drawable image_text_16 ( gc, x, y, string, onerror = None ) @end defmethod @defmethod Drawable query_best_size ( item_class, width, height ) Returns Card16('width'), Card16('height'), @end defmethod @node Window @section Window @code{Window} objects have additional objects, see @ref{Resource} and @ref{Drawable}. @defmethod Window create_window ( x, y, width, height, border_width, depth, window_class = X.CopyFromParent, visual = X.CopyFromParent, **keys ) Returns Window @end defmethod @defmethod Window change_attributes ( onerror = None, **keys ) @end defmethod @defmethod Window get_attributes ( ) Returns Card8('backing_store'), Card32('visual'), Card16('class'), Card8('bit_gravity'), Card8('win_gravity'), Card32('backing_bit_planes'), Card32('backing_pixel'), Card8('save_under'), Card8('map_is_installed'), Card8('map_state'), Card8('override_redirect'), Colormap('colormap', (X.NONE, )), Card32('all_event_masks'), Card32('your_event_mask'), Card16('do_not_propagate_mask'), @end defmethod @defmethod Window destroy ( onerror = None ) @end defmethod @defmethod Window destroy_sub_windows ( onerror = None ) @end defmethod @defmethod Window change_save_set ( mode, onerror = None ) @end defmethod @defmethod Window reparent ( parent, x, y, onerror = None ) @end defmethod @defmethod Window map ( onerror = None ) @end defmethod @defmethod Window map_sub_windows ( onerror = None ) @end defmethod @defmethod Window unmap ( onerror = None ) @end defmethod @defmethod Window unmap_sub_windows ( onerror = None ) @end defmethod @defmethod Window configure ( onerror = None, **keys ) @end defmethod @defmethod Window circulate ( direction, onerror = None ) @end defmethod @defmethod Window query_tree ( ) Returns Window('root'), Window('parent', (X.NONE, )), List('children', WindowObj), @end defmethod @defmethod Window change_property ( property, type, format, data, mode = X.PropModeReplace, onerror = None ) @end defmethod @defmethod Window delete_property ( property, onerror = None ) @end defmethod @defmethod Window get_property ( property, type, offset, length, delete = 0 ) Returns None or Card32('property_type'), Card8('format'), PropertyData('value'), Card32('bytes_after'), @end defmethod @defmethod Window get_full_property ( property, type, sizehint = 10 ) Returns None or Card32('property_type'), Card8('format'), PropertyData('value'), Card32('bytes_after'), @end defmethod @defmethod Window list_properties ( ) Returns List('atoms', Card32Obj), @end defmethod @defmethod Window set_selection_owner ( selection, time, onerror = None ) @end defmethod @defmethod Window convert_selection ( selection, target, property, time, onerror = None ) @end defmethod @defmethod Window send_event ( event, event_mask = 0, propagate = 0, onerror = None ) @end defmethod @defmethod Window grab_pointer ( owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, time ) Returns Card8('status'), @end defmethod @defmethod Window grab_button ( button, modifiers, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor, onerror = None ) @end defmethod @defmethod Window ungrab_button ( button, modifiers, onerror = None ) @end defmethod @defmethod Window grab_keyboard ( owner_events, pointer_mode, keyboard_mode, time ) Returns Card8('status'), @end defmethod @defmethod Window grab_key ( key, modifiers, owner_events, pointer_mode, keyboard_mode, onerror = None ) @end defmethod @defmethod Window ungrab_key ( key, modifiers, onerror = None ) @end defmethod @defmethod Window query_pointer ( ) Returns Card8('same_screen'), Window('root'), Window('child', (X.NONE, )), Int16('root_x'), Int16('root_y'), Int16('win_x'), Int16('win_y'), Card16('mask'), @end defmethod @defmethod Window get_motion_events ( start, stop ) Returns List('events', structs.TimeCoord), @end defmethod @defmethod Window translate_coords ( src_window, src_x, src_y ) Returns Window('child', (X.NONE, )), Int16('x'), Int16('y'), @end defmethod @defmethod Window warp_pointer ( x, y, src_window = 0, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None ) @end defmethod @defmethod Window set_input_focus ( revert_to, time, onerror = None ) @end defmethod @defmethod Window clear_area ( x = 0, y = 0, width = 0, height = 0, exposures = 0, onerror = None ) @end defmethod @defmethod Window create_colormap ( visual, alloc ) Returns Colormap. @end defmethod @defmethod Window list_installed_colormaps ( ) Returns List('cmaps', ColormapObj), @end defmethod @defmethod Window rotate_properties ( properties, delta, onerror = None ) @end defmethod @defmethod Window set_wm_name ( name, onerror = None ) @end defmethod @defmethod Window get_wm_name ( ) Returns None or string. @end defmethod @defmethod Window set_wm_icon_name ( name, onerror = None ) @end defmethod @defmethod Window get_wm_icon_name ( ) Returns None or string. @end defmethod @defmethod Window set_wm_class ( inst, cls, onerror = None ) @end defmethod @defmethod Window get_wm_class ( ) Returns None or (isntance, class) @end defmethod @defmethod Window set_wm_transient_for ( window, onerror = None ) @end defmethod @defmethod Window get_wm_transient_for ( ) Returns None or Window. @end defmethod @defmethod Window set_wm_protocols ( protocols, onerror = None ) @end defmethod @defmethod Window get_wm_protocols ( ) Returns list of atoms. @end defmethod @defmethod Window set_wm_colormap_windows ( windows, onerror = None ) @end defmethod @defmethod Window get_wm_colormap_windows ( ) Returns list of Windows. @end defmethod @defmethod Window set_wm_client_machine ( name, onerror = None ) @end defmethod @defmethod Window get_wm_client_machine ( ) Returns None or string. @end defmethod @defmethod Window set_wm_normal_hints ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_normal_hints ( ) Returns Card32('flags'), Int32('min_width', default = 0), Int32('min_height', default = 0), Int32('max_width', default = 0), Int32('max_height', default = 0), Int32('width_inc', default = 0), Int32('height_inc', default = 0), Object('min_aspect', Aspect, default = (0, 0)), Object('max_aspect', Aspect, default = (0, 0)), Int32('base_width', default = 0), Int32('base_height', default = 0), Int32('win_gravity', default = 0), @end defmethod @defmethod Window set_wm_hints ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_hints ( ) Returns Card32('flags'), Card32('input', default = 0), Set('initial_state', 4, ( Xutil.NormalState, Xutil.IconicState ), default = Xutil.NormalState), Pixmap('icon_pixmap', default = 0), Window('icon_window', default = 0), Int32('icon_x', default = 0), Int32('icon_y', default = 0), Pixmap('icon_mask', default = 0), Window('window_group', default = 0), @end defmethod @defmethod Window set_wm_state ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_state ( ) Returns Set('state', 4, ( Xutil.WithdrawnState, Xutil.NormalState, Xutil.IconicState )), Window('icon', ( X.NONE, )), @end defmethod @defmethod Window set_wm_icon_size ( hints = {}, onerror = None, **keys ) @end defmethod @defmethod Window get_wm_icon_size ( ) Returns Card32('min_width'), Card32('min_height'), Card32('max_width'), Card32('max_height'), Card32('width_inc'), Card32('height_inc'), @end defmethod @node Pixmap @section Pixmap @code{Pixmap} objects have additional objects, see @ref{Resource} and @ref{Drawable}. @defmethod Pixmap free ( onerror = None ) @end defmethod @defmethod Pixmap create_cursor ( mask, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue), x, y ) Returns Cursor. @end defmethod @node Fontable @section Fontable @code{Fontable} is a base class of @code{GC} and @code{Font} objects. @xref{GC}, and @ref{Font}. @xref{Resource}, for additional methods. @defmethod Fontable query ( ) Returns Object('min_bounds', structs.CharInfo), Object('max_bounds', structs.CharInfo), Card16('min_char_or_byte2'), Card16('max_char_or_byte2'), Card16('default_char'), Card8('draw_direction'), Card8('min_byte1,'), Card8('max_byte1,'), Card8('all_chars_exist'), Int16('font_ascent'), Int16('font_descent'), List('properties', structs.FontProp), List('char_infos', structs.CharInfo), @end defmethod @defmethod Fontable query_text_extents ( string ) Returns Card8('draw_direction'), Int16('font_ascent'), Int16('font_descent'), Int16('overall_ascent'), Int16('overall_descent'), Int32('overall_width'), Int32('overall_left'), Int32('overall_right'), @end defmethod @node GC @section GC @code{GC} objects have additional objects, see @ref{Resource} and @ref{Fontable}. @defmethod GC change ( onerror = None, **keys ) @end defmethod @defmethod GC copy ( src_gc, mask, onerror = None ) @end defmethod @defmethod GC set_dashes ( offset, dashes, onerror = None ) @end defmethod @defmethod GC set_clip_rectangles ( x_origin, y_origin, rectangles, ordering, onerror = None ) @end defmethod @defmethod GC free ( onerror = None ) @end defmethod @node Font @section Font @code{Font} objects have additional objects, see @ref{Resource} and @ref{Fontable}. @defmethod Font close ( onerror = None ) @end defmethod @defmethod Font create_glyph_cursor ( mask, source_char, mask_char, (fore_red, fore_green, fore_blue), (back_red, back_green, back_blue) ) Returns Cursor. @end defmethod python-xlib-0.14+20091101/doc/html/0000755000175000017500000000000011273361453015050 5ustar stewstewpython-xlib-0.14+20091101/doc/html/Makefile0000644000175000017500000000030410770020473016500 0ustar stewstew# Make HTML documentation for Python Xlib include ../src/defs python-xlib_toc.html: $(SRCS) ./texi2html -splitnode -menu $(TOPSRC) ln -sf python-xlib_toc.html index.html clean: rm -f *.html python-xlib-0.14+20091101/doc/html/texi2html0000755000175000017500000015650610770020473016726 0ustar stewsteweval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; 'di '; 'ig 00 '; #+############################################################################## # # # File: texi2html # # # # Description: Program to transform most Texinfo documents to HTML # # # #-############################################################################## # From @(#)texi2html 1.52 01/05/98 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch # This version of texi2html is currently maintained at # ftp://ftp.cs.umb.edu/pub/tex/texi2html by kb@cs.umb.edu. # The man page for this program is included at the end of this file and can be # viewed using the command 'nroff -man texi2html'. # Please read the copyright at the end of the man page. #+++############################################################################ # # # Constants # # # #---############################################################################ $DEBUG_TOC = 1; $DEBUG_INDEX = 2; $DEBUG_BIB = 4; $DEBUG_GLOSS = 8; $DEBUG_DEF = 16; $DEBUG_HTML = 32; $DEBUG_USER = 64; $BIBRE = '\[[\w\/-]+\]'; # RE for a bibliography reference $FILERE = '[\/\w.+-]+'; # RE for a file name $VARRE = '[^\s\{\}]+'; # RE for a variable name $NODERE = '[^@{}:\'`",]+'; # RE for a node name $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names $XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) $ERROR = "***"; # prefix for errors and warnings $THISVERSION = "1.56k"; $THISPROG = "texi2html $THISVERSION"; # program name and version $HOMEPAGE = "http://wwwinfo.cern.ch/dis/texi2html/"; # program home page $TODAY = &pretty_date; # like "20 September 1993" $SPLITTAG = "\n"; # tag to know where to split $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections $html2_doctype = ''; # # language dependent constants # #$LDC_SEE = 'see'; #$LDC_SECTION = 'section'; #$LDC_IN = 'in'; #$LDC_TOC = 'Table of Contents'; #$LDC_GOTO = 'Go to the'; #$LDC_FOOT = 'Footnotes'; # TODO: @def* shortcuts # # pre-defined indices # %predefined_index = ( 'cp', 'c', 'fn', 'f', 'vr', 'v', 'ky', 'k', 'pg', 'p', 'tp', 't', ); # # valid indices # %valid_index = ( 'c', 1, 'f', 1, 'v', 1, 'k', 1, 'p', 1, 't', 1, ); # # texinfo section names to level # %sec2level = ( 'top', 0, 'chapter', 1, 'unnumbered', 1, 'majorheading', 1, 'chapheading', 1, 'appendix', 1, 'section', 2, 'unnumberedsec', 2, 'heading', 2, 'appendixsec', 2, 'appendixsection', 2, 'subsection', 3, 'unnumberedsubsec', 3, 'subheading', 3, 'appendixsubsec', 3, 'subsubsection', 4, 'unnumberedsubsubsec', 4, 'subsubheading', 4, 'appendixsubsubsec', 4, ); # # accent map, TeX command to ISO name # %accent_map = ( '"', 'uml', '~', 'tilde', '^', 'circ', '`', 'grave', '\'', 'acute', ); # # texinfo "simple things" (@foo) to HTML ones # %simple_map = ( # cf. makeinfo.c "*", "
", # HTML+ " ", " ", "\t", " ", "-", "­", # soft hyphen "\n", "\n", "|", "", 'tab', '<\/TD>', # spacing commands ":", "", "!", "!", "?", "?", ".", ".", "-", "", ); # # texinfo "things" (@foo{}) to HTML ones # %things_map = ( 'TeX', 'TeX', 'br', '

', # paragraph break 'bullet', '*', 'copyright', '(C)', 'dots', '...', 'equiv', '==', 'error', 'error-->', 'expansion', '==>', 'minus', '-', 'point', '-!-', 'print', '-|', 'result', '=>', 'today', $TODAY, ); # # texinfo styles (@foo{bar}) to HTML ones # %style_map = ( 'asis', '', 'b', 'B', 'cite', 'CITE', 'code', 'CODE', 'ctrl', '&do_ctrl', # special case 'dfn', 'EM', # DFN tag is illegal in the standard 'dmn', '', # useless 'email', '&do_email', # insert a clickable email address 'emph', 'EM', 'file', '"TT', # will put quotes, cf. &apply_style 'i', 'I', 'kbd', 'KBD', 'key', 'KBD', 'math', 'EM', 'r', '', # unsupported 'samp', '"SAMP', # will put quotes, cf. &apply_style 'sc', '&do_sc', # special case 'strong', 'STRONG', 't', 'TT', 'titlefont', '', # useless 'uref', '&do_uref', # insert a clickable URL 'url', '&do_url', # insert a clickable URL 'var', 'VAR', 'w', '', # unsupported ); # # texinfo format (@foo/@end foo) to HTML ones # %format_map = ( 'display', 'PRE', 'example', 'PRE', 'format', 'PRE', 'lisp', 'PRE', 'quotation', 'BLOCKQUOTE', 'smallexample', 'PRE', 'smalllisp', 'PRE', # lists 'itemize', 'UL', 'enumerate', 'OL', # poorly supported 'flushleft', 'PRE', 'flushright', 'PRE', ); # # texinfo definition shortcuts to real ones # %def_map = ( # basic commands 'deffn', 0, 'defvr', 0, 'deftypefn', 0, 'deftypevr', 0, 'defcv', 0, 'defop', 0, 'deftp', 0, # basic x commands 'deffnx', 0, 'defvrx', 0, 'deftypefnx', 0, 'deftypevrx', 0, 'defcvx', 0, 'defopx', 0, 'deftpx', 0, # shortcuts 'defun', 'deffn Function', 'defmac', 'deffn Macro', 'defspec', 'deffn {Special Form}', 'defvar', 'defvr Variable', 'defopt', 'defvr {User Option}', 'deftypefun', 'deftypefn Function', 'deftypevar', 'deftypevr Variable', 'defivar', 'defcv {Instance Variable}', 'defmethod', 'defop Method', # x shortcuts 'defunx', 'deffnx Function', 'defmacx', 'deffnx Macro', 'defspecx', 'deffnx {Special Form}', 'defvarx', 'defvrx Variable', 'defoptx', 'defvrx {User Option}', 'deftypefunx', 'deftypefnx Function', 'deftypevarx', 'deftypevrx Variable', 'defivarx', 'defcvx {Instance Variable}', 'defmethodx', 'defopx Method', ); # # things to skip # %to_skip = ( # comments 'c', 1, 'comment', 1, 'ifnothtml', 1, # useless 'detailmenu', 1, 'direntry', 1, 'contents', 1, 'shortcontents', 1, 'summarycontents', 1, 'footnotestyle', 1, 'end ifclear', 1, 'end ifset', 1, 'titlepage', 1, 'end titlepage', 1, # unsupported commands (formatting) 'afourpaper', 1, 'cropmarks', 1, 'finalout', 1, 'headings', 1, 'sp', 1, 'need', 1, 'page', 1, 'setchapternewpage', 1, 'everyheading', 1, 'everyfooting', 1, 'evenheading', 1, 'evenfooting', 1, 'oddheading', 1, 'oddfooting', 1, 'smallbook', 1, 'vskip', 1, 'filbreak', 1, 'paragraphindent', 1, # unsupported formats 'cartouche', 1, 'end cartouche', 1, 'group', 1, 'end group', 1, ); #+++############################################################################ # # # Argument parsing, initialisation # # # #---############################################################################ %value = (); # hold texinfo variables, see also -D $use_bibliography = 1; $use_acc = 0; $debug = 0; $doctype = ''; $check = 0; $expandinfo = 0; $use_glossary = 0; $invisible_mark = ''; $use_iso = 0; @include_dirs = (); $show_menu = 0; $number_sections = 0; $split_node = 0; $split_chapter = 0; $monolithic = 0; $verbose = 0; $usage = < 0; ✓ exit; } if (($split_node || $split_chapter) && $monolithic) { warn "Can't use -monolithic with -split, -monolithic ignored.\n"; $monolithic = 0; } if ($expandinfo) { $to_skip{'ifinfo'}++; $to_skip{'end ifinfo'}++; $to_skip{'ifnottex'}++; $to_skip{'end ifnottex'}++; } else { $to_skip{'iftex'}++; $to_skip{'end iftex'}++; } $invisible_mark = '' if $invisible_mark eq 'xbm'; die $usage unless @ARGV == 1; $docu = shift(@ARGV); if ($docu =~ /.*\//) { chop($docu_dir = $&); $docu_name = $'; } else { $docu_dir = '.'; $docu_name = $docu; } unshift(@include_dirs, $docu_dir); $docu_name =~ s/\.te?x(i|info)?$//; # basename of the document $docu_doc = "$docu_name.html"; # document's contents if ($monolithic) { $docu_toc = $docu_foot = $docu_doc; } else { $docu_toc = "${docu_name}_toc.html"; # document's table of contents $docu_foot = "${docu_name}_foot.html"; # document's footnotes } # # variables # $value{'html'} = 1; # predefine html (the output format) $value{'texi2html'} = $THISVERSION; # predefine texi2html (the translator) # _foo: internal to track @foo foreach ('_author', '_title', '_subtitle', '_settitle', '_setfilename') { $value{$_} = ''; # prevent -w warnings } %node2sec = (); # node to section name %node2href = (); # node to HREF %bib2href = (); # bibliography reference to HREF %gloss2href = (); # glossary term to HREF @sections = (); # list of sections %tag2pro = (); # protected sections # # initial indexes # $bib_num = 0; $foot_num = 0; $gloss_num = 0; $idx_num = 0; $sec_num = 0; $doc_num = 0; $html_num = 0; # # can I use ISO8879 characters? (HTML+) # if ($use_iso) { $things_map{'bullet'} = "•"; $things_map{'copyright'} = "©"; $things_map{'dots'} = "…"; $things_map{'equiv'} = "≡"; $things_map{'expansion'} = "→"; $things_map{'point'} = "∗"; $things_map{'result'} = "⇒"; } # # read texi2html extensions (if any) # $extensions = 'texi2html.ext'; # extensions in working directory if (-f $extensions) { print "# reading extensions from $extensions\n" if $verbose; require($extensions); } ($progdir = $0) =~ s/[^\/]+$//; if ($progdir && ($progdir ne './')) { $extensions = "${progdir}texi2html.ext"; # extensions in texi2html directory if (-f $extensions) { print "# reading extensions from $extensions\n" if $verbose; require($extensions); } } print "# reading from $docu\n" if $verbose; #+++############################################################################ # # # Pass 1: read source, handle command, variable, simple substitution # # # #---############################################################################ @lines = (); # whole document @toc_lines = (); # table of contents $toplevel = 0; # top level seen in hierarchy $curlevel = 0; # current level in TOC $node = ''; # current node name $in_table = 0; # am I inside a table $table_type = ''; # type of table ('', 'f', 'v', 'multi') @tables = (); # nested table support $in_bibliography = 0; # am I inside a bibliography $in_glossary = 0; # am I inside a glossary $in_top = 0; # am I inside the top node $in_pre = 0; # am I inside a preformatted section $in_list = 0; # am I inside a list $in_html = 0; # am I inside an HTML section $first_line = 1; # is it the first line $dont_html = 0; # don't protect HTML on this line $split_num = 0; # split index $deferred_ref = ''; # deferred reference for indexes @html_stack = (); # HTML elements stack $html_element = ''; # current HTML element &html_reset; # build code for simple substitutions # the maps used (%simple_map and %things_map) MUST be aware of this # watch out for regexps, / and escaped characters! $subst_code = ''; foreach (keys(%simple_map)) { ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n"; } foreach (keys(%things_map)) { $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n"; } if ($use_acc) { # accentuated characters foreach (keys(%accent_map)) { if ($_ eq "`") { $subst_code .= "s/$;3"; } elsif ($_ eq "'") { $subst_code .= "s/$;4"; } else { $subst_code .= "s/\\\@\\$_"; } $subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n"; } } eval("sub simple_substitutions { $subst_code }"); &init_input; while ($_ = &next_line) { # # remove \input on the first lines only # if ($first_line) { next if /^\\input/; $first_line = 0; } # # parse texinfo tags # $tag = ''; $end_tag = ''; if (/^\s*\@end\s+(\w+)\b/) { $end_tag = $1; } elsif (/^\s*\@(\w+)\b/) { $tag = $1; } # # handle @ifhtml / @end ifhtml # if ($in_html) { if ($end_tag eq 'ifhtml') { $in_html = 0; } else { $tag2pro{$in_html} .= $_; } next; } elsif ($tag eq 'ifhtml') { $in_html = $PROTECTTAG . ++$html_num; push(@lines, $in_html); next; } # # try to skip the line # if ($end_tag) { next if $to_skip{"end $end_tag"}; } elsif ($tag) { next if $to_skip{$tag}; last if $tag eq 'bye'; } if ($in_top) { # parsing the top node if ($tag eq 'node' || $tag eq 'include' || $sec2level{$tag}) { # no more in top $in_top = 0; } else { # skip it next; } } # # try to remove inlined comments # syntax from tex-mode.el comment-start-skip # s/((^|[^\@])(\@\@)*)\@c(omment)? .*/$1/; # non-@ substitutions cf. texinfmt.el unless ($in_pre) { s/``/\"/g; s/''/\"/g; s/([\w ])---([\w ])/$1--$2/g; } # # analyze the tag # if ($tag) { # skip lines &skip_until($tag), next if $tag eq 'ignore'; if ($expandinfo) { &skip_until($tag), next if $tag eq 'iftex'; } else { &skip_until($tag), next if $tag eq 'ifinfo'; } &skip_until($tag), next if $tag eq 'tex'; # handle special tables if ($tag =~ /^(|f|v|multi)table$/) { $table_type = $1; $tag = 'table'; } # special cases if ($tag eq 'top' || ($tag eq 'node' && /^\@node\s+top\s*,/i)) { $in_top = 1; @lines = (); # ignore all lines before top (title page garbage) next; } elsif ($tag eq 'node') { $in_top = 0; warn "$ERROR Bad node line: $_" unless $_ =~ /^\@node\s$NODESRE$/o; $_ = &protect_html($_); # if node contains '&' for instance s/^\@node\s+//; ($node) = split(/,/); &normalise_node($node); if ($split_node) { &next_doc; push(@lines, $SPLITTAG) if $split_num++; push(@sections, $node); } next; } elsif ($tag eq 'include') { if (/^\@include\s+($FILERE)\s*$/o) { $file = $1; unless (-e $file) { foreach $dir (@include_dirs) { $file = "$dir/$1"; last if -e $file; } } if (-e $file) { &open($file); print "# including $file\n" if $verbose; } else { warn "$ERROR Can't find $file, skipping"; } } else { warn "$ERROR Bad include line: $_"; } next; } elsif ($tag eq 'ifclear') { if (/^\@ifclear\s+($VARRE)\s*$/o) { next unless defined($value{$1}); &skip_until($tag); } else { warn "$ERROR Bad ifclear line: $_"; } next; } elsif ($tag eq 'ifset') { if (/^\@ifset\s+($VARRE)\s*$/o) { next if defined($value{$1}); &skip_until($tag); } else { warn "$ERROR Bad ifset line: $_"; } next; } elsif ($tag eq 'menu') { unless ($show_menu) { &skip_until($tag); next; } &html_push_if($tag); push(@lines, &html_debug("\n", __LINE__)); } elsif ($format_map{$tag}) { $in_pre = 1 if $format_map{$tag} eq 'PRE'; &html_push_if($format_map{$tag}); push(@lines, &html_debug("\n", __LINE__)); $in_list++ if $format_map{$tag} eq 'UL' || $format_map{$tag} eq 'OL' ; push(@lines, &debug("<$format_map{$tag}>\n", __LINE__)); next; } elsif ($tag eq 'table') { if (/^\s*\@(|f|v)table\s+\@(\w+)/ || /^\s*\@multitable\s+/) { $in_table = $2; unshift(@tables, join($;, $table_type, $in_table)); if ($table_type eq "multi") { push(@lines, &debug("\n", __LINE__)); &html_push_if('TABLE'); } else { push(@lines, &debug("
\n", __LINE__)); &html_push_if('DL'); } push(@lines, &html_debug("\n", __LINE__)); } else { warn "$ERROR Bad table line: $_"; } next; } elsif ($tag eq 'synindex' || $tag eq 'syncodeindex') { if (/^\@$tag\s+(\w)\w\s+(\w)\w\s*$/) { eval("*${1}index = *${2}index"); } else { warn "$ERROR Bad syn*index line: $_"; } next; } elsif ($tag eq 'sp') { push(@lines, &debug("

\n", __LINE__)); next; } elsif ($tag eq 'setref') { &protect_html; # if setref contains '&' for instance if (/^\@$tag\s*{($NODERE)}\s*$/) { $setref = $1; $setref =~ s/\s+/ /g; # normalize $setref =~ s/ $//; $node2sec{$setref} = $name; $node2href{$setref} = "$docu_doc#$docid"; } else { warn "$ERROR Bad setref line: $_"; } next; } elsif ($tag eq 'defindex' || $tag eq 'defcodeindex') { if (/^\@$tag\s+(\w\w)\s*$/) { $valid_index{$1} = 1; } else { warn "$ERROR Bad defindex line: $_"; } next; } elsif ($tag eq 'lowersections') { local ($sec, $level); while (($sec, $level) = each %sec2level) { $sec2level{$sec} = $level + 1; } next; } elsif ($tag eq 'raisesections') { local ($sec, $level); while (($sec, $level) = each %sec2level) { $sec2level{$sec} = $level - 1; } next; } elsif (defined($def_map{$tag})) { if ($def_map{$tag}) { s/^\@$tag\s+//; $tag = $def_map{$tag}; $_ = "\@$tag $_"; $tag =~ s/\s.*//; } } elsif (defined($user_sub{$tag})) { s/^\@$tag\s+//; $sub = $user_sub{$tag}; print "# user $tag = $sub, arg: $_" if $debug & $DEBUG_USER; if (defined(&$sub)) { chop($_); &$sub($_); } else { warn "$ERROR Bad user sub for $tag: $sub\n"; } next; } if (defined($def_map{$tag})) { s/^\@$tag\s+//; if ($tag =~ /x$/) { # extra definition line $tag = $`; $is_extra = 1; } else { $is_extra = 0; } while (/\{([^\{\}]*)\}/) { # this is a {} construct ($before, $contents, $after) = ($`, $1, $'); # protect spaces $contents =~ s/\s+/$;9/g; # restore $_ protecting {} $_ = "$before$;7$contents$;8$after"; } @args = split(/\s+/, &protect_html($_)); foreach (@args) { s/$;9/ /g; # unprotect spaces s/$;7/\{/g; # ... { s/$;8/\}/g; # ... } } $type = shift(@args); $type =~ s/^\{(.*)\}$/$1/; print "# def ($tag): {$type} ", join(', ', @args), "\n" if $debug & $DEBUG_DEF; $type .= ':'; # it's nicer like this $name = shift(@args); $name =~ s/^\{(.*)\}$/$1/; if ($is_extra) { $_ = &debug("

", __LINE__); } else { $_ = &debug("
\n
", __LINE__); } if ($tag eq 'deffn' || $tag eq 'defvr' || $tag eq 'deftp') { $_ .= "$type $name"; $_ .= " @args" if @args; } elsif ($tag eq 'deftypefn' || $tag eq 'deftypevr' || $tag eq 'defcv' || $tag eq 'defop') { $ftype = $name; $name = shift(@args); $name =~ s/^\{(.*)\}$/$1/; $_ .= "$type $ftype $name"; $_ .= " @args" if @args; } else { warn "$ERROR Unknown definition type: $tag\n"; $_ .= "$type $name"; $_ .= " @args" if @args; } $_ .= &debug("\n
", __LINE__); $name = &unprotect_html($name); if ($tag eq 'deffn' || $tag eq 'deftypefn') { unshift(@input_spool, "\@findex $name\n"); } elsif ($tag eq 'defop') { unshift(@input_spool, "\@findex $name on $ftype\n"); } elsif ($tag eq 'defvr' || $tag eq 'deftypevr' || $tag eq 'defcv') { unshift(@input_spool, "\@vindex $name\n"); } else { unshift(@input_spool, "\@tindex $name\n"); } $dont_html = 1; } } elsif ($end_tag) { if ($format_map{$end_tag}) { $in_pre = 0 if $format_map{$end_tag} eq 'PRE'; $in_list-- if $format_map{$end_tag} eq 'UL' || $format_map{$end_tag} eq 'OL' ; &html_pop_if('LI', 'P'); &html_pop_if(); push(@lines, &debug("\n", __LINE__)); push(@lines, &html_debug("\n", __LINE__)); } elsif ($end_tag =~ /^(|f|v|multi)table$/) { unless (@tables) { warn "$ERROR \@end $end_tag without \@*table\n"; next; } ($table_type, $in_table) = split($;, shift(@tables)); unless ($1 eq $table_type) { warn "$ERROR \@end $end_tag without matching \@$end_tag\n"; next; } if ($table_type eq "multi") { push(@lines, "
\n"); &html_pop_if('TR'); } else { push(@lines, "\n"); &html_pop_if('DD'); } &html_pop_if(); if (@tables) { ($table_type, $in_table) = split($;, $tables[0]); } else { $in_table = 0; } } elsif (defined($def_map{$end_tag})) { push(@lines, &debug("\n", __LINE__)); } elsif ($end_tag eq 'menu') { &html_pop_if(); push(@lines, $_); # must keep it for pass 2 } next; } # # misc things # # protect texi and HTML things &protect_texi; $_ = &protect_html($_) unless $dont_html; $dont_html = 0; # substitution (unsupported things) s/^\@center\s+//g; s/^\@exdent\s+//g; s/\@noindent\s+//g; s/\@refill\s+//g; # other substitutions &simple_substitutions; s/\@value{($VARRE)}/$value{$1}/eg; s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 # # analyze the tag again # if ($tag) { if (defined($sec2level{$tag}) && $sec2level{$tag} > 0) { if (/^\@$tag\s+(.+)$/) { $name = $1; $name =~ s/\s+$//; $level = $sec2level{$tag}; $name = &update_sec_num($tag, $level) . " $name" if $number_sections && $tag !~ /^unnumbered/; if ($tag =~ /heading$/) { push(@lines, &html_debug("\n", __LINE__)); if ($html_element ne 'body') { # We are in a nice pickle here. We are trying to get a H? heading # even though we are not in the body level. So, we convert it to a # nice, bold, line by itself. $_ = &debug("\n\n

$name\n\n", __LINE__); } else { $_ = &debug("$name\n", __LINE__); &html_push_if('body'); } print "# heading, section $name, level $level\n" if $debug & $DEBUG_TOC; } else { if ($split_chapter) { unless ($toplevel) { # first time we see a "section" unless ($level == 1) { warn "$ERROR The first section found is not of level 1: $_"; warn "$ERROR I'll split on sections of level $level...\n"; } $toplevel = $level; } if ($level == $toplevel) { &next_doc; push(@lines, $SPLITTAG) if $split_num++; push(@sections, $name); } } $sec_num++; $docid = "SEC$sec_num"; $tocid = "TOC$sec_num"; # check biblio and glossary $in_bibliography = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*bibliography$/i); $in_glossary = ($name =~ /^([A-Z]|\d+)?(\.\d+)*\s*glossary$/i); # check node if ($node) { if ($node2sec{$node}) { warn "$ERROR Duplicate node found: $node\n"; } else { $node2sec{$node} = $name; $node2href{$node} = "$docu_doc#$docid"; print "# node $node, section $name, level $level\n" if $debug & $DEBUG_TOC; } $node = ''; } else { print "# no node, section $name, level $level\n" if $debug & $DEBUG_TOC; } # update TOC while ($level > $curlevel) { $curlevel++; push(@toc_lines, "

    \n"); } while ($level < $curlevel) { $curlevel--; push(@toc_lines, "
\n"); } $_ = "
  • " . &anchor($tocid, "$docu_doc#$docid", $name, 1); push(@toc_lines, &substitute_style($_)); # update DOC push(@lines, &html_debug("\n", __LINE__)); &html_reset; $_ = "".&anchor($docid, "$docu_toc#$tocid", $name)."\n"; $_ = &debug($_, __LINE__); push(@lines, &html_debug("\n", __LINE__)); } # update DOC foreach $line (split(/\n+/, $_)) { push(@lines, "$line\n"); } next; } else { warn "$ERROR Bad section line: $_"; } } else { # track variables $value{$1} = $2, next if /^\@set\s+($VARRE)\s+(.*)$/o; delete $value{$1}, next if /^\@clear\s+($VARRE)\s*$/o; # store things $value{'_setfilename'} = $1, next if /^\@setfilename\s+(.*)$/; $value{'_settitle'} = $1, next if /^\@settitle\s+(.*)$/; $value{'_author'} .= "$1\n", next if /^\@author\s+(.*)$/; $value{'_subtitle'} .= "$1\n", next if /^\@subtitle\s+(.*)$/; $value{'_title'} .= "$1\n", next if /^\@title\s+(.*)$/; # index if (/^\@(..?)index\s+/) { unless ($valid_index{$1}) { warn "$ERROR Undefined index command: $_"; next; } $id = 'IDX' . ++$idx_num; $index = $1 . 'index'; $what = &substitute_style($'); $what =~ s/\s+$//; print "# found $index for '$what' id $id\n" if $debug & $DEBUG_INDEX; eval(<\n", __LINE__)); push(@lines, &anchor($id, '', $invisible_mark, !$in_pre)); &html_push('P'); } elsif ($html_element eq 'DL' || $html_element eq 'UL' || $html_element eq 'OL' ) { $deferred_ref .= &anchor($id, '', $invisible_mark, !$in_pre) . " "; } next; } # list item if (/^\s*\@itemx?\s+/) { $what = $'; $what =~ s/\s+$//; if ($in_bibliography && $use_bibliography) { if ($what =~ /^$BIBRE$/o) { $id = 'BIB' . ++$bib_num; $bib2href{$what} = "$docu_doc#$id"; print "# found bibliography for '$what' id $id\n" if $debug & $DEBUG_BIB; $what = &anchor($id, '', $what); } } elsif ($in_glossary && $use_glossary) { $id = 'GLOSS' . ++$gloss_num; $entry = $what; $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; $gloss2href{$entry} = "$docu_doc#$id"; print "# found glossary for '$entry' id $id\n" if $debug & $DEBUG_GLOSS; $what = &anchor($id, '', $what); } &html_pop_if('P'); if ($html_element eq 'DL' || $html_element eq 'DD') { if ($things_map{$in_table} && !$what) { # special case to allow @table @bullet for instance push(@lines, &debug("
    $things_map{$in_table}\n", __LINE__)); } else { push(@lines, &debug("
    \@$in_table\{$what\}\n", __LINE__)); } push(@lines, "
    "); &html_push('DD') unless $html_element eq 'DD'; if ($table_type) { # add also an index unshift(@input_spool, "\@${table_type}index $what\n"); } } elsif ($html_element eq 'TABLE') { push(@lines, &debug("$what\n", __LINE__)); &html_push('TR'); } elsif ($html_element eq 'TR') { push(@lines, &debug("\n", __LINE__)); push(@lines, &debug("$what\n", __LINE__)); } else { push(@lines, &debug("
  • $what\n", __LINE__)); &html_push('LI') unless $html_element eq 'LI'; } push(@lines, &html_debug("\n", __LINE__)); if ($deferred_ref) { push(@lines, &debug("$deferred_ref\n", __LINE__)); $deferred_ref = ''; } next; } elsif (/^\@tab\s+(.*)$/) { push(@lines, "$1\n"); next; } } } # paragraph separator if ($_ eq "\n") { next if $#lines >= 0 && $lines[$#lines] eq "\n"; if ($html_element eq 'P') { push(@lines, "\n"); $_ = &debug("\n", __LINE__); &html_pop; } } elsif ($html_element eq 'body' || $html_element eq 'BLOCKQUOTE') { push(@lines, "

    \n"); &html_push('P'); $_ = &debug($_, __LINE__); } # otherwise push(@lines, $_); } # finish TOC $level = 0; while ($level < $curlevel) { $curlevel--; push(@toc_lines, "\n"); } print "# end of pass 1\n" if $verbose; #+++############################################################################ # # # Pass 2/3: handle style, menu, index, cross-reference # # # #---############################################################################ @lines2 = (); # whole document (2nd pass) @lines3 = (); # whole document (3rd pass) $in_menu = 0; # am I inside a menu while (@lines) { $_ = shift(@lines); # # special case (protected sections) # if (/^$PROTECTTAG/o) { push(@lines2, $_); next; } # # menu # $in_menu = 1, push(@lines2, &debug("

      \n", __LINE__)), next if /^\@menu\b/; $in_menu = 0, push(@lines2, &debug("
    \n", __LINE__)), next if /^\@end\s+menu\b/; if ($in_menu) { if (/^\*\s+($NODERE)::/o) { $descr = $'; chop($descr); &menu_entry($1, $1, $descr); } elsif (/^\*\s+(.+):\s+([^\t,\.\n]+)[\t,\.\n]/) { $descr = $'; chop($descr); &menu_entry($1, $2, $descr); } elsif (/^\*/) { warn "$ERROR Bad menu line: $_"; } else { # description continued? push(@lines2, $_); } next; } # # printindex # if (/^\@printindex\s+(\w\w)\b/) { local($index, *ary, @keys, $key, $letter, $last_letter, @refs); if ($predefined_index{$1}) { $index = $predefined_index{$1} . 'index'; } else { $index = $1 . 'index'; } eval("*ary = *$index"); @keys = keys(%ary); foreach $key (@keys) { $_ = $key; 1 while s/<(\w+)>\`(.*)\'<\/\1>/$2/; # remove HTML tags with quotes 1 while s/<(\w+)>(.*)<\/\1>/$2/; # remove HTML tags $_ = &unprotect_html($_); &unprotect_texi; tr/A-Z/a-z/; # lowercase $key2alpha{$key} = $_; print "# index $key sorted as $_\n" if $key ne $_ && $debug & $DEBUG_INDEX; } push(@lines2, "Jump to:\n"); $last_letter = undef; foreach $key (sort byalpha @keys) { $letter = substr($key2alpha{$key}, 0, 1); $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; if (!defined($last_letter) || $letter ne $last_letter) { push(@lines2, "-\n") if defined($last_letter); push(@lines2, "" . &protect_html($letter) . "\n"); $last_letter = $letter; } } push(@lines2, "

    \n"); $last_letter = undef; foreach $key (sort byalpha @keys) { $letter = substr($key2alpha{$key}, 0, 1); $letter = substr($key2alpha{$key}, 0, 2) if $letter eq $;; if (!defined($last_letter) || $letter ne $last_letter) { push(@lines2, "\n") if defined($last_letter); push(@lines2, "

    " . &protect_html($letter) . "

    \n"); push(@lines2, "\n"); $last_letter = $letter; } @refs = (); foreach (split(/$;/, $ary{$key})) { push(@refs, &anchor('', $_, $key, 0)); } push(@lines2, "
  • " . join(", ", @refs) . "\n"); } push(@lines2, "
  • \n") if defined($last_letter); next; } # # simple style substitutions # $_ = &substitute_style($_); # # xref # while (/\@(x|px|info|)ref{($XREFRE)(}?)/o) { # note: Texinfo may accept other characters ($type, $nodes, $full) = ($1, $2, $3); ($before, $after) = ($`, $'); if (! $full && $after) { warn "$ERROR Bad xref (no ending } on line): $_"; $_ = "$before$;0${type}ref\{$nodes$after"; next; # while xref } if ($type eq 'x') { $type = 'See '; } elsif ($type eq 'px') { $type = 'see '; } elsif ($type eq 'info') { $type = 'See Info'; } else { $type = ''; } unless ($full) { $next = shift(@lines); $next = &substitute_style($next); chop($nodes); # remove final newline if ($next =~ /\}/) { # split on 2 lines $nodes .= " $`"; $after = $'; } else { $nodes .= " $next"; $next = shift(@lines); $next = &substitute_style($next); chop($nodes); if ($next =~ /\}/) { # split on 3 lines $nodes .= " $`"; $after = $'; } else { warn "$ERROR Bad xref (no ending }): $_"; $_ = "$before$;0xref\{$nodes$after"; unshift(@lines, $next); next; # while xref } } } $nodes =~ s/\s+/ /g; # remove useless spaces @args = split(/\s*,\s*/, $nodes); $node = $args[0]; # the node is always the first arg &normalise_node($node); $sec = $node2sec{$node}; if (@args == 5) { # reference to another manual $sec = $args[2] || $node; $man = $args[4] || $args[3]; $_ = "${before}${type}section `$sec' in \@cite{$man}$after"; } elsif ($type =~ /Info/) { # inforef warn "$ERROR Wrong number of arguments: $_" unless @args == 3; ($nn, $_, $in) = @args; $_ = "${before}${type} file `$in', node `$nn'$after"; } elsif ($sec) { $href = $node2href{$node}; $_ = "${before}${type}section " . &anchor('', $href, $sec) . $after; } else { warn "$ERROR Undefined node ($node): $_"; $_ = "$before$;0xref{$nodes}$after"; } } if (/^\@image\s*{/) { s/\@image\s*{//; my (@args) = split (/,/); my $base = $args[0]; my $image; if (-r "$base.jpg") { $image = "$base.jpg"; } elsif (-r "$base.png") { $image = "$base.png"; } elsif (-r "$base.gif") { $image = "$base.gif"; } else { warn "$ERROR no image file for $base: $_"; } $_ = "\"$base\""; } # # try to guess bibliography references or glossary terms # unless (/^/) { $done .= $pre . &anchor('', $href, $what); } else { $done .= "$pre$what"; } $_ = $post; } $_ = $done . $_; } if ($use_glossary) { $done = ''; while (/\b\w+\b/) { ($pre, $what, $post) = ($`, $&, $'); $entry = $what; $entry =~ tr/A-Z/a-z/ unless $entry =~ /^[A-Z\s]+$/; $href = $gloss2href{$entry}; if (defined($href) && $post !~ /^[^<]*<\/A>/) { $done .= $pre . &anchor('', $href, $what); } else { $done .= "$pre$what"; } $_ = $post; } $_ = $done . $_; } } # otherwise push(@lines2, $_); } print "# end of pass 2\n" if $verbose; # # split style substitutions # while (@lines2) { $_ = shift(@lines2); # # special case (protected sections) # if (/^$PROTECTTAG/o) { push(@lines3, $_); next; } # # split style substitutions # $old = ''; while ($old ne $_) { $old = $_; if (/\@(\w+)\{/) { ($before, $style, $after) = ($`, $1, $'); if (defined($style_map{$style})) { $_ = $after; $text = ''; $after = ''; $failed = 1; while (@lines2) { if (/\}/) { $text .= $`; $after = $'; $failed = 0; last; } else { $text .= $_; $_ = shift(@lines2); } } if ($failed) { die "* Bad syntax (\@$style) after: $before\n"; } else { $text = &apply_style($style, $text); $_ = "$before$text$after"; } } } } # otherwise push(@lines3, $_); } print "# end of pass 3\n" if $verbose; #+++############################################################################ # # # Pass 4: foot notes, final cleanup # # # #---############################################################################ @foot_lines = (); # footnotes @doc_lines = (); # final document $end_of_para = 0; # true if last line is

    while (@lines3) { $_ = shift(@lines3); # # special case (protected sections) # if (/^$PROTECTTAG/o) { push(@doc_lines, $_); $end_of_para = 0; next; } # # footnotes # while (/\@footnote([^\{\s]+)\{/) { ($before, $d, $after) = ($`, $1, $'); $_ = $after; $text = ''; $after = ''; $failed = 1; while (@lines3) { if (/\}/) { $text .= $`; $after = $'; $failed = 0; last; } else { $text .= $_; $_ = shift(@lines3); } } if ($failed) { die "* Bad syntax (\@footnote) after: $before\n"; } else { $foot_num++; $docid = "DOCF$foot_num"; $footid = "FOOT$foot_num"; $foot = "($foot_num)"; push(@foot_lines, "

    " . &anchor($footid, "$d#$docid", $foot) . "

    \n"); $text = "

    $text" unless $text =~ /^\s*

    /; push(@foot_lines, "$text\n"); $_ = $before . &anchor($docid, "$docu_foot#$footid", $foot) . $after; } } # # remove unnecessary

    # if (/^\s*

    \s*$/) { next if $end_of_para++; } else { $end_of_para = 0; } # otherwise push(@doc_lines, $_); } print "# end of pass 4\n" if $verbose; #+++############################################################################ # # # Pass 5: print things # # # #---############################################################################ $header = < EOT $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; $title = $value{'_settitle'} || $full_title; $_ = &substitute_style($full_title); &unprotect_texi; s/\n$//; # rmv last \n (if any) $full_title = "

    " . join("

    \n

    ", split(/\n/, $_)) . "

    \n"; # # print ToC # if (!$monolithic && @toc_lines) { if (open(FILE, "> $docu_toc")) { print "# creating $docu_toc...\n" if $verbose; &print_toplevel_header("$title - Table of Contents"); &print_ruler; &print(*toc_lines, FILE); &print_toplevel_footer; close(FILE); } else { warn "$ERROR Can't write to $docu_toc: $!\n"; } } # # print footnotes # if (!$monolithic && @foot_lines) { if (open(FILE, "> $docu_foot")) { print "# creating $docu_foot...\n" if $verbose; &print_toplevel_header("$title - Footnotes"); &print_ruler; &print(*foot_lines, FILE); &print_toplevel_footer; close(FILE); } else { warn "$ERROR Can't write to $docu_foot: $!\n"; } } # # print document # if ($split_chapter || $split_node) { # split $doc_num = 0; $last_num = scalar(@sections); $first_doc = &doc_name(1); $last_doc = &doc_name($last_num); while (@sections) { $section = shift(@sections); &next_doc; if (open(FILE, "> $docu_doc")) { print "# creating $docu_doc...\n" if $verbose; &print_header("$title - $section"); $prev_doc = ($doc_num == 1 ? undef : &doc_name($doc_num - 1)); $next_doc = ($doc_num == $last_num ? undef : &doc_name($doc_num + 1)); $navigation = "Go to the "; $navigation .= ($prev_doc ? &anchor('', $first_doc, "first") : "first"); $navigation .= ", "; $navigation .= ($prev_doc ? &anchor('', $prev_doc, "previous") : "previous"); $navigation .= ", "; $navigation .= ($next_doc ? &anchor('', $next_doc, "next") : "next"); $navigation .= ", "; $navigation .= ($next_doc ? &anchor('', $last_doc, "last") : "last"); $navigation .= " section, " . &anchor('', $docu_toc, "table of contents") . ".\n"; print FILE $navigation; &print_ruler; # find corresponding lines @tmp_lines = (); while (@doc_lines) { $_ = shift(@doc_lines); last if ($_ eq $SPLITTAG); push(@tmp_lines, $_); } &print(*tmp_lines, FILE); &print_ruler; print FILE $navigation; &print_footer; close(FILE); } else { warn "$ERROR Can't write to $docu_doc: $!\n"; } } } else { # not split if (open(FILE, "> $docu_doc")) { print "# creating $docu_doc...\n" if $verbose; if ($monolithic || !@toc_lines) { &print_toplevel_header($title); } else { &print_header($title); print FILE $full_title; } if ($monolithic && @toc_lines) { &print_ruler; print FILE "

    Table of Contents

    \n"; &print(*toc_lines, FILE); } &print_ruler; &print(*doc_lines, FILE); if ($monolithic && @foot_lines) { &print_ruler; print FILE "

    Footnotes

    \n"; &print(*foot_lines, FILE); } if ($monolithic || !@toc_lines) { &print_toplevel_footer; } else { &print_footer; } close(FILE); } else { warn "$ERROR Can't write to $docu_doc: $!\n"; } } print "# that's all folks\n" if $verbose; #+++############################################################################ # # # Low level functions # # # #---############################################################################ sub update_sec_num { local($name, $level) = @_; my $ret; $level--; # here we start at 0 if ($name =~ /^appendix/) { # appendix style if (defined(@appendix_sec_num)) { &incr_sec_num($level, @appendix_sec_num); } else { @appendix_sec_num = ('A', 0, 0, 0); } $ret = join('.', @appendix_sec_num[0..$level]); } else { # normal style if (defined(@normal_sec_num)) { &incr_sec_num($level, @normal_sec_num); } else { @normal_sec_num = (1, 0, 0, 0); } $ret = join('.', @normal_sec_num[0..$level]); } $ret .= "." if $level == 0; return $ret; } sub incr_sec_num { local($level, $l); $level = shift(@_); $_[$level]++; foreach $l ($level+1 .. 3) { $_[$l] = 0; } } sub check { local($_, %seen, %context, $before, $match, $after); while (<>) { if (/\@(\*|\.|\:|\@|\{|\})/) { $seen{$&}++; $context{$&} .= "> $_" if $verbose; $_ = "$`XX$'"; redo; } if (/\@(\w+)/) { ($before, $match, $after) = ($`, $&, $'); if ($before =~ /\b[\w-]+$/ && $after =~ /^[\w-.]*\b/) { # e-mail address $seen{'e-mail address'}++; $context{'e-mail address'} .= "> $_" if $verbose; } else { $seen{$match}++; $context{$match} .= "> $_" if $verbose; } $match =~ s/^\@/X/; $_ = "$before$match$after"; redo; } } foreach (sort(keys(%seen))) { if ($verbose) { print "$_\n"; print $context{$_}; } else { print "$_ ($seen{$_})\n"; } } } sub open { local($name) = @_; ++$fh_name; if (open($fh_name, $name)) { unshift(@fhs, $fh_name); } else { warn "$ERROR Can't read file $name: $!\n"; } } sub init_input { @fhs = (); # hold the file handles to read @input_spool = (); # spooled lines to read $fh_name = 'FH000'; &open($docu); } sub next_line { local($fh, $line); if (@input_spool) { $line = shift(@input_spool); return($line); } while (@fhs) { $fh = $fhs[0]; $line = <$fh>; return($line) if $line; close($fh); shift(@fhs); } return(undef); } # used in pass 1, use &next_line sub skip_until { local($tag) = @_; local($_); while ($_ = &next_line) { return if /^\@end\s+$tag\s*$/; } die "* Failed to find '$tag' after: " . $lines[$#lines]; } # # HTML stacking to have a better HTML output # sub html_reset { @html_stack = ('html'); $html_element = 'body'; } sub html_push { local($what) = @_; push(@html_stack, $html_element); $html_element = $what; } sub html_push_if { local($what) = @_; push(@html_stack, $html_element) if ($html_element && $html_element ne 'P'); $html_element = $what; } sub html_pop { $html_element = pop(@html_stack); } sub html_pop_if { local($elt); if (@_) { foreach $elt (@_) { if ($elt eq $html_element) { $html_element = pop(@html_stack) if @html_stack; last; } } } else { $html_element = pop(@html_stack) if @html_stack; } } sub html_debug { local($what, $line) = @_; return("$what") if $debug & $DEBUG_HTML; return($what); } # to debug the output... sub debug { local($what, $line) = @_; return("$what") if $debug & $DEBUG_HTML; return($what); } sub normalise_node { $_[0] =~ s/\s+/ /g; $_[0] =~ s/ $//; $_[0] =~ s/^ //; } sub menu_entry { local($entry, $node, $descr) = @_; local($href); &normalise_node($node); $href = $node2href{$node}; if ($href) { $descr =~ s/^\s+//; $descr = ": $descr" if $descr; push(@lines2, "
  • " . &anchor('', $href, $entry) . "$descr\n"); } else { warn "$ERROR Undefined node ($node): $_"; } } sub do_ctrl { "^$_[0]" } sub do_email { local($addr, $text) = split(/,\s*/, $_[0]); $text = $addr unless $text; &anchor('', "mailto:$addr", $text); } sub do_sc { "\U$_[0]\E" } sub do_uref { local($url, $text) = split(/,\s*/, $_[0]); $text = $url unless $text; &anchor('', $url, $text); } sub do_url { &anchor('', $_[0], $_[0]) } sub apply_style { local($texi_style, $text) = @_; local($style); $style = $style_map{$texi_style}; if (defined($style)) { # known style if ($style =~ /^\"/) { # add quotes $style = $'; $text = "\`$text\'"; } if ($style =~ /^\&/) { # custom $style = $'; $text = &$style($text); } elsif ($style) { # good style $text = "<$style>$text"; } else { # no style } } else { # unknown style $text = undef; } return($text); } # remove Texinfo styles sub remove_style { local($_) = @_; s/\@\w+{([^\{\}]+)}/$1/g; return($_); } sub substitute_style { local($_) = @_; local($changed, $done, $style, $text); $changed = 1; while ($changed) { $changed = 0; $done = ''; while (/\@(\w+){([^\{\}]+)}/) { $text = &apply_style($1, $2); if ($text) { $_ = "$`$text$'"; $changed = 1; } else { $done .= "$`\@$1"; $_ = "{$2}$'"; } } $_ = $done . $_; } return($_); } sub anchor { local($name, $href, $text, $newline) = @_; local($result); $result = "

    \n"; } sub print_header { local($_); # clean the title $_ = &remove_style($_[0]); &unprotect_texi; # print the header if ($doctype eq 'html2') { print FILE $html2_doctype; } elsif ($doctype) { print FILE $doctype; } print FILE < $header $_ EOT } sub print_toplevel_header { local($_); &print_header; # pass given arg... print FILE $full_title; if ($value{'_subtitle'}) { $value{'_subtitle'} =~ s/\n+$//; foreach (split(/\n/, $value{'_subtitle'})) { $_ = &substitute_style($_); &unprotect_texi; print FILE "

    $_

    \n"; } } if ($value{'_author'}) { $value{'_author'} =~ s/\n+$//; foreach (split(/\n/, $value{'_author'})) { $_ = &substitute_style($_); &unprotect_texi; s/[\w.-]+\@[\w.-]+/
    $&<\/A>/g; print FILE "
    $_
    \n"; } } print FILE "

    \n"; } sub print_footer { print FILE < EOT } sub print_toplevel_footer { &print_ruler; print FILE <texi2html $value{texi2html}. EOT &print_footer; } sub protect_texi { # protect @ { } ` ' s/\@\@/$;0/go; s/\@\{/$;1/go; s/\@\}/$;2/go; s/\@\`/$;3/go; s/\@\'/$;4/go; } sub protect_html { local($what) = @_; # protect & < > $what =~ s/\&/\&\#38;/g; $what =~ s/\/\&\#62;/g; # but recognize some HTML things $what =~ s/\&\#60;\/A\&\#62;/<\/A>/g; # $what =~ s/\&\#60;A ([^\&]+)\&\#62;//g; # $what =~ s/\&\#60;IMG ([^\&]+)\&\#62;//g; # return($what); } sub unprotect_texi { s/$;0/\@/go; s/$;1/\{/go; s/$;2/\}/go; s/$;3/\`/go; s/$;4/\'/go; } sub unprotect_html { local($what) = @_; $what =~ s/\&\#38;/\&/g; $what =~ s/\&\#60;/\/g; return($what); } sub byalpha { $key2alpha{$a} cmp $key2alpha{$b}; } ############################################################################## # These next few lines are legal in both Perl and nroff. .00 ; # finish .ig 'di \" finish diversion--previous line must be blank .nr nl 0-1 \" fake up transition to first page again .nr % 0 \" start at page 1 '; __END__ ############# From here on it's a standard manual page ############ .TH TEXI2HTML 1 "01/05/98" .AT 3 .SH NAME texi2html \- a Texinfo to HTML converter .SH SYNOPSIS .B texi2html [options] file .PP .B texi2html -check [-verbose] files .SH DESCRIPTION .I Texi2html converts the given Texinfo file to a set of HTML files. It tries to handle most of the Texinfo commands. It creates hypertext links for cross-references, footnotes... .PP It also tries to add links from a reference to its corresponding entry in the bibliography (if any). It may also handle a glossary (see the .B \-glossary option). .PP .I Texi2html creates several files depending on the contents of the Texinfo file and on the chosen options (see FILES). .PP The HTML files created by .I texi2html are closer to TeX than to Info, that's why .I texi2html converts @iftex sections and not @ifinfo ones by default. You can reverse this with the \-expandinfo option. .SH OPTIONS .TP 12 .B \-check Check the given file and give the list of all things that may be Texinfo commands. This may be used to check the output of .I texi2html to find the Texinfo commands that have been left in the HTML file. .TP .B \-expandinfo Expand @ifinfo sections, not @iftex ones. .TP .B \-glossary Use the section named 'Glossary' to build a list of terms and put links in the HTML document from each term toward its definition. .TP .B \-invisible \fIname\fP Use \fIname\fP to create invisible destination anchors for index links (you can for instance use the invisible.xbm file shipped with this program). This is a workaround for a known bug of many WWW browsers, including netscape. .TP .B \-I \fIdir\fP Look also in \fIdir\fP to find included files. .TP .B \-menu Show the Texinfo menus; by default they are ignored. .TP .B \-monolithic Output only one file, including the table of contents and footnotes. .TP .B \-number Number the sections. .TP .B \-split_chapter Split the output into several HTML files (one per main section: chapter, appendix...). .TP .B \-split_node Split the output into several HTML files (one per node). .TP .B \-usage Print usage instructions, listing the current available command-line options. .TP .B \-verbose Give a verbose output. Can be used with the .B \-check option. .PP .SH FILES By default .I texi2html creates the following files (foo being the name of the Texinfo file): .TP 16 .B foo_toc.html The table of contents. .TP .B foo.html The document's contents. .TP .B foo_foot.html The footnotes (if any). .PP When used with the .B \-split option, it creates several files (one per chapter or node), named .B foo_n.html (n being the indice of the chapter or node), instead of the single .B foo.html file. .PP When used with the .B \-monolithic option, it creates only one file: .B foo.html .SH VARIABLES .I texi2html predefines the following variables: \fBhtml\fP, \fBtexi2html\fP. .SH ADDITIONAL COMMANDS .I texi2html implements the following non-Texinfo commands (maybe they are in Texinfo now...): .TP 16 .B @ifhtml This indicates the start of an HTML section, this section will passed through without any modification. .TP .B @end ifhtml This indicates the end of an HTML section. .SH VERSION This is \fItexi2html\fP version 1.56k, 1999-02-20. .PP The latest version of \fItexi2html\fP can be found in WWW, cf. URLs http://wwwinfo.cern.ch/dis/texi2html/ .br http://texinfo.org/texi2html/ .SH AUTHOR The main author is Lionel Cons, CERN IT/DIS/OSE, Lionel.Cons@cern.ch. Many other people around the net contributed to this program. .SH COPYRIGHT This program is the intellectual property of the European Laboratory for Particle Physics (known as CERN). No guarantee whatsoever is provided by CERN. No liability whatsoever is accepted for any loss or damage of any kind resulting from any defect or inaccuracy in this information or code. .PP CERN, 1211 Geneva 23, Switzerland .SH "SEE ALSO" GNU Texinfo Documentation Format, HyperText Markup Language (HTML), World Wide Web (WWW). .SH BUGS This program does not understand all Texinfo commands (yet). .PP TeX specific commands (normally enclosed in @iftex) will be passed unmodified. .ex python-xlib-0.14+20091101/doc/info/0000755000175000017500000000000011273361453015037 5ustar stewstewpython-xlib-0.14+20091101/doc/info/Makefile0000644000175000017500000000025610770020473016475 0ustar stewstew# Make info documentation for Python Xlib include ../src/defs python-xlib.info: $(SRCS) makeinfo --force --no-split -P $(SRCDIR) $(TOPSRC) clean: rm -f python-xlib.info python-xlib-0.14+20091101/doc/ps/0000755000175000017500000000000011273361453014526 5ustar stewstewpython-xlib-0.14+20091101/doc/ps/Makefile0000644000175000017500000000072410770020473016164 0ustar stewstew# Make postscript documentation for Python Xlib include ../src/defs python-xlib.ps: python-xlib.dvi dvips -o python-xlib.ps python-xlib.dvi python-xlib.dvi: $(SRCS) if test -f python-xlib.aux; then \ cp python-xlib.aux python-xlib.auxtmp; \ else touch python-xlib.auxtmp; fi texi2dvi -b $(TOPSRC) # If xref has changed, rebuild again to catch them cmp python-xlib.aux python-xlib.auxtmp || texi2dvi -b $(TOPSRC) clean: rm -f python-xlib.* python-xlib-0.14+20091101/doc/Makefile0000644000175000017500000000033710770020473015542 0ustar stewstew# Top-level makefile for Python Xlib documentation FORMATS = info ps html all: $(FORMATS) info:: (cd info; make) ps:: (cd ps; make) html:: (cd html; make) clean: for f in $(FORMATS); do (cd $$f; make clean); done