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), )
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)))
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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)
'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'), )