1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
|
# Xlib.ext.xfixes -- XFIXES extension module
#
# Copyright (C) 2010-2011 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 partial implementation of the XFIXES extension. Only the HideCursor and
ShowCursor requests and SelectionNotify events are provided.
'''
from Xlib.protocol import rq
extname = 'XFIXES'
XFixesSelectionNotify = 0
XFixesSetSelectionOwnerNotifyMask = (1 << 0)
XFixesSelectionWindowDestroyNotifyMask = (1 << 1)
XFixesSelectionClientCloseNotifyMask = (1 << 2)
XFixesSetSelectionOwnerNotify = 0
XFixesSelectionWindowDestroyNotify = 1
XFixesSelectionClientCloseNotify = 2
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),
major_version=4,
minor_version=0)
class HideCursor(rq.Request):
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(29),
rq.RequestLength(),
rq.Window('window')
)
def hide_cursor(self):
HideCursor(display=self.display,
opcode=self.display.get_extension_major(extname),
window=self)
class ShowCursor(rq.Request):
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(30),
rq.RequestLength(),
rq.Window('window')
)
def show_cursor(self):
ShowCursor(display=self.display,
opcode=self.display.get_extension_major(extname),
window=self)
class SelectSelectionInput(rq.Request):
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(2),
rq.RequestLength(),
rq.Window('window'),
rq.Card32('selection'),
rq.Card32('mask')
)
def select_selection_input(self, window, selection, mask):
return SelectSelectionInput(opcode=self.display.get_extension_major(extname),
display=self.display,
window=window,
selection=selection,
mask=mask)
class SelectionNotify(rq.Event):
_code = None
_fields = rq.Struct(rq.Card8('type'),
rq.Card8('sub_code'),
rq.Card16('sequence_number'),
rq.Window('window'),
rq.Window('owner'),
rq.Card32('selection'),
rq.Card32('timestamp'),
rq.Card32('selection_timestamp'),
rq.Pad(8))
class SetSelectionOwnerNotify(SelectionNotify):
pass
class SelectionWindowDestroyNotify(SelectionNotify):
pass
class SelectionClientCloseNotify(SelectionNotify):
pass
def init(disp, info):
disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input)
disp.extension_add_method('display', 'xfixes_query_version', query_version)
disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor)
disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor)
disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify)
disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify)
disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify)
|