|
| 1 | +# Xlib.ext.xfixes -- XFIXES extension module |
| 2 | +# |
| 3 | +# Copyright (C) 2010-2011 Outpost Embedded, LLC |
| 4 | +# Forest Bond <forest.bond@rapidrollout.com> |
| 5 | +# |
| 6 | +# This program is free software; you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation; either version 2 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 16 | +# You should have received a copy of the GNU General Public License |
| 17 | +# along with this program; if not, write to the Free Software |
| 18 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | + |
| 20 | +''' |
| 21 | +A partial implementation of the XFIXES extension. Only the HideCursor and |
| 22 | +ShowCursor requests are provided. |
| 23 | +''' |
| 24 | + |
| 25 | +from Xlib.protocol import rq |
| 26 | + |
| 27 | +extname = 'XFIXES' |
| 28 | + |
| 29 | + |
| 30 | +class QueryVersion(rq.ReplyRequest): |
| 31 | + _request = rq.Struct(rq.Card8('opcode'), |
| 32 | + rq.Opcode(0), |
| 33 | + rq.RequestLength(), |
| 34 | + rq.Card32('major_version'), |
| 35 | + rq.Card32('minor_version') |
| 36 | + ) |
| 37 | + _reply = rq.Struct(rq.ReplyCode(), |
| 38 | + rq.Pad(1), |
| 39 | + rq.Card16('sequence_number'), |
| 40 | + rq.ReplyLength(), |
| 41 | + rq.Card32('major_version'), |
| 42 | + rq.Card32('minor_version'), |
| 43 | + rq.Pad(16) |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | +def query_version(self): |
| 48 | + return QueryVersion(display=self.display, |
| 49 | + opcode=self.display.get_extension_major(extname), |
| 50 | + major_version=4, |
| 51 | + minor_version=0) |
| 52 | + |
| 53 | + |
| 54 | +class HideCursor(rq.Request): |
| 55 | + _request = rq.Struct(rq.Card8('opcode'), |
| 56 | + rq.Opcode(29), |
| 57 | + rq.RequestLength(), |
| 58 | + rq.Window('window') |
| 59 | + ) |
| 60 | + |
| 61 | +def hide_cursor(self): |
| 62 | + HideCursor(display=self.display, |
| 63 | + opcode=self.display.get_extension_major(extname), |
| 64 | + window=self) |
| 65 | + |
| 66 | + |
| 67 | +class ShowCursor(rq.Request): |
| 68 | + _request = rq.Struct(rq.Card8('opcode'), |
| 69 | + rq.Opcode(30), |
| 70 | + rq.RequestLength(), |
| 71 | + rq.Window('window') |
| 72 | + ) |
| 73 | + |
| 74 | + |
| 75 | +def show_cursor(self): |
| 76 | + ShowCursor(display=self.display, |
| 77 | + opcode=self.display.get_extension_major(extname), |
| 78 | + window=self) |
| 79 | + |
| 80 | + |
| 81 | +def init(disp, info): |
| 82 | + disp.extension_add_method('display', 'xfixes_query_version', query_version) |
| 83 | + disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) |
| 84 | + disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) |
0 commit comments