コード例 #1
0
ファイル: display.py プロジェクト: victorssilva/cghs-PIano
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)
コード例 #2
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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),
        )
コード例 #3
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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'),
        )
コード例 #4
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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'),
        )
コード例 #5
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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'),
        )
コード例 #6
0
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'),
    )
コード例 #7
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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'),
        )
コード例 #8
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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),
        )
コード例 #9
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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),
        )
コード例 #10
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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),
        )
コード例 #11
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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'),
        )
コード例 #12
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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),
        )
コード例 #13
0
ファイル: request.py プロジェクト: victorssilva/cghs-PIano
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)