112ac1d3 |
1 | ;; Common Lisp bindings for GTK+ v2.x |
57e4839d |
2 | ;; Copyright 1999-2006 Espen S. Johnsen <espen@users.sf.net> |
5d462688 |
3 | ;; |
112ac1d3 |
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: |
5d462688 |
11 | ;; |
112ac1d3 |
12 | ;; The above copyright notice and this permission notice shall be |
13 | ;; included in all copies or substantial portions of the Software. |
5d462688 |
14 | ;; |
112ac1d3 |
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. |
5d462688 |
22 | |
5421c488 |
23 | ;; $Id: gdkevents.lisp,v 1.13 2008-01-07 16:02:23 espen Exp $ |
5d462688 |
24 | |
25 | (in-package "GDK") |
26 | |
27 | |
5d462688 |
28 | ;;;; Metaclass for event classes |
29 | |
30 | (eval-when (:compile-toplevel :load-toplevel :execute) |
57e4839d |
31 | (defvar *event-classes* (make-hash-table)) |
32 | |
9adccb27 |
33 | (defclass event-class (boxed-class) |
57e4839d |
34 | ((event-type :reader event-class-type :initform nil))) |
5d462688 |
35 | |
9adccb27 |
36 | (defmethod validate-superclass ((class event-class) (super standard-class)) |
c07660b3 |
37 | ;(subtypep (class-name super) 'event) |
57e4839d |
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)))) |
e2696f46 |
47 | |
9adccb27 |
48 | (let ((reader (reader-function 'event-type))) |
49 | (defun %event-class (location) |
50 | (gethash (funcall reader location 0) *event-classes*))) |
5d462688 |
51 | |
57e4839d |
52 | (defmethod make-proxy-instance :around ((class event-class) location |
53 | &rest initargs) |
9adccb27 |
54 | (let ((class (%event-class location))) |
8958fa4a |
55 | (apply #'call-next-method class location initargs))) |
5d462688 |
56 | |
57 | |
57e4839d |
58 | ;; The class event is the only class that actually exists in the |
59 | ;; GObject class hierarchy |
5d462688 |
60 | |
c07660b3 |
61 | (eval-when (:compile-toplevel :load-toplevel :execute) |
62 | (defclass event (boxed) |
63 | ((%type |
64 | :allocation :alien |
65 | :type event-type) |
66 | (window |
67 | :allocation :alien |
68 | :accessor event-window |
69 | :initarg :window |
70 | :type window) |
71 | (send-event |
72 | :allocation :alien |
73 | :accessor event-send-event |
74 | :initarg :send-event |
57e4839d |
75 | :type (bool 8))) |
76 | (:metaclass boxed-class))) |
c07660b3 |
77 | |
5421c488 |
78 | (defmethod initialize-instance :after ((event event) &rest initargs) |
c07660b3 |
79 | (declare (ignore initargs)) |
c07660b3 |
80 | (setf (slot-value event '%type) (event-class-type (class-of event)))) |
81 | |
5421c488 |
82 | (defmethod make-proxy-instance ((class (eql (find-class 'event))) location &rest initargs) |
57e4839d |
83 | (let ((class (%event-class location))) |
5421c488 |
84 | (apply #'make-proxy-instance class location initargs))) |
57e4839d |
85 | |
c07660b3 |
86 | |
5d462688 |
87 | (defclass timed-event (event) |
88 | ((time |
89 | :allocation :alien |
90 | :accessor event-time |
91 | :initarg :time |
92 | :type (unsigned 32))) |
9adccb27 |
93 | (:metaclass event-class)) |
5d462688 |
94 | |
95 | (defclass delete-event (event) |
96 | () |
97 | (:metaclass event-class) |
57e4839d |
98 | (:event-type :delete)) |
5d462688 |
99 | |
9adccb27 |
100 | |
5d462688 |
101 | (defclass destroy-event (event) |
102 | () |
103 | (:metaclass event-class) |
57e4839d |
104 | (:event-type :destroy)) |
5d462688 |
105 | |
106 | (defclass expose-event (event) |
107 | ((x |
108 | :allocation :alien |
109 | :accessor event-x |
110 | :initarg :x |
111 | :type int) |
112 | (y |
113 | :allocation :alien |
114 | :accessor event-y |
115 | :initarg :y |
116 | :type int) |
117 | (width |
118 | :allocation :alien |
119 | :accessor event-width |
120 | :initarg :width |
121 | :type int) |
122 | (height |
123 | :allocation :alien |
124 | :accessor event-height |
125 | :initarg :height |
126 | :type int) |
c07660b3 |
127 | (region |
128 | :allocation :alien |
129 | :accessor event-region |
130 | :initarg :region |
131 | :type pointer) |
5d462688 |
132 | (count |
133 | :allocation :alien |
134 | :accessor event-count |
135 | :initarg :count |
136 | :type int)) |
137 | (:metaclass event-class) |
57e4839d |
138 | (:event-type :expose)) |
5d462688 |
139 | |
c07660b3 |
140 | (defclass input-event (timed-event) |
5d462688 |
141 | ((x |
142 | :allocation :alien |
143 | :accessor event-x |
144 | :initarg :x |
145 | :type double-float) |
146 | (y |
147 | :allocation :alien |
148 | :accessor event-y |
149 | :initarg :y |
150 | :type double-float) |
c07660b3 |
151 | (axes |
152 | :allocation :alien |
153 | :accessor event-axes |
154 | :initarg :axes |
155 | :type pointer) ;double-float) |
5d462688 |
156 | (state |
157 | :allocation :alien |
5d462688 |
158 | :accessor event-state |
159 | :initarg :state |
c07660b3 |
160 | :type modifier-type)) |
161 | (:metaclass event-class)) |
162 | |
163 | |
164 | (defclass motion-notify-event (input-event) |
165 | ((is-hint |
5d462688 |
166 | :allocation :alien |
167 | :accessor event-is-hint |
168 | :initarg :is-hint |
169 | :type (signed 16) ; should it be (boolean 16)? |
170 | ) |
171 | (device |
172 | :allocation :alien |
173 | :offset 2 |
174 | :accessor event-device |
175 | :initarg :device |
176 | :type device) |
177 | (root-x |
178 | :allocation :alien |
179 | :accessor event-root-x |
180 | :initarg :root-x |
181 | :type double-float) |
182 | (root-y |
183 | :allocation :alien |
184 | :accessor event-root-y |
185 | :initarg :root-y |
186 | :type double-float)) |
187 | (:metaclass event-class) |
57e4839d |
188 | (:event-type :motion-notify)) |
5d462688 |
189 | |
c07660b3 |
190 | (defclass button-event (input-event) |
191 | ((button |
5d462688 |
192 | :allocation :alien |
193 | :accessor event-button |
194 | :initarg :button |
195 | :type unsigned-int) |
196 | (device |
197 | :allocation :alien |
198 | :accessor event-device |
199 | :initarg :device |
200 | :type device) |
201 | (root-x |
202 | :allocation :alien |
203 | :accessor event-root-x |
204 | :initarg :root-x |
205 | :type double-float) |
206 | (root-y |
207 | :allocation :alien |
208 | :accessor event-root-y |
209 | :initarg :root-y |
210 | :type double-float)) |
c07660b3 |
211 | (:metaclass event-class)) |
212 | |
213 | (defclass button-press-event (button-event) |
214 | () |
5d462688 |
215 | (:metaclass event-class) |
57e4839d |
216 | (:event-type :button-press)) |
5d462688 |
217 | |
218 | (defclass 2-button-press-event (button-press-event) |
219 | () |
220 | (:metaclass event-class) |
57e4839d |
221 | (:event-type :2button-press)) |
5d462688 |
222 | |
223 | (defclass 3-button-press-event (button-press-event) |
224 | () |
225 | (:metaclass event-class) |
57e4839d |
226 | (:event-type :3button-press)) |
5d462688 |
227 | |
c07660b3 |
228 | (defclass button-release-event (button-event) |
5d462688 |
229 | () |
230 | (:metaclass event-class) |
57e4839d |
231 | (:event-type :button-release)) |
5d462688 |
232 | |
c07660b3 |
233 | |
234 | (defclass key-event (timed-event) |
235 | ((state |
236 | :allocation :alien |
237 | :accessor event-state |
238 | :initarg :state |
239 | :type modifier-type) |
240 | (keyval |
241 | :allocation :alien |
242 | :accessor event-keyval |
243 | :initarg :keyval |
244 | :type unsigned-int) |
245 | (length |
246 | :allocation :alien |
247 | :accessor event-length |
248 | :initarg :length |
249 | :type unsigned-int) |
250 | (string |
251 | :allocation :alien |
252 | :accessor event-string |
253 | :initarg :string |
254 | :type string) |
255 | (hardware-keycode |
256 | :allocation :alien |
257 | :accessor event-hardware-keycode |
258 | :initarg :hardware-keycode |
259 | :type (unsigned 16)) |
260 | (group |
261 | :allocation :alien |
262 | :accessor event-group |
263 | :initarg :group |
264 | :type (unsigned 8))) |
265 | (:metaclass event-class)) |
266 | |
267 | (defclass key-press-event (key-event) |
5d462688 |
268 | () |
269 | (:metaclass event-class) |
57e4839d |
270 | (:event-type :key-press)) |
5d462688 |
271 | |
c07660b3 |
272 | (defclass key-release-event (key-event) |
5d462688 |
273 | () |
274 | (:metaclass event-class) |
57e4839d |
275 | (:event-type :key-release)) |
5d462688 |
276 | |
c07660b3 |
277 | |
278 | (defclass crossing-event (event) |
279 | ((subwindow |
280 | :allocation :alien |
281 | :accessor event-subwindow |
282 | :initarg :subwindow |
283 | :type window) |
284 | (time |
285 | :allocation :alien |
286 | :accessor event-time |
287 | :initarg :time |
288 | :type (unsigned 32)) |
289 | (x |
290 | :allocation :alien |
291 | :accessor event-x |
292 | :initarg :x |
293 | :type double-float) |
294 | (y |
295 | :allocation :alien |
296 | :accessor event-y |
297 | :initarg :y |
298 | :type double-float) |
299 | (root-x |
300 | :allocation :alien |
301 | :accessor event-root-x |
302 | :initarg :root-x |
303 | :type double-float) |
304 | (root-y |
305 | :allocation :alien |
306 | :accessor event-root-y |
307 | :initarg :root-y |
308 | :type double-float) |
309 | (mode |
310 | :allocation :alien |
311 | :accessor event-mode |
312 | :initarg :mode |
313 | :type crossing-mode) |
314 | (detail |
315 | :allocation :alien |
316 | :accessor event-detail |
317 | :initarg :detail |
318 | :type notify-type) |
319 | (focus |
320 | :allocation :alien |
321 | :accessor event-focus |
322 | :initarg :focus |
323 | :type boolean) |
324 | (state |
325 | :allocation :alien |
326 | :accessor event-state |
327 | :initarg :state |
328 | :type unsigned-int)) |
329 | (:metaclass event-class)) |
330 | |
331 | |
332 | (defclass enter-notify-event (crossing-event) |
5d462688 |
333 | () |
334 | (:metaclass event-class) |
57e4839d |
335 | (:event-type :enter-notify)) |
5d462688 |
336 | |
c07660b3 |
337 | (defclass leave-notify-event (crossing-event) |
5d462688 |
338 | () |
339 | (:metaclass event-class) |
57e4839d |
340 | (:event-type :leave-notify)) |
5d462688 |
341 | |
342 | (defclass focus-change-event (event) |
c07660b3 |
343 | ((in |
344 | :allocation :alien |
345 | :accessor event-in |
346 | :initarg :in |
57e4839d |
347 | :type (bool 16))) |
5d462688 |
348 | (:metaclass event-class) |
57e4839d |
349 | (:event-type :focus-change)) |
5d462688 |
350 | |
351 | (defclass configure-event (event) |
352 | ((x |
353 | :allocation :alien |
354 | :accessor event-x |
355 | :initarg :x |
356 | :type int) |
357 | (y |
358 | :allocation :alien |
359 | :accessor event-y |
360 | :initarg :y |
361 | :type int) |
362 | (width |
363 | :allocation :alien |
364 | :accessor event-width |
365 | :initarg :width |
366 | :type int) |
367 | (height |
368 | :allocation :alien |
369 | :accessor event-height |
370 | :initarg :height |
371 | :type int)) |
372 | (:metaclass event-class) |
57e4839d |
373 | (:event-type :configure)) |
5d462688 |
374 | |
375 | (defclass map-event (event) |
376 | () |
377 | (:metaclass event-class) |
57e4839d |
378 | (:event-type :map)) |
5d462688 |
379 | |
380 | (defclass unmap-event (event) |
381 | () |
382 | (:metaclass event-class) |
57e4839d |
383 | (:event-type :unmap)) |
5d462688 |
384 | |
385 | (defclass property-notify-event (event) |
386 | () |
387 | (:metaclass event-class) |
57e4839d |
388 | (:event-type :property-notify)) |
5d462688 |
389 | |
390 | (defclass selection-clear-event (event) |
391 | () |
392 | (:metaclass event-class) |
57e4839d |
393 | (:event-type :selection-clear)) |
5d462688 |
394 | |
395 | (defclass selection-request-event (event) |
396 | () |
397 | (:metaclass event-class) |
57e4839d |
398 | (:event-type :selection-request)) |
5d462688 |
399 | |
400 | (defclass selection-notify-event (event) |
401 | () |
402 | (:metaclass event-class) |
57e4839d |
403 | (:event-type :selection-notify)) |
5d462688 |
404 | |
c07660b3 |
405 | (defclass dnd-event (event) |
406 | ((context |
407 | :allocation :alien |
408 | :accessor event-contex |
409 | :initarg :context |
410 | :type drag-context) |
411 | (time |
412 | :allocation :alien |
413 | :accessor event-time |
414 | :initarg :time |
415 | :type (unsigned 32)) |
416 | (x-root |
417 | :allocation :alien |
418 | :accessor event-x-root |
419 | :initarg :x-root |
420 | :type short) |
421 | (y-root |
422 | :allocation :alien |
423 | :accessor event-y-root |
424 | :initarg :y-root |
425 | :type short)) |
426 | (:metaclass event-class)) |
427 | |
428 | (defclass drag-enter-event (dnd-event) |
5d462688 |
429 | () |
430 | (:metaclass event-class) |
57e4839d |
431 | (:event-type :drag-enter)) |
5d462688 |
432 | |
c07660b3 |
433 | (defclass drag-leave-event (dnd-event) |
5d462688 |
434 | () |
435 | (:metaclass event-class) |
57e4839d |
436 | (:event-type :drag-leave)) |
5d462688 |
437 | |
c07660b3 |
438 | (defclass drag-motion-event (dnd-event) |
5d462688 |
439 | () |
440 | (:metaclass event-class) |
57e4839d |
441 | (:event-type :drag-motion)) |
5d462688 |
442 | |
c07660b3 |
443 | (defclass drag-status-event (dnd-event) |
5d462688 |
444 | () |
445 | (:metaclass event-class) |
57e4839d |
446 | (:event-type :drag-status)) |
5d462688 |
447 | |
c07660b3 |
448 | (defclass drot-start-event (dnd-event) |
5d462688 |
449 | () |
450 | (:metaclass event-class) |
57e4839d |
451 | (:event-type :drop-start)) |
5d462688 |
452 | |
c07660b3 |
453 | (defclass drop-finished-event (dnd-event) |
5d462688 |
454 | () |
455 | (:metaclass event-class) |
57e4839d |
456 | (:event-type :drop-finished)) |
5d462688 |
457 | |
458 | (defclass client-event (event) |
459 | () |
460 | (:metaclass event-class) |
57e4839d |
461 | (:event-type :client-event)) |
5d462688 |
462 | |
463 | (defclass visibility-notify-event (event) |
464 | ((state |
465 | :allocation :alien |
466 | :accessor event-state |
467 | :initarg :state |
468 | :type visibility-state)) |
469 | (:metaclass event-class) |
57e4839d |
470 | (:event-type :visibility-notify)) |
5d462688 |
471 | |
472 | (defclass no-expose-event (event) |
473 | () |
474 | (:metaclass event-class) |
57e4839d |
475 | (:event-type :no-expose)) |
5d462688 |
476 | |
477 | (defclass scroll-event (timed-event) |
c07660b3 |
478 | ((x |
479 | :allocation :alien |
480 | :accessor event-x |
481 | :initarg :x |
482 | :type double-float) |
483 | (y |
484 | :allocation :alien |
485 | :accessor event-y |
486 | :initarg :y |
487 | :type double-float) |
488 | (state |
489 | :allocation :alien |
490 | :accessor event-state |
491 | :initarg :state |
492 | :type modifier-type) |
493 | (direction |
494 | :allocation :alien |
495 | :accessor event-direction |
496 | :initarg :direction |
497 | :type scroll-direction) |
498 | (root-x |
499 | :allocation :alien |
500 | :accessor event-root-x |
501 | :initarg :root-x |
502 | :type double-float) |
503 | (root-y |
504 | :allocation :alien |
505 | :accessor event-root-y |
506 | :initarg :root-y |
507 | :type double-float)) |
5d462688 |
508 | (:metaclass event-class) |
57e4839d |
509 | (:event-type :scroll)) |
5d462688 |
510 | |
c07660b3 |
511 | (defclass setting-event (event) |
512 | ((action |
513 | :allocation :alien |
514 | :accessor event-action |
515 | :initarg :action |
516 | :type setting-action) |
517 | (name |
518 | :allocation :alien |
519 | :accessor event-name |
520 | :initarg :name |
521 | :type string)) |
5d462688 |
522 | (:metaclass event-class) |
57e4839d |
523 | (:event-type :setting)) |
c07660b3 |
524 | |
525 | (defclass proximity-event (timed-event) |
526 | ((device |
527 | :allocation :alien |
528 | :accessor event-device |
529 | :initarg :device |
530 | :type device)) |
531 | (:metaclass event-class)) |
532 | |
533 | (defclass proximity-in-event (proximity-event) |
534 | () |
535 | (:metaclass event-class) |
57e4839d |
536 | (:event-type :proximity-in)) |
c07660b3 |
537 | |
538 | (defclass proximity-out-event (proximity-event) |
539 | () |
540 | (:metaclass event-class) |
57e4839d |
541 | (:event-type :proximity-out)) |
c07660b3 |
542 | |
543 | (defclass window-state-event (event) |
544 | ((change-mask |
545 | :allocation :alien |
546 | :accessor event-change-mask |
547 | :initarg :change-mask |
548 | :type window-state) |
549 | (new-window-state |
550 | :allocation :alien |
551 | :accessor event-new-window-state |
552 | :initarg :new-window-state |
553 | :type window-state)) |
554 | (:metaclass event-class) |
57e4839d |
555 | (:event-type :window-state)) |
c07660b3 |
556 | |
557 | (defclass owner-change-event (event) |
558 | () |
559 | (:metaclass event-class) |
57e4839d |
560 | (:event-type :owner-change)) |
c07660b3 |
561 | |