|
25 | 25 | ShowCursor requests and SelectionNotify events are provided. |
26 | 26 | ''' |
27 | 27 |
|
28 | | -from Xlib.protocol import rq |
| 28 | +from Xlib import X |
| 29 | +from Xlib.protocol import rq, structs |
29 | 30 |
|
30 | 31 | extname = 'XFIXES' |
31 | 32 |
|
32 | 33 | XFixesSelectionNotify = 0 |
| 34 | +XFixesCursorNotify = 1 |
33 | 35 |
|
34 | 36 | XFixesSetSelectionOwnerNotifyMask = (1 << 0) |
35 | 37 | XFixesSelectionWindowDestroyNotifyMask = (1 << 1) |
36 | 38 | XFixesSelectionClientCloseNotifyMask = (1 << 2) |
| 39 | +XFixesDisplayCursorNotifyMask = (1 << 0) |
37 | 40 |
|
38 | 41 | XFixesSetSelectionOwnerNotify = 0 |
39 | 42 | XFixesSelectionWindowDestroyNotify = 1 |
40 | 43 | XFixesSelectionClientCloseNotify = 2 |
| 44 | +XFixesDisplayCursorNotify = 0 |
41 | 45 |
|
42 | 46 | class QueryVersion(rq.ReplyRequest): |
43 | 47 | _request = rq.Struct(rq.Card8('opcode'), |
@@ -131,12 +135,67 @@ class SelectionClientCloseNotify(SelectionNotify): |
131 | 135 | pass |
132 | 136 |
|
133 | 137 |
|
| 138 | +class SelectCursorInput(rq.Request): |
| 139 | + _request = rq.Struct(rq.Card8('opcode'), |
| 140 | + rq.Opcode(3), |
| 141 | + rq.RequestLength(), |
| 142 | + rq.Window('window'), |
| 143 | + rq.Card32('mask') |
| 144 | + ) |
| 145 | + |
| 146 | +def select_cursor_input(self, window, mask): |
| 147 | + return SelectCursorInput(opcode=self.display.get_extension_major(extname), |
| 148 | + display=self.display, |
| 149 | + window=window, |
| 150 | + cursor_serial=0, |
| 151 | + mask=mask) |
| 152 | + |
| 153 | + |
| 154 | +class GetCursorImage(rq.ReplyRequest): |
| 155 | + _request = rq.Struct(rq.Card8('opcode'), |
| 156 | + rq.Opcode(4), |
| 157 | + rq.RequestLength() |
| 158 | + ) |
| 159 | + _reply = rq.Struct(rq.ReplyCode(), |
| 160 | + rq.Pad(1), |
| 161 | + rq.Card16('sequence_number'), |
| 162 | + rq.ReplyLength(), |
| 163 | + rq.Int16('x'), |
| 164 | + rq.Int16('y'), |
| 165 | + rq.Card16('width'), |
| 166 | + rq.Card16('height'), |
| 167 | + rq.Card16('xhot'), |
| 168 | + rq.Card16('yhot'), |
| 169 | + rq.Card32('cursor_serial'), |
| 170 | + rq.Pad(8), |
| 171 | + rq.List('cursor_image', rq.Card32) |
| 172 | + ) |
| 173 | + |
| 174 | +def get_cursor_image(self, window): |
| 175 | + return GetCursorImage(opcode=self.display.get_extension_major(extname), |
| 176 | + display=self.display, |
| 177 | + ) |
| 178 | + |
| 179 | + |
| 180 | +class DisplayCursorNotify(rq.Event): |
| 181 | + _code = None |
| 182 | + _fields = rq.Struct(rq.Card8('type'), |
| 183 | + rq.Card8('sub_code'), |
| 184 | + rq.Card16('sequence_number'), |
| 185 | + rq.Window('window'), |
| 186 | + rq.Card32('cursor_serial'), |
| 187 | + rq.Card32('timestamp')) |
| 188 | + |
| 189 | + |
134 | 190 | def init(disp, info): |
135 | 191 | disp.extension_add_method('display', 'xfixes_select_selection_input', select_selection_input) |
136 | 192 | disp.extension_add_method('display', 'xfixes_query_version', query_version) |
137 | 193 | disp.extension_add_method('window', 'xfixes_hide_cursor', hide_cursor) |
138 | 194 | disp.extension_add_method('window', 'xfixes_show_cursor', show_cursor) |
| 195 | + disp.extension_add_method('display', 'xfixes_select_cursor_input', select_cursor_input) |
| 196 | + disp.extension_add_method('display', 'xfixes_get_cursor_image', get_cursor_image) |
139 | 197 |
|
140 | 198 | disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSetSelectionOwnerNotify, SetSelectionOwnerNotify) |
141 | 199 | disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionWindowDestroyNotify, SelectionWindowDestroyNotify) |
142 | 200 | disp.extension_add_subevent(info.first_event + XFixesSelectionNotify, XFixesSelectionClientCloseNotify, SelectionClientCloseNotify) |
| 201 | + disp.extension_add_subevent(info.first_event + XFixesCursorNotify, XFixesDisplayCursorNotify, DisplayCursorNotify) |
0 commit comments