# Xlib.ext.xinput -- XInput extension module
#
#    Copyright (C) 2012 Outpost Embedded, LLC
#      Forest Bond <forest.bond@rapidrollout.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1
# of the License, or (at your option) any later version.
#
# This library 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
#    Free Software Foundation, Inc.,
#    59 Temple Place,
#    Suite 330,
#    Boston, MA 02111-1307 USA

'''
A very incomplete implementation of the XInput extension.
'''

import sys
import array
import struct

# Python 2/3 compatibility.
from six import integer_types

from Xlib.protocol import rq
from Xlib import X


extname = 'XInputExtension'

PropertyDeleted = 0
PropertyCreated = 1
PropertyModified = 2

NotifyNormal = 0
NotifyGrab = 1
NotifyUngrab = 2
NotifyWhileGrabbed = 3
NotifyPassiveGrab = 4
NotifyPassiveUngrab = 5

NotifyAncestor = 0
NotifyVirtual = 1
NotifyInferior = 2
NotifyNonlinear = 3
NotifyNonlinearVirtual = 4
NotifyPointer = 5
NotifyPointerRoot = 6
NotifyDetailNone = 7

GrabtypeButton = 0
GrabtypeKeycode = 1
GrabtypeEnter = 2
GrabtypeFocusIn = 3
GrabtypeTouchBegin = 4

AnyModifier = (1 << 31)
AnyButton = 0
AnyKeycode = 0

AsyncDevice = 0
SyncDevice = 1
ReplayDevice = 2
AsyncPairedDevice = 3
AsyncPair = 4
SyncPair = 5

SlaveSwitch = 1
DeviceChange = 2

MasterAdded = (1 << 0)
MasterRemoved = (1 << 1)
SlaveAdded = (1 << 2)
SlaveRemoved = (1 << 3)
SlaveAttached = (1 << 4)
SlaveDetached = (1 << 5)
DeviceEnabled = (1 << 6)
DeviceDisabled = (1 << 7)

AddMaster = 1
RemoveMaster = 2
AttachSlave = 3
DetachSlave = 4

AttachToMaster = 1
Floating = 2

ModeRelative = 0
ModeAbsolute = 1

MasterPointer = 1
MasterKeyboard = 2
SlavePointer = 3
SlaveKeyboard = 4
FloatingSlave = 5

KeyClass = 0
ButtonClass = 1
ValuatorClass = 2
ScrollClass = 3
TouchClass = 8

KeyRepeat = (1 << 16)

AllDevices = 0
AllMasterDevices = 1

DeviceChanged = 1
KeyPress = 2
KeyRelease = 3
ButtonPress = 4
ButtonRelease = 5
Motion = 6
Enter = 7
Leave = 8
FocusIn = 9
FocusOut = 10
HierarchyChanged = 11
PropertyEvent = 12
RawKeyPress = 13
RawKeyRelease = 14
RawButtonPress = 15
RawButtonRelease = 16
RawMotion = 17

DeviceChangedMask = (1 << DeviceChanged)
KeyPressMask = (1 << KeyPress)
KeyReleaseMask = (1 << KeyRelease)
ButtonPressMask = (1 << ButtonPress)
ButtonReleaseMask = (1 << ButtonRelease)
MotionMask = (1 << Motion)
EnterMask = (1 << Enter)
LeaveMask = (1 << Leave)
FocusInMask = (1 << FocusIn)
FocusOutMask = (1 << FocusOut)
HierarchyChangedMask = (1 << HierarchyChanged)
PropertyEventMask = (1 << PropertyEvent)
RawKeyPressMask = (1 << RawKeyPress)
RawKeyReleaseMask = (1 << RawKeyRelease)
RawButtonPressMask = (1 << RawButtonPress)
RawButtonReleaseMask = (1 << RawButtonRelease)
RawMotionMask = (1 << RawMotion)

GrabModeSync = 0
GrabModeAsync = 1
GrabModeTouch = 2

DEVICEID = rq.Card16
DEVICE = rq.Card16
DEVICEUSE = rq.Card8

class FP1616(rq.Int32):

    def check_value(self, value):
        return int(value * 65536.0)

    def parse_value(self, value, display):
        return float(value) / float(1 << 16)

class FP3232(rq.ValueField):
    structcode = 'lL'
    structvalues = 2

    def check_value(self, value):
        return value

    def parse_value(self, value, display):
        integral, frac = value
        ret = float(integral)
        # optimised math.ldexp(float(frac), -32)
        ret += float(frac) * (1.0 / (1 << 32))
        return ret

class XIQueryVersion(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(47),
        rq.RequestLength(),
        rq.Card16('major_version'),
        rq.Card16('minor_version'),
        )
    _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 XIQueryVersion(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        major_version=2,
        minor_version=0,
        )

class Mask(rq.List):

    def __init__(self, name):
        rq.List.__init__(self, name, rq.Card32, pad=0)

    def pack_value(self, val):

        mask_seq = array.array(rq.struct_to_array_codes['L'])

        if isinstance(val, integer_types):
            # We need to build a "binary mask" that (as far as I can tell) is
            # encoded in native byte order from end to end.  The simple case is
            # with a single unsigned 32-bit value, for which we construct an
            # array with just one item.  For values too big to fit inside 4
            # bytes we build a longer array, being careful to maintain native
            # byte order across the entire set of values.
            if sys.byteorder == 'little':
                def fun(val):
                    mask_seq.insert(0, val)
            elif sys.byteorder == 'big':
                fun = mask_seq.append
            else:
                raise AssertionError(sys.byteorder)
            while val:
                fun(val & 0xFFFFFFFF)
                val = val >> 32
        else:
            mask_seq.extend(val)

        return mask_seq.tostring(), len(mask_seq), None

EventMask = rq.Struct(
    DEVICE('deviceid'),
    rq.LengthOf('mask', 2),
    Mask('mask'),
)


class XISelectEvents(rq.Request):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(46),
        rq.RequestLength(),
        rq.Window('window'),
        rq.LengthOf('masks', 2),
        rq.Pad(2),
        rq.List('masks', EventMask),
    )

def select_events(self, event_masks):
    '''
    select_events(event_masks)

    event_masks:
      Sequence of (deviceid, mask) pairs, where deviceid is a numerical device
      ID, or AllDevices or AllMasterDevices, and mask is either an unsigned
      integer or sequence of 32 bits unsigned values
    '''
    return XISelectEvents(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        window=self,
        masks=event_masks,
    )

AnyInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.Pad(2),
)

class ButtonMask(object):

    def __init__(self, value, length):
        self._value = value
        self._length = length

    def __len__(self):
        return self._length

    def __getitem__(self, key):
        return self._value & (1 << key)

    def __str__(self):
        return repr(self)

    def __repr__(self):
        return '0b{value:0{width}b}'.format(value=self._value,
                                            width=self._length)

class ButtonState(rq.ValueField):

    structcode = None

    def __init__(self, name):
        rq.ValueField.__init__(self, name)

    def parse_binary_value(self, data, display, length, fmt):
        # Mask: bitfield of <length> button states.
        mask_len = 4 * ((((length + 7) >> 3) + 3) >> 2)
        mask_data = data[:mask_len]
        mask_value = 0
        for byte in reversed(struct.unpack('={0:d}B'.format(mask_len), mask_data)):
            mask_value <<= 8
            mask_value |= byte
        data = data[mask_len:]
        assert (mask_value & 1) == 0
        return ButtonMask(mask_value >> 1, length), data

ButtonInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.LengthOf(('state', 'labels'), 2),
    ButtonState('state'),
    rq.List('labels', rq.Card32),
)

KeyInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.LengthOf('keycodes', 2),
    rq.List('keycodes', rq.Card32),
)

ValuatorInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.Card16('number'),
    rq.Card32('label'),
    FP3232('min'),
    FP3232('max'),
    FP3232('value'),
    rq.Card32('resolution'),
    rq.Card8('mode'),
    rq.Pad(3),
)

ScrollInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.Card16('number'),
    rq.Card16('scroll_type'),
    rq.Pad(2),
    rq.Card32('flags'),
    FP3232('increment'),
)

TouchInfo = rq.Struct(
    rq.Card16('type'),
    rq.Card16('length'),
    rq.Card16('sourceid'),
    rq.Card8('mode'),
    rq.Card8('num_touches'),
)

INFO_CLASSES = {
    KeyClass: KeyInfo,
    ButtonClass: ButtonInfo,
    ValuatorClass: ValuatorInfo,
    ScrollClass: ScrollInfo,
    TouchClass: TouchInfo,
}

class ClassInfoClass(object):

    structcode = None

    def parse_binary(self, data, display):
        class_type, length = struct.unpack('=HH', data[:4])
        class_struct = INFO_CLASSES.get(class_type, AnyInfo)
        class_data, _ = class_struct.parse_binary(data, display)
        data = data[length * 4:]
        return class_data, data

ClassInfo = ClassInfoClass()

DeviceInfo = rq.Struct(
    DEVICEID('deviceid'),
    rq.Card16('use'),
    rq.Card16('attachment'),
    rq.LengthOf('classes', 2),
    rq.LengthOf('name', 2),
    rq.Bool('enabled'),
    rq.Pad(1),
    rq.String8('name', 4),
    rq.List('classes', ClassInfo),
)

class XIQueryDevice(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(48),
        rq.RequestLength(),
        DEVICEID('deviceid'),
        rq.Pad(2),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('devices', 2),
        rq.Pad(22),
        rq.List('devices', DeviceInfo),
        )

def query_device(self, deviceid):
    return XIQueryDevice(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        deviceid=deviceid,
        )

class XIGrabDevice(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(51),
        rq.RequestLength(),
        rq.Window('grab_window'),
        rq.Card32('time'),
        rq.Cursor('cursor', (X.NONE, )),
        DEVICEID('deviceid'),
        rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)),
        rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)),
        rq.Bool('owner_events'),
        rq.Pad(1),
        rq.LengthOf('mask', 2),
        Mask('mask'),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.Card8('status'),
        rq.Pad(23),
        )

def grab_device(self, deviceid, time, grab_mode, paired_device_mode, owner_events, event_mask):
    return XIGrabDevice(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        deviceid=deviceid,
        grab_window=self,
        time=time,
        cursor=X.NONE,
        grab_mode=grab_mode,
        paired_device_mode=paired_device_mode,
        owner_events=owner_events,
        mask=event_mask,
        )

class XIUngrabDevice(rq.Request):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(52),
        rq.RequestLength(),
        rq.Card32('time'),
        DEVICEID('deviceid'),
        rq.Pad(2),
    )

def ungrab_device(self, deviceid, time):
    return XIUngrabDevice(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        time=time,
        deviceid=deviceid,
    )

class XIPassiveGrabDevice(rq.ReplyRequest):
    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(54),
        rq.RequestLength(),
        rq.Card32('time'),
        rq.Window('grab_window'),
        rq.Cursor('cursor', (X.NONE, )),
        rq.Card32('detail'),
        DEVICEID('deviceid'),
        rq.LengthOf('modifiers', 2),
        rq.LengthOf('mask', 2),
        rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter,
                                GrabtypeFocusIn, GrabtypeTouchBegin)),
        rq.Set('grab_mode', 1, (GrabModeSync, GrabModeAsync)),
        rq.Set('paired_device_mode', 1, (GrabModeSync, GrabModeAsync)),
        rq.Bool('owner_events'),
        rq.Pad(2),
        Mask('mask'),
        rq.List('modifiers', rq.Card32),
    )

    _reply = rq.Struct(
        rq.ReplyCode(),
        rq.Pad(1),
        rq.Card16('sequence_number'),
        rq.ReplyLength(),
        rq.LengthOf('modifiers', 2),
        rq.Pad(22),
        rq.List('modifiers', rq.Card32),
        )

def passive_grab_device(self, deviceid, time, detail,
                        grab_type, grab_mode, paired_device_mode,
                        owner_events, event_mask, modifiers):
    return XIPassiveGrabDevice(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        deviceid=deviceid,
        grab_window=self,
        time=time,
        cursor=X.NONE,
        detail=detail,
        grab_type=grab_type,
        grab_mode=grab_mode,
        paired_device_mode=paired_device_mode,
        owner_events=owner_events,
        mask=event_mask,
        modifiers=modifiers,
        )

def grab_keycode(self, deviceid, time, keycode,
                 grab_mode, paired_device_mode,
                 owner_events, event_mask, modifiers):
    return passive_grab_device(self, deviceid, time, keycode,
                               GrabtypeKeycode,
                               grab_mode, paired_device_mode,
                               owner_events, event_mask, modifiers)

class XIPassiveUngrabDevice(rq.Request):

    _request = rq.Struct(
        rq.Card8('opcode'),
        rq.Opcode(55),
        rq.RequestLength(),
        rq.Window('grab_window'),
        rq.Card32('detail'),
        DEVICEID('deviceid'),
        rq.LengthOf('modifiers', 2),
        rq.Set('grab_type', 1, (GrabtypeButton, GrabtypeKeycode,
                                GrabtypeEnter, GrabtypeFocusIn,
                                GrabtypeTouchBegin)),
        rq.Pad(3),
        rq.List('modifiers', rq.Card32),
    )

def passive_ungrab_device(self, deviceid, detail, grab_type, modifiers):
    return XIPassiveUngrabDevice(
        display=self.display,
        opcode=self.display.get_extension_major(extname),
        deviceid=deviceid,
        grab_window=self,
        detail=detail,
        grab_type=grab_type,
        modifiers=modifiers,
        )

def ungrab_keycode(self, deviceid, keycode, modifiers):
    return passive_ungrab_device(self, deviceid, keycode,
                                 GrabtypeKeycode, modifiers)

HierarchyInfo = rq.Struct(
    DEVICEID('deviceid'),
    DEVICEID('attachment'),
    DEVICEUSE('type'),
    rq.Bool('enabled'),
    rq.Pad(2),
    rq.Card32('flags'),
)


HierarchyEventData = rq.Struct(
    DEVICEID('deviceid'),
    rq.Card32('time'),
    rq.Card32('flags'),
    rq.LengthOf('info', 2),
    rq.Pad(10),
    rq.List('info', HierarchyInfo),
)

ModifierInfo = rq.Struct(
    rq.Card32('base_mods'),
    rq.Card32('latched_mods'),
    rq.Card32('locked_mods'),
    rq.Card32('effective_mods'),
)

GroupInfo = rq.Struct(
    rq.Card8('base_group'),
    rq.Card8('latched_group'),
    rq.Card8('locked_group'),
    rq.Card8('effective_group'),
)

DeviceEventData = rq.Struct(
    DEVICEID('deviceid'),
    rq.Card32('time'),
    rq.Card32('detail'),
    rq.Window('root'),
    rq.Window('event'),
    rq.Window('child'),
    FP1616('root_x'),
    FP1616('root_y'),
    FP1616('event_x'),
    FP1616('event_y'),
    rq.LengthOf('buttons', 2),
    rq.Card16('valulators_len'),
    DEVICEID('sourceid'),
    rq.Pad(2),
    rq.Card32('flags'),
    rq.Object('mods', ModifierInfo),
    rq.Object('groups', GroupInfo),
    ButtonState('buttons'),
)

DeviceChangedEventData = rq.Struct(
    DEVICEID('deviceid'),
    rq.Card32('time'),
    rq.LengthOf('classes', 2),
    DEVICEID('sourceid'),
    rq.Card8('reason'),
    rq.Pad(11),
    rq.List('classes', ClassInfo),
)

def init(disp, info):
    disp.extension_add_method('display', 'xinput_query_version', query_version)
    disp.extension_add_method('window', 'xinput_select_events', select_events)
    disp.extension_add_method('display', 'xinput_query_device', query_device)
    disp.extension_add_method('window', 'xinput_grab_device', grab_device)
    disp.extension_add_method('display', 'xinput_ungrab_device', ungrab_device)
    disp.extension_add_method('window', 'xinput_grab_keycode', grab_keycode)
    disp.extension_add_method('window', 'xinput_ungrab_keycode', ungrab_keycode)
    if hasattr(disp,"ge_add_event_data"):
        for device_event in (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion):
            disp.ge_add_event_data(info.major_opcode, device_event, DeviceEventData)
        disp.ge_add_event_data(info.major_opcode, DeviceChanged, DeviceEventData)
        disp.ge_add_event_data(info.major_opcode, HierarchyChanged, HierarchyEventData)

[((243, 4, 243, 26), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(243, 16, 243, 22): '"""mask"""', (243, 24, 243, 25): '2'}, {}), "('mask', 2)", False, 'from Xlib.protocol import rq\n'), ((276, 4, 276, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(276, 14, 276, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((277, 4, 277, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(277, 14, 277, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((278, 4, 278, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(278, 14, 278, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((279, 4, 279, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(279, 11, 279, 12): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((321, 4, 321, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(321, 14, 321, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((322, 4, 322, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(322, 14, 322, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((323, 4, 323, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(323, 14, 323, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((324, 4, 324, 39), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(324, 16, 324, 35): "('state', 'labels')", (324, 37, 324, 38): '2'}, {}), "(('state', 'labels'), 2)", False, 'from Xlib.protocol import rq\n'), ((326, 4, 326, 32), 'Xlib.protocol.rq.List', 'rq.List', ({(326, 12, 326, 20): '"""labels"""', (326, 22, 326, 31): 'rq.Card32'}, {}), "('labels', rq.Card32)", False, 'from Xlib.protocol import rq\n'), ((330, 4, 330, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(330, 14, 330, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((331, 4, 331, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(331, 14, 331, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((332, 4, 332, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(332, 14, 332, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((333, 4, 333, 30), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(333, 16, 333, 26): '"""keycodes"""', (333, 28, 333, 29): '2'}, {}), "('keycodes', 2)", False, 'from Xlib.protocol import rq\n'), ((334, 4, 334, 34), 'Xlib.protocol.rq.List', 'rq.List', ({(334, 12, 334, 22): '"""keycodes"""', (334, 24, 334, 33): 'rq.Card32'}, {}), "('keycodes', rq.Card32)", False, 'from Xlib.protocol import rq\n'), ((338, 4, 338, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(338, 14, 338, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((339, 4, 339, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(339, 14, 339, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((340, 4, 340, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(340, 14, 340, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((341, 4, 341, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(341, 14, 341, 22): '"""number"""'}, {}), "('number')", False, 'from Xlib.protocol import rq\n'), ((342, 4, 342, 22), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(342, 14, 342, 21): '"""label"""'}, {}), "('label')", False, 'from Xlib.protocol import rq\n'), ((346, 4, 346, 27), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(346, 14, 346, 26): '"""resolution"""'}, {}), "('resolution')", False, 'from Xlib.protocol import rq\n'), ((347, 4, 347, 20), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(347, 13, 347, 19): '"""mode"""'}, {}), "('mode')", False, 'from Xlib.protocol import rq\n'), ((348, 4, 348, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(348, 11, 348, 12): '3'}, {}), '(3)', False, 'from Xlib.protocol import rq\n'), ((352, 4, 352, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(352, 14, 352, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((353, 4, 353, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(353, 14, 353, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((354, 4, 354, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(354, 14, 354, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((355, 4, 355, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(355, 14, 355, 22): '"""number"""'}, {}), "('number')", False, 'from Xlib.protocol import rq\n'), ((356, 4, 356, 28), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(356, 14, 356, 27): '"""scroll_type"""'}, {}), "('scroll_type')", False, 'from Xlib.protocol import rq\n'), ((357, 4, 357, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(357, 11, 357, 12): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((358, 4, 358, 22), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(358, 14, 358, 21): '"""flags"""'}, {}), "('flags')", False, 'from Xlib.protocol import rq\n'), ((363, 4, 363, 21), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(363, 14, 363, 20): '"""type"""'}, {}), "('type')", False, 'from Xlib.protocol import rq\n'), ((364, 4, 364, 23), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(364, 14, 364, 22): '"""length"""'}, {}), "('length')", False, 'from Xlib.protocol import rq\n'), ((365, 4, 365, 25), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(365, 14, 365, 24): '"""sourceid"""'}, {}), "('sourceid')", False, 'from Xlib.protocol import rq\n'), ((366, 4, 366, 20), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(366, 13, 366, 19): '"""mode"""'}, {}), "('mode')", False, 'from Xlib.protocol import rq\n'), ((367, 4, 367, 27), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(367, 13, 367, 26): '"""num_touches"""'}, {}), "('num_touches')", False, 'from Xlib.protocol import rq\n'), ((393, 4, 393, 20), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(393, 14, 393, 19): '"""use"""'}, {}), "('use')", False, 'from Xlib.protocol import rq\n'), ((394, 4, 394, 27), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(394, 14, 394, 26): '"""attachment"""'}, {}), "('attachment')", False, 'from Xlib.protocol import rq\n'), ((395, 4, 395, 29), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(395, 16, 395, 25): '"""classes"""', (395, 27, 395, 28): '2'}, {}), "('classes', 2)", False, 'from Xlib.protocol import rq\n'), ((396, 4, 396, 26), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(396, 16, 396, 22): '"""name"""', (396, 24, 396, 25): '2'}, {}), "('name', 2)", False, 'from Xlib.protocol import rq\n'), ((397, 4, 397, 22), 'Xlib.protocol.rq.Bool', 'rq.Bool', ({(397, 12, 397, 21): '"""enabled"""'}, {}), "('enabled')", False, 'from Xlib.protocol import rq\n'), ((398, 4, 398, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(398, 11, 398, 12): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((399, 4, 399, 25), 'Xlib.protocol.rq.String8', 'rq.String8', ({(399, 15, 399, 21): '"""name"""', (399, 23, 399, 24): '4'}, {}), "('name', 4)", False, 'from Xlib.protocol import rq\n'), ((400, 4, 400, 33), 'Xlib.protocol.rq.List', 'rq.List', ({(400, 12, 400, 21): '"""classes"""', (400, 23, 400, 32): 'ClassInfo'}, {}), "('classes', ClassInfo)", False, 'from Xlib.protocol import rq\n'), ((582, 4, 582, 22), 'Xlib.protocol.rq.Bool', 'rq.Bool', ({(582, 12, 582, 21): '"""enabled"""'}, {}), "('enabled')", False, 'from Xlib.protocol import rq\n'), ((583, 4, 583, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(583, 11, 583, 12): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((584, 4, 584, 22), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(584, 14, 584, 21): '"""flags"""'}, {}), "('flags')", False, 'from Xlib.protocol import rq\n'), ((590, 4, 590, 21), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(590, 14, 590, 20): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((591, 4, 591, 22), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(591, 14, 591, 21): '"""flags"""'}, {}), "('flags')", False, 'from Xlib.protocol import rq\n'), ((592, 4, 592, 26), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(592, 16, 592, 22): '"""info"""', (592, 24, 592, 25): '2'}, {}), "('info', 2)", False, 'from Xlib.protocol import rq\n'), ((593, 4, 593, 14), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(593, 11, 593, 13): '10'}, {}), '(10)', False, 'from Xlib.protocol import rq\n'), ((594, 4, 594, 34), 'Xlib.protocol.rq.List', 'rq.List', ({(594, 12, 594, 18): '"""info"""', (594, 20, 594, 33): 'HierarchyInfo'}, {}), "('info', HierarchyInfo)", False, 'from Xlib.protocol import rq\n'), ((598, 4, 598, 26), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(598, 14, 598, 25): '"""base_mods"""'}, {}), "('base_mods')", False, 'from Xlib.protocol import rq\n'), ((599, 4, 599, 29), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(599, 14, 599, 28): '"""latched_mods"""'}, {}), "('latched_mods')", False, 'from Xlib.protocol import rq\n'), ((600, 4, 600, 28), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(600, 14, 600, 27): '"""locked_mods"""'}, {}), "('locked_mods')", False, 'from Xlib.protocol import rq\n'), ((601, 4, 601, 31), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(601, 14, 601, 30): '"""effective_mods"""'}, {}), "('effective_mods')", False, 'from Xlib.protocol import rq\n'), ((605, 4, 605, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(605, 13, 605, 25): '"""base_group"""'}, {}), "('base_group')", False, 'from Xlib.protocol import rq\n'), ((606, 4, 606, 29), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(606, 13, 606, 28): '"""latched_group"""'}, {}), "('latched_group')", False, 'from Xlib.protocol import rq\n'), ((607, 4, 607, 28), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(607, 13, 607, 27): '"""locked_group"""'}, {}), "('locked_group')", False, 'from Xlib.protocol import rq\n'), ((608, 4, 608, 31), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(608, 13, 608, 30): '"""effective_group"""'}, {}), "('effective_group')", False, 'from Xlib.protocol import rq\n'), ((613, 4, 613, 21), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(613, 14, 613, 20): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((614, 4, 614, 23), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(614, 14, 614, 22): '"""detail"""'}, {}), "('detail')", False, 'from Xlib.protocol import rq\n'), ((615, 4, 615, 21), 'Xlib.protocol.rq.Window', 'rq.Window', ({(615, 14, 615, 20): '"""root"""'}, {}), "('root')", False, 'from Xlib.protocol import rq\n'), ((616, 4, 616, 22), 'Xlib.protocol.rq.Window', 'rq.Window', ({(616, 14, 616, 21): '"""event"""'}, {}), "('event')", False, 'from Xlib.protocol import rq\n'), ((617, 4, 617, 22), 'Xlib.protocol.rq.Window', 'rq.Window', ({(617, 14, 617, 21): '"""child"""'}, {}), "('child')", False, 'from Xlib.protocol import rq\n'), ((622, 4, 622, 29), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(622, 16, 622, 25): '"""buttons"""', (622, 27, 622, 28): '2'}, {}), "('buttons', 2)", False, 'from Xlib.protocol import rq\n'), ((623, 4, 623, 31), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(623, 14, 623, 30): '"""valulators_len"""'}, {}), "('valulators_len')", False, 'from Xlib.protocol import rq\n'), ((625, 4, 625, 13), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(625, 11, 625, 12): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((626, 4, 626, 22), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(626, 14, 626, 21): '"""flags"""'}, {}), "('flags')", False, 'from Xlib.protocol import rq\n'), ((627, 4, 627, 35), 'Xlib.protocol.rq.Object', 'rq.Object', ({(627, 14, 627, 20): '"""mods"""', (627, 22, 627, 34): 'ModifierInfo'}, {}), "('mods', ModifierInfo)", False, 'from Xlib.protocol import rq\n'), ((628, 4, 628, 34), 'Xlib.protocol.rq.Object', 'rq.Object', ({(628, 14, 628, 22): '"""groups"""', (628, 24, 628, 33): 'GroupInfo'}, {}), "('groups', GroupInfo)", False, 'from Xlib.protocol import rq\n'), ((634, 4, 634, 21), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(634, 14, 634, 20): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((635, 4, 635, 29), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(635, 16, 635, 25): '"""classes"""', (635, 27, 635, 28): '2'}, {}), "('classes', 2)", False, 'from Xlib.protocol import rq\n'), ((637, 4, 637, 22), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(637, 13, 637, 21): '"""reason"""'}, {}), "('reason')", False, 'from Xlib.protocol import rq\n'), ((638, 4, 638, 14), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(638, 11, 638, 13): '11'}, {}), '(11)', False, 'from Xlib.protocol import rq\n'), ((639, 4, 639, 33), 'Xlib.protocol.rq.List', 'rq.List', ({(639, 12, 639, 21): '"""classes"""', (639, 23, 639, 32): 'ClassInfo'}, {}), "('classes', ClassInfo)", False, 'from Xlib.protocol import rq\n'), ((185, 8, 185, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(185, 17, 185, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((186, 8, 186, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(186, 18, 186, 20): '47'}, {}), '(47)', False, 'from Xlib.protocol import rq\n'), ((187, 8, 187, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((188, 8, 188, 34), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(188, 18, 188, 33): '"""major_version"""'}, {}), "('major_version')", False, 'from Xlib.protocol import rq\n'), ((189, 8, 189, 34), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(189, 18, 189, 33): '"""minor_version"""'}, {}), "('minor_version')", False, 'from Xlib.protocol import rq\n'), ((192, 8, 192, 22), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((193, 8, 193, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(193, 15, 193, 16): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((194, 8, 194, 36), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(194, 18, 194, 35): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((195, 8, 195, 24), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((196, 8, 196, 34), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(196, 18, 196, 33): '"""major_version"""'}, {}), "('major_version')", False, 'from Xlib.protocol import rq\n'), ((197, 8, 197, 34), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(197, 18, 197, 33): '"""minor_version"""'}, {}), "('minor_version')", False, 'from Xlib.protocol import rq\n'), ((198, 8, 198, 18), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(198, 15, 198, 17): '20'}, {}), '(20)', False, 'from Xlib.protocol import rq\n'), ((213, 8, 213, 54), 'Xlib.protocol.rq.List.__init__', 'rq.List.__init__', (), '', False, 'from Xlib.protocol import rq\n'), ((217, 19, 217, 61), 'array.array', 'array.array', ({(217, 31, 217, 60): "rq.struct_to_array_codes['L']"}, {}), "(rq.struct_to_array_codes['L'])", False, 'import array\n'), ((250, 8, 250, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(250, 17, 250, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((251, 8, 251, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(251, 18, 251, 20): '46'}, {}), '(46)', False, 'from Xlib.protocol import rq\n'), ((252, 8, 252, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((253, 8, 253, 27), 'Xlib.protocol.rq.Window', 'rq.Window', ({(253, 18, 253, 26): '"""window"""'}, {}), "('window')", False, 'from Xlib.protocol import rq\n'), ((254, 8, 254, 31), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(254, 20, 254, 27): '"""masks"""', (254, 29, 254, 30): '2'}, {}), "('masks', 2)", False, 'from Xlib.protocol import rq\n'), ((255, 8, 255, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(255, 15, 255, 16): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((256, 8, 256, 35), 'Xlib.protocol.rq.List', 'rq.List', ({(256, 16, 256, 23): '"""masks"""', (256, 25, 256, 34): 'EventMask'}, {}), "('masks', EventMask)", False, 'from Xlib.protocol import rq\n'), ((306, 8, 306, 42), 'Xlib.protocol.rq.ValueField.__init__', 'rq.ValueField.__init__', ({(306, 31, 306, 35): 'self', (306, 37, 306, 41): 'name'}, {}), '(self, name)', False, 'from Xlib.protocol import rq\n'), ((383, 29, 383, 59), 'struct.unpack', 'struct.unpack', ({(383, 43, 383, 48): '"""=HH"""', (383, 50, 383, 58): 'data[:4]'}, {}), "('=HH', data[:4])", False, 'import struct\n'), ((405, 8, 405, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(405, 17, 405, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((406, 8, 406, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(406, 18, 406, 20): '48'}, {}), '(48)', False, 'from Xlib.protocol import rq\n'), ((407, 8, 407, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((409, 8, 409, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(409, 15, 409, 16): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((413, 8, 413, 22), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((414, 8, 414, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(414, 15, 414, 16): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((415, 8, 415, 36), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(415, 18, 415, 35): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((416, 8, 416, 24), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((417, 8, 417, 33), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(417, 20, 417, 29): '"""devices"""', (417, 31, 417, 32): '2'}, {}), "('devices', 2)", False, 'from Xlib.protocol import rq\n'), ((418, 8, 418, 18), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(418, 15, 418, 17): '22'}, {}), '(22)', False, 'from Xlib.protocol import rq\n'), ((419, 8, 419, 38), 'Xlib.protocol.rq.List', 'rq.List', ({(419, 16, 419, 25): '"""devices"""', (419, 27, 419, 37): 'DeviceInfo'}, {}), "('devices', DeviceInfo)", False, 'from Xlib.protocol import rq\n'), ((431, 8, 431, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(431, 17, 431, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((432, 8, 432, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(432, 18, 432, 20): '51'}, {}), '(51)', False, 'from Xlib.protocol import rq\n'), ((433, 8, 433, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((434, 8, 434, 32), 'Xlib.protocol.rq.Window', 'rq.Window', ({(434, 18, 434, 31): '"""grab_window"""'}, {}), "('grab_window')", False, 'from Xlib.protocol import rq\n'), ((435, 8, 435, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(435, 18, 435, 24): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((436, 8, 436, 39), 'Xlib.protocol.rq.Cursor', 'rq.Cursor', ({(436, 18, 436, 26): '"""cursor"""', (436, 28, 436, 38): '(X.NONE,)'}, {}), "('cursor', (X.NONE,))", False, 'from Xlib.protocol import rq\n'), ((438, 8, 438, 61), 'Xlib.protocol.rq.Set', 'rq.Set', ({(438, 15, 438, 26): '"""grab_mode"""', (438, 28, 438, 29): '1', (438, 31, 438, 60): '(GrabModeSync, GrabModeAsync)'}, {}), "('grab_mode', 1, (GrabModeSync, GrabModeAsync))", False, 'from Xlib.protocol import rq\n'), ((439, 8, 439, 70), 'Xlib.protocol.rq.Set', 'rq.Set', ({(439, 15, 439, 35): '"""paired_device_mode"""', (439, 37, 439, 38): '1', (439, 40, 439, 69): '(GrabModeSync, GrabModeAsync)'}, {}), "('paired_device_mode', 1, (GrabModeSync, GrabModeAsync))", False, 'from Xlib.protocol import rq\n'), ((440, 8, 440, 31), 'Xlib.protocol.rq.Bool', 'rq.Bool', ({(440, 16, 440, 30): '"""owner_events"""'}, {}), "('owner_events')", False, 'from Xlib.protocol import rq\n'), ((441, 8, 441, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(441, 15, 441, 16): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((442, 8, 442, 30), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(442, 20, 442, 26): '"""mask"""', (442, 28, 442, 29): '2'}, {}), "('mask', 2)", False, 'from Xlib.protocol import rq\n'), ((447, 8, 447, 22), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((448, 8, 448, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(448, 15, 448, 16): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((449, 8, 449, 36), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(449, 18, 449, 35): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((450, 8, 450, 24), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((451, 8, 451, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(451, 17, 451, 25): '"""status"""'}, {}), "('status')", False, 'from Xlib.protocol import rq\n'), ((452, 8, 452, 18), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(452, 15, 452, 17): '23'}, {}), '(23)', False, 'from Xlib.protocol import rq\n'), ((471, 8, 471, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(471, 17, 471, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((472, 8, 472, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(472, 18, 472, 20): '52'}, {}), '(52)', False, 'from Xlib.protocol import rq\n'), ((473, 8, 473, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((474, 8, 474, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(474, 18, 474, 24): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((476, 8, 476, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(476, 15, 476, 16): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((489, 8, 489, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(489, 17, 489, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((490, 8, 490, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(490, 18, 490, 20): '54'}, {}), '(54)', False, 'from Xlib.protocol import rq\n'), ((491, 8, 491, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((492, 8, 492, 25), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(492, 18, 492, 24): '"""time"""'}, {}), "('time')", False, 'from Xlib.protocol import rq\n'), ((493, 8, 493, 32), 'Xlib.protocol.rq.Window', 'rq.Window', ({(493, 18, 493, 31): '"""grab_window"""'}, {}), "('grab_window')", False, 'from Xlib.protocol import rq\n'), ((494, 8, 494, 39), 'Xlib.protocol.rq.Cursor', 'rq.Cursor', ({(494, 18, 494, 26): '"""cursor"""', (494, 28, 494, 38): '(X.NONE,)'}, {}), "('cursor', (X.NONE,))", False, 'from Xlib.protocol import rq\n'), ((495, 8, 495, 27), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(495, 18, 495, 26): '"""detail"""'}, {}), "('detail')", False, 'from Xlib.protocol import rq\n'), ((497, 8, 497, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(497, 20, 497, 31): '"""modifiers"""', (497, 33, 497, 34): '2'}, {}), "('modifiers', 2)", False, 'from Xlib.protocol import rq\n'), ((498, 8, 498, 30), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(498, 20, 498, 26): '"""mask"""', (498, 28, 498, 29): '2'}, {}), "('mask', 2)", False, 'from Xlib.protocol import rq\n'), ((499, 8, 500, 69), 'Xlib.protocol.rq.Set', 'rq.Set', ({(499, 15, 499, 26): '"""grab_type"""', (499, 28, 499, 29): '1', (499, 31, 500, 68): '(GrabtypeButton, GrabtypeKeycode, GrabtypeEnter, GrabtypeFocusIn,\n    GrabtypeTouchBegin)'}, {}), "('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter,\n    GrabtypeFocusIn, GrabtypeTouchBegin))", False, 'from Xlib.protocol import rq\n'), ((501, 8, 501, 61), 'Xlib.protocol.rq.Set', 'rq.Set', ({(501, 15, 501, 26): '"""grab_mode"""', (501, 28, 501, 29): '1', (501, 31, 501, 60): '(GrabModeSync, GrabModeAsync)'}, {}), "('grab_mode', 1, (GrabModeSync, GrabModeAsync))", False, 'from Xlib.protocol import rq\n'), ((502, 8, 502, 70), 'Xlib.protocol.rq.Set', 'rq.Set', ({(502, 15, 502, 35): '"""paired_device_mode"""', (502, 37, 502, 38): '1', (502, 40, 502, 69): '(GrabModeSync, GrabModeAsync)'}, {}), "('paired_device_mode', 1, (GrabModeSync, GrabModeAsync))", False, 'from Xlib.protocol import rq\n'), ((503, 8, 503, 31), 'Xlib.protocol.rq.Bool', 'rq.Bool', ({(503, 16, 503, 30): '"""owner_events"""'}, {}), "('owner_events')", False, 'from Xlib.protocol import rq\n'), ((504, 8, 504, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(504, 15, 504, 16): '2'}, {}), '(2)', False, 'from Xlib.protocol import rq\n'), ((506, 8, 506, 39), 'Xlib.protocol.rq.List', 'rq.List', ({(506, 16, 506, 27): '"""modifiers"""', (506, 29, 506, 38): 'rq.Card32'}, {}), "('modifiers', rq.Card32)", False, 'from Xlib.protocol import rq\n'), ((510, 8, 510, 22), 'Xlib.protocol.rq.ReplyCode', 'rq.ReplyCode', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((511, 8, 511, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(511, 15, 511, 16): '1'}, {}), '(1)', False, 'from Xlib.protocol import rq\n'), ((512, 8, 512, 36), 'Xlib.protocol.rq.Card16', 'rq.Card16', ({(512, 18, 512, 35): '"""sequence_number"""'}, {}), "('sequence_number')", False, 'from Xlib.protocol import rq\n'), ((513, 8, 513, 24), 'Xlib.protocol.rq.ReplyLength', 'rq.ReplyLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((514, 8, 514, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(514, 20, 514, 31): '"""modifiers"""', (514, 33, 514, 34): '2'}, {}), "('modifiers', 2)", False, 'from Xlib.protocol import rq\n'), ((515, 8, 515, 18), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(515, 15, 515, 17): '22'}, {}), '(22)', False, 'from Xlib.protocol import rq\n'), ((516, 8, 516, 39), 'Xlib.protocol.rq.List', 'rq.List', ({(516, 16, 516, 27): '"""modifiers"""', (516, 29, 516, 38): 'rq.Card32'}, {}), "('modifiers', rq.Card32)", False, 'from Xlib.protocol import rq\n'), ((549, 8, 549, 26), 'Xlib.protocol.rq.Card8', 'rq.Card8', ({(549, 17, 549, 25): '"""opcode"""'}, {}), "('opcode')", False, 'from Xlib.protocol import rq\n'), ((550, 8, 550, 21), 'Xlib.protocol.rq.Opcode', 'rq.Opcode', ({(550, 18, 550, 20): '55'}, {}), '(55)', False, 'from Xlib.protocol import rq\n'), ((551, 8, 551, 26), 'Xlib.protocol.rq.RequestLength', 'rq.RequestLength', ({}, {}), '()', False, 'from Xlib.protocol import rq\n'), ((552, 8, 552, 32), 'Xlib.protocol.rq.Window', 'rq.Window', ({(552, 18, 552, 31): '"""grab_window"""'}, {}), "('grab_window')", False, 'from Xlib.protocol import rq\n'), ((553, 8, 553, 27), 'Xlib.protocol.rq.Card32', 'rq.Card32', ({(553, 18, 553, 26): '"""detail"""'}, {}), "('detail')", False, 'from Xlib.protocol import rq\n'), ((555, 8, 555, 35), 'Xlib.protocol.rq.LengthOf', 'rq.LengthOf', ({(555, 20, 555, 31): '"""modifiers"""', (555, 33, 555, 34): '2'}, {}), "('modifiers', 2)", False, 'from Xlib.protocol import rq\n'), ((556, 8, 558, 52), 'Xlib.protocol.rq.Set', 'rq.Set', ({(556, 15, 556, 26): '"""grab_type"""', (556, 28, 556, 29): '1', (556, 31, 558, 51): '(GrabtypeButton, GrabtypeKeycode, GrabtypeEnter, GrabtypeFocusIn,\n    GrabtypeTouchBegin)'}, {}), "('grab_type', 1, (GrabtypeButton, GrabtypeKeycode, GrabtypeEnter,\n    GrabtypeFocusIn, GrabtypeTouchBegin))", False, 'from Xlib.protocol import rq\n'), ((559, 8, 559, 17), 'Xlib.protocol.rq.Pad', 'rq.Pad', ({(559, 15, 559, 16): '3'}, {}), '(3)', False, 'from Xlib.protocol import rq\n'), ((560, 8, 560, 39), 'Xlib.protocol.rq.List', 'rq.List', ({(560, 16, 560, 27): '"""modifiers"""', (560, 29, 560, 38): 'rq.Card32'}, {}), "('modifiers', rq.Card32)", False, 'from Xlib.protocol import rq\n')]