1# Xlib.protocol.event -- definitions of core events 2# 3# Copyright (C) 2000-2002 Peter Liljenberg <petli@ctrl-c.liu.se> 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 19 20# Xlib modules 21from Xlib import X 22 23# Xlib.protocol modules 24from Xlib.protocol import rq 25 26 27class AnyEvent(rq.Event): 28 _code = None 29 _fields = rq.Struct( rq.Card8('type'), 30 rq.Card8('detail'), 31 rq.Card16('sequence_number'), 32 rq.FixedString('data', 28), 33 ) 34 35class KeyButtonPointer(rq.Event): 36 _code = None 37 _fields = rq.Struct( rq.Card8('type'), 38 rq.Card8('detail'), 39 rq.Card16('sequence_number'), 40 rq.Card32('time'), 41 rq.Window('root'), 42 rq.Window('window'), 43 rq.Window('child', (X.NONE, )), 44 rq.Int16('root_x'), 45 rq.Int16('root_y'), 46 rq.Int16('event_x'), 47 rq.Int16('event_y'), 48 rq.Card16('state'), 49 rq.Card8('same_screen'), 50 rq.Pad(1), 51 ) 52 53class KeyPress(KeyButtonPointer): 54 _code = X.KeyPress 55 56class KeyRelease(KeyButtonPointer): 57 _code = X.KeyRelease 58 59class ButtonPress(KeyButtonPointer): 60 _code = X.ButtonPress 61 62class ButtonRelease(KeyButtonPointer): 63 _code = X.ButtonRelease 64 65class MotionNotify(KeyButtonPointer): 66 _code = X.MotionNotify 67 68class EnterLeave(rq.Event): 69 _code = None 70 _fields = rq.Struct( rq.Card8('type'), 71 rq.Card8('detail'), 72 rq.Card16('sequence_number'), 73 rq.Card32('time'), 74 rq.Window('root'), 75 rq.Window('window'), 76 rq.Window('child', (X.NONE, )), 77 rq.Int16('root_x'), 78 rq.Int16('root_y'), 79 rq.Int16('event_x'), 80 rq.Int16('event_y'), 81 rq.Card16('state'), 82 rq.Card8('mode'), 83 rq.Card8('flags'), 84 ) 85 86class EnterNotify(EnterLeave): 87 _code = X.EnterNotify 88 89class LeaveNotify(EnterLeave): 90 _code = X.LeaveNotify 91 92 93class Focus(rq.Event): 94 _code = None 95 _fields = rq.Struct( rq.Card8('type'), 96 rq.Card8('detail'), 97 rq.Card16('sequence_number'), 98 rq.Window('window'), 99 rq.Card8('mode'), 100 rq.Pad(23), 101 ) 102 103class FocusIn(Focus): 104 _code = X.FocusIn 105 106class FocusOut(Focus): 107 _code = X.FocusOut 108 109class Expose(rq.Event): 110 _code = X.Expose 111 _fields = rq.Struct( rq.Card8('type'), 112 rq.Pad(1), 113 rq.Card16('sequence_number'), 114 rq.Window('window'), 115 rq.Card16('x'), 116 rq.Card16('y'), 117 rq.Card16('width'), 118 rq.Card16('height'), 119 rq.Card16('count'), 120 rq.Pad(14), 121 ) 122 123class GraphicsExpose(rq.Event): 124 _code = X.GraphicsExpose 125 _fields = rq.Struct( rq.Card8('type'), 126 rq.Pad(1), 127 rq.Card16('sequence_number'), 128 rq.Drawable('drawable'), 129 rq.Card16('x'), 130 rq.Card16('y'), 131 rq.Card16('width'), 132 rq.Card16('height'), 133 rq.Card16('minor_event'), 134 rq.Card16('count'), 135 rq.Card8('major_event'), 136 rq.Pad(11), 137 ) 138 139class NoExpose(rq.Event): 140 _code = X.NoExpose 141 _fields = rq.Struct( rq.Card8('type'), 142 rq.Pad(1), 143 rq.Card16('sequence_number'), 144 rq.Drawable('window'), 145 rq.Card16('minor_event'), 146 rq.Card8('major_event'), 147 rq.Pad(21), 148 ) 149 150class VisibilityNotify(rq.Event): 151 _code = X.VisibilityNotify 152 _fields = rq.Struct( rq.Card8('type'), 153 rq.Pad(1), 154 rq.Card16('sequence_number'), 155 rq.Window('window'), 156 rq.Card8('state'), 157 rq.Pad(23), 158 ) 159 160class CreateNotify(rq.Event): 161 _code = X.CreateNotify 162 _fields = rq.Struct( rq.Card8('type'), 163 rq.Pad(1), 164 rq.Card16('sequence_number'), 165 rq.Window('parent'), 166 rq.Window('window'), 167 rq.Int16('x'), 168 rq.Int16('y'), 169 rq.Card16('width'), 170 rq.Card16('height'), 171 rq.Card16('border_width'), 172 rq.Card8('override'), 173 rq.Pad(9), 174 ) 175 176class DestroyNotify(rq.Event): 177 _code = X.DestroyNotify 178 _fields = rq.Struct( rq.Card8('type'), 179 rq.Pad(1), 180 rq.Card16('sequence_number'), 181 rq.Window('event'), 182 rq.Window('window'), 183 rq.Pad(20), 184 ) 185 186class UnmapNotify(rq.Event): 187 _code = X.UnmapNotify 188 _fields = rq.Struct( rq.Card8('type'), 189 rq.Pad(1), 190 rq.Card16('sequence_number'), 191 rq.Window('event'), 192 rq.Window('window'), 193 rq.Card8('from_configure'), 194 rq.Pad(19), 195 ) 196 197class MapNotify(rq.Event): 198 _code = X.MapNotify 199 _fields = rq.Struct( rq.Card8('type'), 200 rq.Pad(1), 201 rq.Card16('sequence_number'), 202 rq.Window('event'), 203 rq.Window('window'), 204 rq.Card8('override'), 205 rq.Pad(19), 206 ) 207 208class MapRequest(rq.Event): 209 _code = X.MapRequest 210 _fields = rq.Struct( rq.Card8('type'), 211 rq.Pad(1), 212 rq.Card16('sequence_number'), 213 rq.Window('parent'), 214 rq.Window('window'), 215 rq.Pad(20), 216 ) 217 218class ReparentNotify(rq.Event): 219 _code = X.ReparentNotify 220 _fields = rq.Struct( rq.Card8('type'), 221 rq.Pad(1), 222 rq.Card16('sequence_number'), 223 rq.Window('event'), 224 rq.Window('window'), 225 rq.Window('parent'), 226 rq.Int16('x'), 227 rq.Int16('y'), 228 rq.Card8('override'), 229 rq.Pad(11), 230 ) 231 232class ConfigureNotify(rq.Event): 233 _code = X.ConfigureNotify 234 _fields = rq.Struct( rq.Card8('type'), 235 rq.Pad(1), 236 rq.Card16('sequence_number'), 237 rq.Window('event'), 238 rq.Window('window'), 239 rq.Window('above_sibling', (X.NONE, )), 240 rq.Int16('x'), 241 rq.Int16('y'), 242 rq.Card16('width'), 243 rq.Card16('height'), 244 rq.Card16('border_width'), 245 rq.Card8('override'), 246 rq.Pad(5), 247 ) 248 249class ConfigureRequest(rq.Event): 250 _code = X.ConfigureRequest 251 _fields = rq.Struct( rq.Card8('type'), 252 rq.Card8('stack_mode'), 253 rq.Card16('sequence_number'), 254 rq.Window('parent'), 255 rq.Window('window'), 256 rq.Window('sibling', (X.NONE, )), 257 rq.Int16('x'), 258 rq.Int16('y'), 259 rq.Card16('width'), 260 rq.Card16('height'), 261 rq.Card16('border_width'), 262 rq.Card16('value_mask'), 263 rq.Pad(4), 264 ) 265 266class GravityNotify(rq.Event): 267 _code = X.GravityNotify 268 _fields = rq.Struct( rq.Card8('type'), 269 rq.Pad(1), 270 rq.Card16('sequence_number'), 271 rq.Window('event'), 272 rq.Window('window'), 273 rq.Int16('x'), 274 rq.Int16('y'), 275 rq.Pad(16), 276 ) 277 278class ResizeRequest(rq.Event): 279 _code = X.ResizeRequest 280 _fields = rq.Struct( rq.Card8('type'), 281 rq.Pad(1), 282 rq.Card16('sequence_number'), 283 rq.Window('window'), 284 rq.Card16('width'), 285 rq.Card16('height'), 286 rq.Pad(20), 287 ) 288 289class Circulate(rq.Event): 290 _code = None 291 _fields = rq.Struct( rq.Card8('type'), 292 rq.Pad(1), 293 rq.Card16('sequence_number'), 294 rq.Window('event'), 295 rq.Window('window'), 296 rq.Pad(4), 297 rq.Card8('place'), 298 rq.Pad(15), 299 ) 300 301class CirculateNotify(Circulate): 302 _code = X.CirculateNotify 303 304class CirculateRequest(Circulate): 305 _code = X.CirculateRequest 306 307class PropertyNotify(rq.Event): 308 _code = X.PropertyNotify 309 _fields = rq.Struct( rq.Card8('type'), 310 rq.Pad(1), 311 rq.Card16('sequence_number'), 312 rq.Window('window'), 313 rq.Card32('atom'), 314 rq.Card32('time'), 315 rq.Card8('state'), 316 rq.Pad(15), 317 ) 318 319class SelectionClear(rq.Event): 320 _code = X.SelectionClear 321 _fields = rq.Struct( rq.Card8('type'), 322 rq.Pad(1), 323 rq.Card16('sequence_number'), 324 rq.Card32('time'), 325 rq.Window('window'), 326 rq.Card32('atom'), 327 rq.Pad(16), 328 ) 329 330class SelectionRequest(rq.Event): 331 _code = X.SelectionRequest 332 _fields = rq.Struct( rq.Card8('type'), 333 rq.Pad(1), 334 rq.Card16('sequence_number'), 335 rq.Card32('time'), 336 rq.Window('owner'), 337 rq.Window('requestor'), 338 rq.Card32('selection'), 339 rq.Card32('target'), 340 rq.Card32('property'), 341 rq.Pad(4), 342 ) 343 344class SelectionNotify(rq.Event): 345 _code = X.SelectionNotify 346 _fields = rq.Struct( rq.Card8('type'), 347 rq.Pad(1), 348 rq.Card16('sequence_number'), 349 rq.Card32('time'), 350 rq.Window('requestor'), 351 rq.Card32('selection'), 352 rq.Card32('target'), 353 rq.Card32('property'), 354 rq.Pad(8), 355 ) 356 357class ColormapNotify(rq.Event): 358 _code = X.ColormapNotify 359 _fields = rq.Struct( rq.Card8('type'), 360 rq.Pad(1), 361 rq.Card16('sequence_number'), 362 rq.Window('window'), 363 rq.Colormap('colormap', (X.NONE, )), 364 rq.Card8('new'), 365 rq.Card8('state'), 366 rq.Pad(18), 367 ) 368 369class MappingNotify(rq.Event): 370 _code = X.MappingNotify 371 _fields = rq.Struct( rq.Card8('type'), 372 rq.Pad(1), 373 rq.Card16('sequence_number'), 374 rq.Card8('request'), 375 rq.Card8('first_keycode'), 376 rq.Card8('count'), 377 rq.Pad(25), 378 ) 379 380class ClientMessage(rq.Event): 381 _code = X.ClientMessage 382 _fields = rq.Struct( rq.Card8('type'), 383 rq.Format('data', 1), 384 rq.Card16('sequence_number'), 385 rq.Window('window'), 386 rq.Card32('client_type'), 387 rq.FixedPropertyData('data', 20), 388 ) 389 390class KeymapNotify(rq.Event): 391 _code = X.KeymapNotify 392 _fields = rq.Struct( rq.Card8('type'), 393 rq.FixedList('data', 31, rq.Card8Obj, pad = 0) 394 ) 395 396 397event_class = { 398 X.KeyPress: KeyPress, 399 X.KeyRelease: KeyRelease, 400 X.ButtonPress: ButtonPress, 401 X.ButtonRelease: ButtonRelease, 402 X.MotionNotify: MotionNotify, 403 X.EnterNotify: EnterNotify, 404 X.LeaveNotify: LeaveNotify, 405 X.FocusIn: FocusIn, 406 X.FocusOut: FocusOut, 407 X.KeymapNotify: KeymapNotify, 408 X.Expose: Expose, 409 X.GraphicsExpose: GraphicsExpose, 410 X.NoExpose: NoExpose, 411 X.VisibilityNotify: VisibilityNotify, 412 X.CreateNotify: CreateNotify, 413 X.DestroyNotify: DestroyNotify, 414 X.UnmapNotify: UnmapNotify, 415 X.MapNotify: MapNotify, 416 X.MapRequest: MapRequest, 417 X.ReparentNotify: ReparentNotify, 418 X.ConfigureNotify: ConfigureNotify, 419 X.ConfigureRequest: ConfigureRequest, 420 X.GravityNotify: GravityNotify, 421 X.ResizeRequest: ResizeRequest, 422 X.CirculateNotify: CirculateNotify, 423 X.CirculateRequest: CirculateRequest, 424 X.PropertyNotify: PropertyNotify, 425 X.SelectionClear: SelectionClear, 426 X.SelectionRequest: SelectionRequest, 427 X.SelectionNotify: SelectionNotify, 428 X.ColormapNotify: ColormapNotify, 429 X.ClientMessage: ClientMessage, 430 X.MappingNotify: MappingNotify, 431 } 432