chiark / gitweb /
Added note saying the file should probably be treated as being GPL
[clg] / gdk / gdkevents.lisp
CommitLineData
55212af1 1;; Common Lisp bindings for GTK+ v2.x
c554ae48 2;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net>
35a82fd6 3;;
55212af1 4;; Permission is hereby granted, free of charge, to any person obtaining
5;; a copy of this software and associated documentation files (the
6;; "Software"), to deal in the Software without restriction, including
7;; without limitation the rights to use, copy, modify, merge, publish,
8;; distribute, sublicense, and/or sell copies of the Software, and to
9;; permit persons to whom the Software is furnished to do so, subject to
10;; the following conditions:
35a82fd6 11;;
55212af1 12;; The above copyright notice and this permission notice shall be
13;; included in all copies or substantial portions of the Software.
35a82fd6 14;;
55212af1 15;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35a82fd6 22
700056aa 23;; $Id: gdkevents.lisp,v 1.15 2008/03/18 15:08:08 espen Exp $
35a82fd6 24
25(in-package "GDK")
26
27
35a82fd6 28;;;; Metaclass for event classes
29
30(eval-when (:compile-toplevel :load-toplevel :execute)
c554ae48 31 (defvar *event-classes* (make-hash-table))
32
6baf860c 33 (defclass event-class (boxed-class)
c554ae48 34 ((event-type :reader event-class-type :initform nil)))
35a82fd6 35
6baf860c 36 (defmethod validate-superclass ((class event-class) (super standard-class))
48f4250a 37 ;(subtypep (class-name super) 'event)
c554ae48 38 t)
39
40 (defmethod shared-initialize ((class event-class) names &key name event-type)
41 (declare (ignore names))
42 (register-type-alias (or name (class-name class)) 'event)
43 (call-next-method)
44 (when event-type
45 (setf (slot-value class 'event-type) (first event-type))
46 (setf (gethash (first event-type) *event-classes*) class))))
f33ff27a 47
6baf860c 48(let ((reader (reader-function 'event-type)))
49 (defun %event-class (location)
7f392865 50 (or
51 (gethash (funcall reader location 0) *event-classes*)
52 (error "No class defined for event type: ~S" (funcall reader location 0)))))
35a82fd6 53
c554ae48 54(defmethod make-proxy-instance :around ((class event-class) location
55 &rest initargs)
6baf860c 56 (let ((class (%event-class location)))
1d06a422 57 (apply #'call-next-method class location initargs)))
35a82fd6 58
59
c554ae48 60;; The class event is the only class that actually exists in the
61;; GObject class hierarchy
35a82fd6 62
48f4250a 63(eval-when (:compile-toplevel :load-toplevel :execute)
64 (defclass event (boxed)
65 ((%type
66 :allocation :alien
67 :type event-type)
68 (window
69 :allocation :alien
70 :accessor event-window
71 :initarg :window
72 :type window)
73 (send-event
74 :allocation :alien
75 :accessor event-send-event
76 :initarg :send-event
c554ae48 77 :type (bool 8)))
78 (:metaclass boxed-class)))
48f4250a 79
ebe0decd 80(defmethod initialize-instance :after ((event event) &rest initargs)
48f4250a 81 (declare (ignore initargs))
48f4250a 82 (setf (slot-value event '%type) (event-class-type (class-of event))))
83
ebe0decd 84(defmethod make-proxy-instance ((class (eql (find-class 'event))) location &rest initargs)
c554ae48 85 (let ((class (%event-class location)))
ebe0decd 86 (apply #'make-proxy-instance class location initargs)))
c554ae48 87
48f4250a 88
35a82fd6 89(defclass timed-event (event)
90 ((time
91 :allocation :alien
92 :accessor event-time
93 :initarg :time
94 :type (unsigned 32)))
6baf860c 95 (:metaclass event-class))
35a82fd6 96
97(defclass delete-event (event)
98 ()
99 (:metaclass event-class)
c554ae48 100 (:event-type :delete))
35a82fd6 101
6baf860c 102
35a82fd6 103(defclass destroy-event (event)
104 ()
105 (:metaclass event-class)
c554ae48 106 (:event-type :destroy))
35a82fd6 107
108(defclass expose-event (event)
109 ((x
110 :allocation :alien
111 :accessor event-x
112 :initarg :x
113 :type int)
114 (y
115 :allocation :alien
116 :accessor event-y
117 :initarg :y
118 :type int)
119 (width
120 :allocation :alien
121 :accessor event-width
122 :initarg :width
123 :type int)
124 (height
125 :allocation :alien
126 :accessor event-height
127 :initarg :height
128 :type int)
48f4250a 129 (region
130 :allocation :alien
131 :accessor event-region
132 :initarg :region
133 :type pointer)
35a82fd6 134 (count
135 :allocation :alien
136 :accessor event-count
137 :initarg :count
138 :type int))
139 (:metaclass event-class)
c554ae48 140 (:event-type :expose))
35a82fd6 141
48f4250a 142(defclass input-event (timed-event)
35a82fd6 143 ((x
144 :allocation :alien
145 :accessor event-x
146 :initarg :x
147 :type double-float)
148 (y
149 :allocation :alien
150 :accessor event-y
151 :initarg :y
152 :type double-float)
48f4250a 153 (axes
154 :allocation :alien
155 :accessor event-axes
156 :initarg :axes
157 :type pointer) ;double-float)
35a82fd6 158 (state
159 :allocation :alien
35a82fd6 160 :accessor event-state
161 :initarg :state
48f4250a 162 :type modifier-type))
163 (:metaclass event-class))
164
165
166(defclass motion-notify-event (input-event)
167 ((is-hint
35a82fd6 168 :allocation :alien
169 :accessor event-is-hint
170 :initarg :is-hint
171 :type (signed 16) ; should it be (boolean 16)?
172 )
173 (device
174 :allocation :alien
175 :offset 2
176 :accessor event-device
177 :initarg :device
178 :type device)
179 (root-x
180 :allocation :alien
181 :accessor event-root-x
182 :initarg :root-x
183 :type double-float)
184 (root-y
185 :allocation :alien
186 :accessor event-root-y
187 :initarg :root-y
188 :type double-float))
189 (:metaclass event-class)
c554ae48 190 (:event-type :motion-notify))
35a82fd6 191
48f4250a 192(defclass button-event (input-event)
193 ((button
35a82fd6 194 :allocation :alien
195 :accessor event-button
196 :initarg :button
197 :type unsigned-int)
198 (device
199 :allocation :alien
200 :accessor event-device
201 :initarg :device
202 :type device)
203 (root-x
204 :allocation :alien
205 :accessor event-root-x
206 :initarg :root-x
207 :type double-float)
208 (root-y
209 :allocation :alien
210 :accessor event-root-y
211 :initarg :root-y
212 :type double-float))
48f4250a 213 (:metaclass event-class))
214
215(defclass button-press-event (button-event)
216 ()
35a82fd6 217 (:metaclass event-class)
c554ae48 218 (:event-type :button-press))
35a82fd6 219
220(defclass 2-button-press-event (button-press-event)
221 ()
222 (:metaclass event-class)
c554ae48 223 (:event-type :2button-press))
35a82fd6 224
225(defclass 3-button-press-event (button-press-event)
226 ()
227 (:metaclass event-class)
c554ae48 228 (:event-type :3button-press))
35a82fd6 229
48f4250a 230(defclass button-release-event (button-event)
35a82fd6 231 ()
232 (:metaclass event-class)
c554ae48 233 (:event-type :button-release))
35a82fd6 234
48f4250a 235
236(defclass key-event (timed-event)
237 ((state
238 :allocation :alien
239 :accessor event-state
240 :initarg :state
241 :type modifier-type)
242 (keyval
243 :allocation :alien
244 :accessor event-keyval
245 :initarg :keyval
246 :type unsigned-int)
247 (length
248 :allocation :alien
249 :accessor event-length
250 :initarg :length
251 :type unsigned-int)
252 (string
253 :allocation :alien
254 :accessor event-string
255 :initarg :string
256 :type string)
257 (hardware-keycode
258 :allocation :alien
259 :accessor event-hardware-keycode
260 :initarg :hardware-keycode
261 :type (unsigned 16))
262 (group
263 :allocation :alien
264 :accessor event-group
265 :initarg :group
266 :type (unsigned 8)))
267 (:metaclass event-class))
268
269(defclass key-press-event (key-event)
35a82fd6 270 ()
271 (:metaclass event-class)
c554ae48 272 (:event-type :key-press))
35a82fd6 273
48f4250a 274(defclass key-release-event (key-event)
35a82fd6 275 ()
276 (:metaclass event-class)
c554ae48 277 (:event-type :key-release))
35a82fd6 278
48f4250a 279
280(defclass crossing-event (event)
281 ((subwindow
282 :allocation :alien
283 :accessor event-subwindow
284 :initarg :subwindow
285 :type window)
286 (time
287 :allocation :alien
288 :accessor event-time
289 :initarg :time
290 :type (unsigned 32))
291 (x
292 :allocation :alien
293 :accessor event-x
294 :initarg :x
295 :type double-float)
296 (y
297 :allocation :alien
298 :accessor event-y
299 :initarg :y
300 :type double-float)
301 (root-x
302 :allocation :alien
303 :accessor event-root-x
304 :initarg :root-x
305 :type double-float)
306 (root-y
307 :allocation :alien
308 :accessor event-root-y
309 :initarg :root-y
310 :type double-float)
311 (mode
312 :allocation :alien
313 :accessor event-mode
314 :initarg :mode
315 :type crossing-mode)
316 (detail
317 :allocation :alien
318 :accessor event-detail
319 :initarg :detail
320 :type notify-type)
321 (focus
322 :allocation :alien
323 :accessor event-focus
324 :initarg :focus
325 :type boolean)
326 (state
327 :allocation :alien
328 :accessor event-state
329 :initarg :state
330 :type unsigned-int))
331 (:metaclass event-class))
332
333
334(defclass enter-notify-event (crossing-event)
35a82fd6 335 ()
336 (:metaclass event-class)
c554ae48 337 (:event-type :enter-notify))
35a82fd6 338
48f4250a 339(defclass leave-notify-event (crossing-event)
35a82fd6 340 ()
341 (:metaclass event-class)
c554ae48 342 (:event-type :leave-notify))
35a82fd6 343
344(defclass focus-change-event (event)
48f4250a 345 ((in
346 :allocation :alien
347 :accessor event-in
348 :initarg :in
c554ae48 349 :type (bool 16)))
35a82fd6 350 (:metaclass event-class)
c554ae48 351 (:event-type :focus-change))
35a82fd6 352
353(defclass configure-event (event)
354 ((x
355 :allocation :alien
356 :accessor event-x
357 :initarg :x
358 :type int)
359 (y
360 :allocation :alien
361 :accessor event-y
362 :initarg :y
363 :type int)
364 (width
365 :allocation :alien
366 :accessor event-width
367 :initarg :width
368 :type int)
369 (height
370 :allocation :alien
371 :accessor event-height
372 :initarg :height
373 :type int))
374 (:metaclass event-class)
c554ae48 375 (:event-type :configure))
35a82fd6 376
377(defclass map-event (event)
378 ()
379 (:metaclass event-class)
c554ae48 380 (:event-type :map))
35a82fd6 381
382(defclass unmap-event (event)
383 ()
384 (:metaclass event-class)
c554ae48 385 (:event-type :unmap))
35a82fd6 386
387(defclass property-notify-event (event)
388 ()
389 (:metaclass event-class)
c554ae48 390 (:event-type :property-notify))
35a82fd6 391
392(defclass selection-clear-event (event)
393 ()
394 (:metaclass event-class)
c554ae48 395 (:event-type :selection-clear))
35a82fd6 396
397(defclass selection-request-event (event)
398 ()
399 (:metaclass event-class)
c554ae48 400 (:event-type :selection-request))
35a82fd6 401
402(defclass selection-notify-event (event)
403 ()
404 (:metaclass event-class)
c554ae48 405 (:event-type :selection-notify))
35a82fd6 406
48f4250a 407(defclass dnd-event (event)
408 ((context
409 :allocation :alien
410 :accessor event-contex
411 :initarg :context
412 :type drag-context)
413 (time
414 :allocation :alien
415 :accessor event-time
416 :initarg :time
417 :type (unsigned 32))
418 (x-root
419 :allocation :alien
420 :accessor event-x-root
421 :initarg :x-root
422 :type short)
423 (y-root
424 :allocation :alien
425 :accessor event-y-root
426 :initarg :y-root
427 :type short))
428 (:metaclass event-class))
429
430(defclass drag-enter-event (dnd-event)
35a82fd6 431 ()
432 (:metaclass event-class)
c554ae48 433 (:event-type :drag-enter))
35a82fd6 434
48f4250a 435(defclass drag-leave-event (dnd-event)
35a82fd6 436 ()
437 (:metaclass event-class)
c554ae48 438 (:event-type :drag-leave))
35a82fd6 439
48f4250a 440(defclass drag-motion-event (dnd-event)
35a82fd6 441 ()
442 (:metaclass event-class)
c554ae48 443 (:event-type :drag-motion))
35a82fd6 444
48f4250a 445(defclass drag-status-event (dnd-event)
35a82fd6 446 ()
447 (:metaclass event-class)
c554ae48 448 (:event-type :drag-status))
35a82fd6 449
48f4250a 450(defclass drot-start-event (dnd-event)
35a82fd6 451 ()
452 (:metaclass event-class)
c554ae48 453 (:event-type :drop-start))
35a82fd6 454
48f4250a 455(defclass drop-finished-event (dnd-event)
35a82fd6 456 ()
457 (:metaclass event-class)
c554ae48 458 (:event-type :drop-finished))
35a82fd6 459
460(defclass client-event (event)
461 ()
462 (:metaclass event-class)
c554ae48 463 (:event-type :client-event))
35a82fd6 464
465(defclass visibility-notify-event (event)
466 ((state
467 :allocation :alien
468 :accessor event-state
469 :initarg :state
470 :type visibility-state))
471 (:metaclass event-class)
c554ae48 472 (:event-type :visibility-notify))
35a82fd6 473
474(defclass no-expose-event (event)
475 ()
476 (:metaclass event-class)
c554ae48 477 (:event-type :no-expose))
35a82fd6 478
479(defclass scroll-event (timed-event)
48f4250a 480 ((x
481 :allocation :alien
482 :accessor event-x
483 :initarg :x
484 :type double-float)
485 (y
486 :allocation :alien
487 :accessor event-y
488 :initarg :y
489 :type double-float)
490 (state
491 :allocation :alien
492 :accessor event-state
493 :initarg :state
494 :type modifier-type)
495 (direction
496 :allocation :alien
497 :accessor event-direction
498 :initarg :direction
499 :type scroll-direction)
500 (root-x
501 :allocation :alien
502 :accessor event-root-x
503 :initarg :root-x
504 :type double-float)
505 (root-y
506 :allocation :alien
507 :accessor event-root-y
508 :initarg :root-y
509 :type double-float))
35a82fd6 510 (:metaclass event-class)
c554ae48 511 (:event-type :scroll))
35a82fd6 512
48f4250a 513(defclass setting-event (event)
514 ((action
515 :allocation :alien
516 :accessor event-action
517 :initarg :action
518 :type setting-action)
519 (name
520 :allocation :alien
521 :accessor event-name
522 :initarg :name
523 :type string))
35a82fd6 524 (:metaclass event-class)
c554ae48 525 (:event-type :setting))
48f4250a 526
527(defclass proximity-event (timed-event)
528 ((device
529 :allocation :alien
530 :accessor event-device
531 :initarg :device
532 :type device))
533 (:metaclass event-class))
534
535(defclass proximity-in-event (proximity-event)
536 ()
537 (:metaclass event-class)
c554ae48 538 (:event-type :proximity-in))
48f4250a 539
540(defclass proximity-out-event (proximity-event)
541 ()
542 (:metaclass event-class)
c554ae48 543 (:event-type :proximity-out))
48f4250a 544
545(defclass window-state-event (event)
546 ((change-mask
547 :allocation :alien
548 :accessor event-change-mask
549 :initarg :change-mask
550 :type window-state)
551 (new-window-state
552 :allocation :alien
553 :accessor event-new-window-state
554 :initarg :new-window-state
555 :type window-state))
556 (:metaclass event-class)
c554ae48 557 (:event-type :window-state))
48f4250a 558
559(defclass owner-change-event (event)
560 ()
561 (:metaclass event-class)
c554ae48 562 (:event-type :owner-change))
48f4250a 563
7f392865 564(defclass grab-broken-event (event)
565 ((keyboard
566 :allocation :alien
567 :accessor event-keyboard
568 :initarg :keyboard
569 :type boolean)
570 (implicit
571 :allocation :alien
572 :accessor event-implicit
573 :initarg :implicit
700056aa 574 :type boolean)
575 (grab-window
576 :allocation :alien
577 :accessor event-grab-window
578 :initarg :grab-window
579 :type window))
7f392865 580 (:metaclass event-class)
581 (:event-type :grab-broken))