2bbdcee0703eb90e824e0f7cfcf8c7ef3c37c7bb
1 #define __SP_EVENT_CONTEXT_C__
3 /** \file
4 * Main event handling, and related helper functions.
5 *
6 * Authors:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * Frank Felfe <innerspace@iname.com>
9 * bulia byak <buliabyak@users.sf.net>
10 *
11 * Copyright (C) 1999-2005 authors
12 * Copyright (C) 2001-2002 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 /** \class SPEventContext
18 * SPEventContext is an abstract base class of all tools. As the name
19 * indicates, event context implementations process UI events (mouse
20 * movements and keypresses) and take actions (like creating or modifying
21 * objects). There is one event context implementation for each tool,
22 * plus few abstract base classes. Writing a new tool involves
23 * subclassing SPEventContext.
24 */
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
30 #include "event-context.h"
32 #include <string.h>
33 #include <gdk/gdkkeysyms.h>
34 #include <gtk/gtkmain.h>
35 #include <gtk/gtkmenu.h>
36 #include <glibmm/i18n.h>
37 #include <cstring>
38 #include <string>
40 #include "display/sp-canvas.h"
41 #include "xml/node-event-vector.h"
42 #include "sp-cursor.h"
43 #include "shortcuts.h"
44 #include "desktop.h"
45 #include "desktop-handles.h"
46 #include "sp-namedview.h"
47 #include "selection.h"
48 #include "file.h"
49 #include "interface.h"
50 #include "macros.h"
51 #include "tools-switch.h"
52 #include "preferences.h"
53 #include "message-context.h"
54 #include "gradient-drag.h"
55 #include "object-edit.h"
56 #include "attributes.h"
57 #include "rubberband.h"
58 #include "selcue.h"
59 #include "node-context.h"
60 #include "lpe-tool-context.h"
62 static void sp_event_context_class_init(SPEventContextClass *klass);
63 static void sp_event_context_init(SPEventContext *event_context);
64 static void sp_event_context_dispose(GObject *object);
66 static void sp_event_context_private_setup(SPEventContext *ec);
67 static gint sp_event_context_private_root_handler(SPEventContext *event_context, GdkEvent *event);
68 static gint sp_event_context_private_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
70 static void set_event_location(SPDesktop * desktop, GdkEvent * event);
72 static GObjectClass *parent_class;
74 // globals for temporary switching to selector by space
75 static bool selector_toggled = FALSE;
76 static int switch_selector_to = 0;
78 // globals for temporary switching to dropper by 'D'
79 static bool dropper_toggled = FALSE;
80 static int switch_dropper_to = 0;
82 static gint xp = 0, yp = 0; // where drag started
83 static gint tolerance = 0;
84 static bool within_tolerance = false;
86 // globals for keeping track of keyboard scroll events in order to accelerate
87 static guint32 scroll_event_time = 0;
88 static gdouble scroll_multiply = 1;
89 static guint scroll_keyval = 0;
91 /**
92 * Registers the SPEventContext class with Glib and returns its type number.
93 */
94 GType
95 sp_event_context_get_type(void)
96 {
97 static GType type = 0;
98 if (!type) {
99 GTypeInfo info = {
100 sizeof(SPEventContextClass),
101 NULL, NULL,
102 (GClassInitFunc) sp_event_context_class_init,
103 NULL, NULL,
104 sizeof(SPEventContext),
105 4,
106 (GInstanceInitFunc) sp_event_context_init,
107 NULL, /* value_table */
108 };
109 type = g_type_register_static(G_TYPE_OBJECT, "SPEventContext", &info, (GTypeFlags)0);
110 }
111 return type;
112 }
114 /**
115 * Callback to set up the SPEventContext vtable.
116 */
117 static void
118 sp_event_context_class_init(SPEventContextClass *klass)
119 {
120 GObjectClass *object_class;
122 object_class = (GObjectClass *) klass;
124 parent_class = (GObjectClass*)g_type_class_peek_parent(klass);
126 object_class->dispose = sp_event_context_dispose;
128 klass->setup = sp_event_context_private_setup;
129 klass->root_handler = sp_event_context_private_root_handler;
130 klass->item_handler = sp_event_context_private_item_handler;
131 }
133 /**
134 * Clears all SPEventContext object members.
135 */
136 static void
137 sp_event_context_init(SPEventContext *event_context)
138 {
139 event_context->desktop = NULL;
140 event_context->cursor = NULL;
141 event_context->_message_context = NULL;
142 event_context->_selcue = NULL;
143 event_context->_grdrag = NULL;
144 event_context->space_panning = false;
145 event_context->shape_editor = NULL;
146 event_context->_delayed_snap_event = NULL;
147 }
149 /**
150 * Callback to free and null member variables of SPEventContext object.
151 */
152 static void
153 sp_event_context_dispose(GObject *object)
154 {
155 SPEventContext *ec;
157 ec = SP_EVENT_CONTEXT(object);
159 if (ec->_message_context) {
160 delete ec->_message_context;
161 }
163 if (ec->cursor != NULL) {
164 gdk_cursor_unref(ec->cursor);
165 ec->cursor = NULL;
166 }
168 if (ec->desktop) {
169 ec->desktop = NULL;
170 }
172 if (ec->pref_observer) {
173 delete ec->pref_observer;
174 }
176 if (ec->_delayed_snap_event) {
177 delete ec->_delayed_snap_event;
178 }
180 G_OBJECT_CLASS(parent_class)->dispose(object);
181 }
183 /**
184 * Recreates and draws cursor on desktop related to SPEventContext.
185 */
186 void
187 sp_event_context_update_cursor(SPEventContext *ec)
188 {
189 GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(ec->desktop));
190 if (w->window) {
191 /* fixme: */
192 if (ec->cursor_shape) {
193 GdkBitmap *bitmap = NULL;
194 GdkBitmap *mask = NULL;
195 sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape);
196 if ((bitmap != NULL) && (mask != NULL)) {
197 if (ec->cursor)
198 gdk_cursor_unref (ec->cursor);
199 ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask,
200 &w->style->black,
201 &w->style->white,
202 ec->hot_x, ec->hot_y);
203 g_object_unref (bitmap);
204 g_object_unref (mask);
205 }
206 }
207 gdk_window_set_cursor(w->window, ec->cursor);
208 gdk_flush();
209 }
210 ec->desktop->waiting_cursor = false;
211 }
213 /**
214 * Callback that gets called on initialization of SPEventContext object.
215 * Redraws mouse cursor, at the moment.
216 */
217 static void
218 sp_event_context_private_setup(SPEventContext *ec)
219 {
220 sp_event_context_update_cursor(ec);
221 }
223 /**
224 * \brief Gobbles next key events on the queue with the same keyval and mask. Returns the number of events consumed.
225 */
226 gint gobble_key_events(guint keyval, gint mask)
227 {
228 GdkEvent *event_next;
229 gint i = 0;
231 event_next = gdk_event_get();
232 // while the next event is also a key notify with the same keyval and mask,
233 while (event_next && (event_next->type == GDK_KEY_PRESS || event_next->type == GDK_KEY_RELEASE)
234 && event_next->key.keyval == keyval
235 && (!mask || (event_next->key.state & mask))) {
236 if (event_next->type == GDK_KEY_PRESS)
237 i ++;
238 // kill it
239 gdk_event_free(event_next);
240 // get next
241 event_next = gdk_event_get();
242 }
243 // otherwise, put it back onto the queue
244 if (event_next) gdk_event_put(event_next);
246 return i;
247 }
249 /**
250 * \brief Gobbles next motion notify events on the queue with the same mask. Returns the number of events consumed.
251 */
252 gint gobble_motion_events(gint mask)
253 {
254 GdkEvent *event_next;
255 gint i = 0;
257 event_next = gdk_event_get();
258 // while the next event is also a key notify with the same keyval and mask,
259 while (event_next && event_next->type == GDK_MOTION_NOTIFY
260 && (event_next->motion.state & mask)) {
261 // kill it
262 gdk_event_free(event_next);
263 // get next
264 event_next = gdk_event_get();
265 i ++;
266 }
267 // otherwise, put it back onto the queue
268 if (event_next) gdk_event_put(event_next);
270 return i;
271 }
273 /**
274 * Toggles current tool between active tool and selector tool.
275 * Subroutine of sp_event_context_private_root_handler().
276 */
277 static void
278 sp_toggle_selector(SPDesktop *dt)
279 {
280 if (!dt->event_context) return;
282 if (tools_isactive(dt, TOOLS_SELECT)) {
283 if (selector_toggled) {
284 if (switch_selector_to) tools_switch (dt, switch_selector_to);
285 selector_toggled = FALSE;
286 } else return;
287 } else {
288 selector_toggled = TRUE;
289 switch_selector_to = tools_active(dt);
290 tools_switch (dt, TOOLS_SELECT);
291 }
292 }
294 /**
295 * Toggles current tool between active tool and dropper tool.
296 * Subroutine of sp_event_context_private_root_handler().
297 */
298 static void
299 sp_toggle_dropper(SPDesktop *dt)
300 {
301 if (!dt->event_context) return;
303 if (tools_isactive(dt, TOOLS_DROPPER)) {
304 if (dropper_toggled) {
305 if (switch_dropper_to) tools_switch (dt, switch_dropper_to);
306 dropper_toggled = FALSE;
307 } else return;
308 } else {
309 dropper_toggled = TRUE;
310 switch_dropper_to = tools_active(dt);
311 tools_switch (dt, TOOLS_DROPPER);
312 }
313 }
315 /**
316 * Calculates and keeps track of scroll acceleration.
317 * Subroutine of sp_event_context_private_root_handler().
318 */
319 static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, SPCanvas */*canvas*/)
320 {
321 guint32 time_diff = ((GdkEventKey *) event)->time - scroll_event_time;
323 /* key pressed within 500ms ? (1/2 second) */
324 if (time_diff > 500 || event->key.keyval != scroll_keyval) {
325 scroll_multiply = 1; // abort acceleration
326 } else {
327 scroll_multiply += acceleration; // continue acceleration
328 }
330 scroll_event_time = ((GdkEventKey *) event)->time;
331 scroll_keyval = event->key.keyval;
333 return scroll_multiply;
334 }
336 /**
337 * Main event dispatch, gets called from Gdk.
338 */
339 static gint sp_event_context_private_root_handler(SPEventContext *event_context, GdkEvent *event)
340 {
341 static Geom::Point button_w;
342 static unsigned int panning = 0;
343 static unsigned int zoom_rb = 0;
345 SPDesktop *desktop = event_context->desktop;
346 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
348 /// @todo REmove redundant /value in preference keys
349 tolerance = prefs->getIntLimited(
350 "/options/dragtolerance/value", 0, 0, 100);
351 double const zoom_inc = prefs->getDoubleLimited(
352 "/options/zoomincrement/value", M_SQRT2, 1.01, 10);
353 double const acceleration = prefs->getDoubleLimited(
354 "/options/scrollingacceleration/value", 0, 0, 6);
355 int const key_scroll = prefs->getIntLimited(
356 "/options/keyscroll/value", 10, 0, 1000);
357 int const wheel_scroll = prefs->getIntLimited(
358 "/options/wheelscroll/value", 40, 0, 1000);
360 gint ret = FALSE;
362 switch (event->type) {
363 case GDK_2BUTTON_PRESS:
364 if (panning) {
365 panning = 0;
366 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
367 event->button.time);
368 ret = TRUE;
369 } else {
370 /* sp_desktop_dialog(); */
371 }
372 break;
373 case GDK_BUTTON_PRESS:
375 // save drag origin
376 xp = (gint) event->button.x;
377 yp = (gint) event->button.y;
378 within_tolerance = true;
380 button_w = Geom::Point(event->button.x, event->button.y);
382 switch (event->button.button) {
383 case 1:
384 if (event_context->space_panning) {
385 panning = 1;
386 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
387 GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
388 NULL, event->button.time-1);
389 ret = TRUE;
390 }
391 break;
392 case 2:
393 if (event->button.state == GDK_SHIFT_MASK) {
394 zoom_rb = 2;
395 } else {
396 panning = 2;
397 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
398 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
399 NULL, event->button.time-1);
400 }
401 ret = TRUE;
402 break;
403 case 3:
404 if (event->button.state & GDK_SHIFT_MASK
405 || event->button.state & GDK_CONTROL_MASK) {
406 panning = 3;
407 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
408 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
409 NULL, event->button.time);
410 ret = TRUE;
411 } else {
412 sp_event_root_menu_popup(desktop, NULL, event);
413 }
414 break;
415 default:
416 break;
417 }
418 break;
419 case GDK_MOTION_NOTIFY:
420 if (panning) {
421 if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK))
422 || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK))
423 || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))
424 ) {
425 /* Gdk seems to lose button release for us sometimes :-( */
426 panning = 0;
427 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
428 event->button.time);
429 ret = TRUE;
430 } else {
431 if ( within_tolerance
432 && ( abs( (gint) event->motion.x - xp ) < tolerance )
433 && ( abs( (gint) event->motion.y - yp ) < tolerance ))
434 {
435 // do not drag if we're within tolerance from origin
436 break;
437 }
438 // Once the user has moved farther than tolerance from
439 // the original location (indicating they intend to move
440 // the object, not click), then always process the motion
441 // notify coordinates as given (no snapping back to origin)
442 within_tolerance = false;
444 // gobble subsequent motion events to prevent "sticking"
445 // when scrolling is slow
446 gobble_motion_events(panning == 2 ?
447 GDK_BUTTON2_MASK :
448 (panning == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));
450 Geom::Point const motion_w(event->motion.x, event->motion.y);
451 Geom::Point const moved_w( motion_w - button_w );
452 event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
453 ret = TRUE;
454 }
455 } else if (zoom_rb) {
456 Geom::Point const motion_w(event->motion.x, event->motion.y);
457 Geom::Point const motion_dt(desktop->w2d(motion_w));
459 if ( within_tolerance
460 && ( abs( (gint) event->motion.x - xp ) < tolerance )
461 && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) {
462 break; // do not drag if we're within tolerance from origin
463 }
464 // Once the user has moved farther than tolerance from the original location
465 // (indicating they intend to move the object, not click), then always process the
466 // motion notify coordinates as given (no snapping back to origin)
467 within_tolerance = false;
469 if (Inkscape::Rubberband::get(desktop)->is_started()) {
470 Inkscape::Rubberband::get(desktop)->move(motion_dt);
471 } else {
472 Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt);
473 }
474 if (zoom_rb == 2)
475 gobble_motion_events(GDK_BUTTON2_MASK);
476 }
477 break;
478 case GDK_BUTTON_RELEASE:
479 xp = yp = 0;
480 if (within_tolerance && (panning || zoom_rb)) {
481 zoom_rb = 0;
482 if (panning) {
483 panning = 0;
484 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
485 event->button.time);
486 }
487 Geom::Point const event_w(event->button.x, event->button.y);
488 Geom::Point const event_dt(desktop->w2d(event_w));
489 desktop->zoom_relative_keep_point(event_dt,
490 (event->button.state & GDK_SHIFT_MASK) ? 1/zoom_inc : zoom_inc);
491 desktop->updateNow();
492 ret = TRUE;
493 } else if (panning == event->button.button) {
494 panning = 0;
495 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
496 event->button.time);
498 // in slow complex drawings, some of the motion events are lost;
499 // to make up for this, we scroll it once again to the button-up event coordinates
500 // (i.e. canvas will always get scrolled all the way to the mouse release point,
501 // even if few intermediate steps were visible)
502 Geom::Point const motion_w(event->button.x, event->button.y);
503 Geom::Point const moved_w( motion_w - button_w );
504 event_context->desktop->scroll_world(moved_w);
505 desktop->updateNow();
506 ret = TRUE;
507 } else if (zoom_rb == event->button.button) {
508 zoom_rb = 0;
509 Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle();
510 Inkscape::Rubberband::get(desktop)->stop();
511 if (b && !within_tolerance) {
512 desktop->set_display_area(*b, 10);
513 }
514 ret = TRUE;
515 }
516 break;
517 case GDK_KEY_PRESS:
518 switch (get_group0_keyval(&event->key)) {
519 // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
520 // in the editing window). So we resteal them back and run our regular shortcut
521 // invoker on them.
522 unsigned int shortcut;
523 case GDK_Tab:
524 case GDK_ISO_Left_Tab:
525 case GDK_F1:
526 shortcut = get_group0_keyval(&event->key);
527 if (event->key.state & GDK_SHIFT_MASK)
528 shortcut |= SP_SHORTCUT_SHIFT_MASK;
529 if (event->key.state & GDK_CONTROL_MASK)
530 shortcut |= SP_SHORTCUT_CONTROL_MASK;
531 if (event->key.state & GDK_MOD1_MASK)
532 shortcut |= SP_SHORTCUT_ALT_MASK;
533 ret = sp_shortcut_invoke(shortcut, desktop);
534 break;
536 case GDK_D:
537 case GDK_d:
538 if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
539 sp_toggle_dropper(desktop);
540 ret = TRUE;
541 }
542 break;
543 case GDK_Q:
544 case GDK_q:
545 if (desktop->quick_zoomed()) {
546 ret = TRUE;
547 }
548 if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
549 desktop->zoom_quick(true);
550 ret = TRUE;
551 }
552 break;
553 case GDK_W:
554 case GDK_w:
555 case GDK_F4:
556 /* Close view */
557 if (MOD__CTRL_ONLY) {
558 sp_ui_close_view(NULL);
559 ret = TRUE;
560 }
561 break;
562 case GDK_Left: // Ctrl Left
563 case GDK_KP_Left:
564 case GDK_KP_4:
565 if (MOD__CTRL_ONLY) {
566 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
567 gobble_key_events(get_group0_keyval(&event->key),
568 GDK_CONTROL_MASK);
569 event_context->desktop->scroll_world(i, 0);
570 ret = TRUE;
571 }
572 break;
573 case GDK_Up: // Ctrl Up
574 case GDK_KP_Up:
575 case GDK_KP_8:
576 if (MOD__CTRL_ONLY) {
577 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
578 gobble_key_events(get_group0_keyval(&event->key),
579 GDK_CONTROL_MASK);
580 event_context->desktop->scroll_world(0, i);
581 ret = TRUE;
582 }
583 break;
584 case GDK_Right: // Ctrl Right
585 case GDK_KP_Right:
586 case GDK_KP_6:
587 if (MOD__CTRL_ONLY) {
588 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
589 gobble_key_events(get_group0_keyval(&event->key),
590 GDK_CONTROL_MASK);
591 event_context->desktop->scroll_world(-i, 0);
592 ret = TRUE;
593 }
594 break;
595 case GDK_Down: // Ctrl Down
596 case GDK_KP_Down:
597 case GDK_KP_2:
598 if (MOD__CTRL_ONLY) {
599 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
600 gobble_key_events(get_group0_keyval(&event->key),
601 GDK_CONTROL_MASK);
602 event_context->desktop->scroll_world(0, -i);
603 ret = TRUE;
604 }
605 break;
606 case GDK_F10:
607 if (MOD__SHIFT_ONLY) {
608 sp_event_root_menu_popup(desktop, NULL, event);
609 ret= TRUE;
610 }
611 break;
612 case GDK_space:
613 if (prefs->getBool("/options/spacepans/value")) {
614 event_context->space_panning = true;
615 event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, _("<b>Space+mouse drag</b> to pan canvas"));
616 ret= TRUE;
617 } else {
618 sp_toggle_selector(desktop);
619 ret= TRUE;
620 }
621 break;
622 case GDK_z:
623 case GDK_Z:
624 if (MOD__ALT_ONLY) {
625 desktop->zoom_grab_focus();
626 ret = TRUE;
627 }
628 break;
629 default:
630 break;
631 }
632 break;
633 case GDK_KEY_RELEASE:
634 switch (get_group0_keyval(&event->key)) {
635 case GDK_space:
636 if (event_context->space_panning) {
637 event_context->space_panning = false;
638 event_context->_message_context->clear();
639 if (panning == 1) {
640 panning = 0;
641 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
642 event->key.time);
643 desktop->updateNow();
644 }
645 ret= TRUE;
646 }
647 break;
648 case GDK_Q:
649 case GDK_q:
650 if (desktop->quick_zoomed()) {
651 desktop->zoom_quick(false);
652 ret = TRUE;
653 }
654 break;
655 default:
656 break;
657 }
658 break;
659 case GDK_SCROLL:
660 {
661 bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
662 bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
663 /* shift + wheel, pan left--right */
664 if (event->scroll.state & GDK_SHIFT_MASK) {
665 switch (event->scroll.direction) {
666 case GDK_SCROLL_UP:
667 desktop->scroll_world(wheel_scroll, 0);
668 break;
669 case GDK_SCROLL_DOWN:
670 desktop->scroll_world(-wheel_scroll, 0);
671 break;
672 default:
673 break;
674 }
676 /* ctrl + wheel, zoom in--out */
677 } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) {
678 double rel_zoom;
679 switch (event->scroll.direction) {
680 case GDK_SCROLL_UP:
681 rel_zoom = zoom_inc;
682 break;
683 case GDK_SCROLL_DOWN:
684 rel_zoom = 1 / zoom_inc;
685 break;
686 default:
687 rel_zoom = 0.0;
688 break;
689 }
690 if (rel_zoom != 0.0) {
691 Geom::Point const scroll_dt = desktop->point();
692 desktop->zoom_relative_keep_point(scroll_dt, rel_zoom);
693 }
695 /* no modifier, pan up--down (left--right on multiwheel mice?) */
696 } else {
697 switch (event->scroll.direction) {
698 case GDK_SCROLL_UP:
699 desktop->scroll_world(0, wheel_scroll);
700 break;
701 case GDK_SCROLL_DOWN:
702 desktop->scroll_world(0, -wheel_scroll);
703 break;
704 case GDK_SCROLL_LEFT:
705 desktop->scroll_world(wheel_scroll, 0);
706 break;
707 case GDK_SCROLL_RIGHT:
708 desktop->scroll_world(-wheel_scroll, 0);
709 break;
710 }
711 }
712 break;
713 }
714 default:
715 break;
716 }
718 return ret;
719 }
721 /**
722 * Handles item specific events. Gets called from Gdk.
723 *
724 * Only reacts to right mouse button at the moment.
725 * \todo Fixme: do context sensitive popup menu on items.
726 */
727 gint
728 sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
729 {
730 int ret = FALSE;
732 switch (event->type) {
733 case GDK_BUTTON_PRESS:
734 if ((event->button.button == 3)
735 && !(event->button.state & GDK_SHIFT_MASK || event->button.state & GDK_CONTROL_MASK)) {
736 sp_event_root_menu_popup(ec->desktop, item, event);
737 ret = TRUE;
738 }
739 break;
740 default:
741 break;
742 }
744 return ret;
745 }
747 /**
748 * @brief An observer that relays pref changes to the derived classes
749 */
750 class ToolPrefObserver : public Inkscape::Preferences::Observer {
751 public:
752 ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) :
753 Inkscape::Preferences::Observer(path),
754 _ec(ec) {}
755 virtual void notify(Inkscape::Preferences::Entry const &val)
756 {
757 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) {
758 ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec,
759 const_cast<Inkscape::Preferences::Entry*>(&val));
760 }
761 }
762 private:
763 SPEventContext * const _ec;
764 };
766 /**
767 * Creates new SPEventContext object and calls its virtual setup() function.
768 * @todo This is bogus. pref_path should be a private property of the inheriting objects.
769 */
770 SPEventContext *
771 sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned int key)
772 {
773 g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
774 g_return_val_if_fail(desktop != NULL, NULL);
776 SPEventContext *const ec = (SPEventContext*)g_object_new(type, NULL);
778 ec->desktop = desktop;
779 ec->_message_context = new Inkscape::MessageContext(desktop->messageStack());
780 ec->key = key;
781 ec->pref_observer = NULL;
783 if (pref_path) {
784 ec->pref_observer = new ToolPrefObserver(pref_path, ec);
786 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
787 prefs->addObserver(*(ec->pref_observer));
788 }
790 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup)
791 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup(ec);
793 return ec;
794 }
796 /**
797 * Finishes SPEventContext.
798 */
799 void
800 sp_event_context_finish(SPEventContext *ec)
801 {
802 g_return_if_fail(ec != NULL);
803 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
805 ec->enableSelectionCue(false);
807 if (ec->next) {
808 g_warning("Finishing event context with active link\n");
809 }
811 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish)
812 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish(ec);
813 }
815 //-------------------------------member functions
817 /**
818 * Enables/disables the SPEventContext's SelCue.
819 */
820 void SPEventContext::enableSelectionCue(bool enable) {
821 if (enable) {
822 if (!_selcue) {
823 _selcue = new Inkscape::SelCue(desktop);
824 }
825 } else {
826 delete _selcue;
827 _selcue = NULL;
828 }
829 }
831 /**
832 * Enables/disables the SPEventContext's GrDrag.
833 */
834 void SPEventContext::enableGrDrag(bool enable) {
835 if (enable) {
836 if (!_grdrag) {
837 _grdrag = new GrDrag(desktop);
838 }
839 } else {
840 if (_grdrag) {
841 delete _grdrag;
842 _grdrag = NULL;
843 }
844 }
845 }
847 /**
848 * Calls virtual set() function of SPEventContext.
849 */
850 void
851 sp_event_context_read(SPEventContext *ec, gchar const *key)
852 {
853 g_return_if_fail(ec != NULL);
854 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
855 g_return_if_fail(key != NULL);
857 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
858 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
859 Inkscape::Preferences::Entry val = prefs->getEntry(
860 ec->pref_observer->observed_path + '/' + key );
861 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val);
862 }
863 }
865 /**
866 * Calls virtual activate() function of SPEventContext.
867 */
868 void
869 sp_event_context_activate(SPEventContext *ec)
870 {
871 g_return_if_fail(ec != NULL);
872 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
874 // Make sure no delayed snapping events are carried over after switching contexts
875 // (this is only an additional safety measure against sloppy coding, because each
876 // context should take care of this by itself. It might be hard to get each and every
877 // context perfect though)
878 sp_event_context_snap_window_closed(ec, false);
880 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate)
881 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec);
882 }
884 /**
885 * Calls virtual deactivate() function of SPEventContext.
886 */
887 void
888 sp_event_context_deactivate(SPEventContext *ec)
889 {
890 g_return_if_fail(ec != NULL);
891 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
893 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate)
894 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate(ec);
895 }
897 /**
898 * Calls virtual root_handler(), the main event handling function.
899 */
900 gint
901 sp_event_context_root_handler(SPEventContext * event_context, GdkEvent * event)
902 {
903 //std::cout << "sp_event_context_root_handler" << std::endl;
904 switch (event->type) {
905 case GDK_MOTION_NOTIFY:
906 sp_event_context_snap_delay_handler(event_context, NULL, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
907 break;
908 case GDK_BUTTON_RELEASE:
909 if (event_context->_delayed_snap_event) {
910 // If we have any pending snapping action, then invoke it now
911 sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
912 }
913 break;
914 case GDK_BUTTON_PRESS:
915 case GDK_2BUTTON_PRESS:
916 case GDK_3BUTTON_PRESS:
917 // Snapping will be on hold if we're moving the mouse at high speeds. When starting
918 // drawing a new shape we really should snap though.
919 event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
920 break;
921 default:
922 break;
923 }
925 return sp_event_context_virtual_root_handler(event_context, event);
926 }
928 gint
929 sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event)
930 {
931 //std::cout << "sp_event_context_virtual_root_handler -> postponed: " << event_context->desktop->namedview->snap_manager.snapprefs.getSnapPostponedGlobally() << std::endl;
933 gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
934 set_event_location(event_context->desktop, event);
935 return ret;
936 }
938 /**
939 * Calls virtual item_handler(), the item event handling function.
940 */
941 gint
942 sp_event_context_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
943 {
944 //std::cout << "sp_event_context_item_handler" << std::endl;
945 switch (event->type) {
946 case GDK_MOTION_NOTIFY:
947 sp_event_context_snap_delay_handler(event_context, item, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
948 break;
949 case GDK_BUTTON_RELEASE:
950 if (event_context->_delayed_snap_event) {
951 // If we have any pending snapping action, then invoke it now
952 sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
953 }
954 break;
955 /*case GDK_BUTTON_PRESS:
956 case GDK_2BUTTON_PRESS:
957 case GDK_3BUTTON_PRESS:
958 // Snapping will be on hold if we're moving the mouse at high speeds. When starting
959 // drawing a new shape we really should snap though.
960 event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
961 break;
962 */
963 default:
964 break;
965 }
967 return sp_event_context_virtual_item_handler(event_context, item, event);
968 }
970 gint
971 sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
972 {
973 gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
975 if (! ret) {
976 ret = sp_event_context_virtual_root_handler(event_context, event);
977 } else {
978 set_event_location(event_context->desktop, event);
979 }
981 return ret;
982 }
984 /**
985 * Emits 'position_set' signal on desktop and shows coordinates on status bar.
986 */
987 static void set_event_location(SPDesktop *desktop, GdkEvent *event)
988 {
989 if (event->type != GDK_MOTION_NOTIFY) {
990 return;
991 }
993 Geom::Point const button_w(event->button.x, event->button.y);
994 Geom::Point const button_dt(desktop->w2d(button_w));
995 desktop->setPosition(button_dt);
996 desktop->set_coordinate_status(button_dt);
997 }
999 //-------------------------------------------------------------------
1000 /**
1001 * Create popup menu and tell Gtk to show it.
1002 */
1003 void
1004 sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
1005 {
1006 GtkWidget *menu;
1008 /* fixme: This is not what I want but works for now (Lauris) */
1009 if (event->type == GDK_KEY_PRESS) {
1010 item = sp_desktop_selection(desktop)->singleItem();
1011 }
1012 menu = sp_ui_context_menu(desktop, item);
1013 gtk_widget_show(menu);
1015 switch (event->type) {
1016 case GDK_BUTTON_PRESS:
1017 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, event->button.button, event->button.time);
1018 break;
1019 case GDK_KEY_PRESS:
1020 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time);
1021 break;
1022 default:
1023 break;
1024 }
1025 }
1027 /**
1028 * Show tool context specific modifier tip.
1029 */
1030 void
1031 sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
1032 GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip,
1033 gchar const *alt_tip)
1034 {
1035 guint keyval = get_group0_keyval(&event->key);
1037 bool ctrl = ctrl_tip && (MOD__CTRL
1038 || (keyval == GDK_Control_L)
1039 || (keyval == GDK_Control_R));
1040 bool shift = shift_tip
1041 && (MOD__SHIFT || (keyval == GDK_Shift_L) || (keyval == GDK_Shift_R));
1042 bool alt = alt_tip
1043 && (MOD__ALT
1044 || (keyval == GDK_Alt_L)
1045 || (keyval == GDK_Alt_R)
1046 || (keyval == GDK_Meta_L)
1047 || (keyval == GDK_Meta_R));
1049 gchar *tip = g_strdup_printf("%s%s%s%s%s",
1050 ( ctrl ? ctrl_tip : "" ),
1051 ( ctrl && (shift || alt) ? "; " : "" ),
1052 ( shift ? shift_tip : "" ),
1053 ( (ctrl || shift) && alt ? "; " : "" ),
1054 ( alt ? alt_tip : "" ));
1056 if (strlen(tip) > 0) {
1057 message_context->flash(Inkscape::INFORMATION_MESSAGE, tip);
1058 }
1060 g_free(tip);
1061 }
1063 /**
1064 * Return the keyval corresponding to the key event in group 0, i.e.,
1065 * in the main (English) layout.
1066 *
1067 * Use this instead of simply event->keyval, so that your keyboard shortcuts
1068 * work regardless of layouts (e.g., in Cyrillic).
1069 */
1070 guint
1071 get_group0_keyval(GdkEventKey *event)
1072 {
1073 guint keyval = 0;
1074 gdk_keymap_translate_keyboard_state(
1075 gdk_keymap_get_for_display(gdk_display_get_default()),
1076 event->hardware_keycode,
1077 (GdkModifierType) event->state,
1078 0 /*event->key.group*/,
1079 &keyval, NULL, NULL, NULL);
1080 return keyval;
1081 }
1083 /**
1084 * Returns item at point p in desktop.
1085 *
1086 * If state includes alt key mask, cyclically selects under; honors
1087 * into_groups.
1088 */
1089 SPItem *
1090 sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p,
1091 bool select_under, bool into_groups)
1092 {
1093 SPItem *item;
1095 if (select_under) {
1096 SPItem *selected_at_point =
1097 desktop->item_from_list_at_point_bottom (desktop->selection->itemList(), p);
1098 item = desktop->item_at_point(p, into_groups, selected_at_point);
1099 if (item == NULL) { // we may have reached bottom, flip over to the top
1100 item = desktop->item_at_point(p, into_groups, NULL);
1101 }
1102 } else
1103 item = desktop->item_at_point(p, into_groups, NULL);
1105 return item;
1106 }
1108 /**
1109 * Returns item if it is under point p in desktop, at any depth; otherwise returns NULL.
1110 *
1111 * Honors into_groups.
1112 */
1113 SPItem *
1114 sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p)
1115 {
1116 GSList *temp = NULL;
1117 temp = g_slist_prepend (temp, item);
1118 SPItem *item_at_point = desktop->item_from_list_at_point_bottom (temp, p);
1119 g_slist_free (temp);
1121 return item_at_point;
1122 }
1124 ShapeEditor *
1125 sp_event_context_get_shape_editor (SPEventContext *ec)
1126 {
1127 return ec->shape_editor;
1128 }
1130 void
1131 event_context_print_event_info(GdkEvent *event, bool print_return) {
1132 switch (event->type) {
1133 case GDK_BUTTON_PRESS:
1134 g_print ("GDK_BUTTON_PRESS");
1135 break;
1136 case GDK_2BUTTON_PRESS:
1137 g_print ("GDK_2BUTTON_PRESS");
1138 break;
1139 case GDK_3BUTTON_PRESS:
1140 g_print ("GDK_3BUTTON_PRESS");
1141 break;
1143 case GDK_MOTION_NOTIFY:
1144 g_print ("GDK_MOTION_NOTIFY");
1145 break;
1146 case GDK_ENTER_NOTIFY:
1147 g_print ("GDK_ENTER_NOTIFY");
1148 break;
1150 case GDK_LEAVE_NOTIFY:
1151 g_print ("GDK_LEAVE_NOTIFY");
1152 break;
1153 case GDK_BUTTON_RELEASE:
1154 g_print ("GDK_BUTTON_RELEASE");
1155 break;
1157 case GDK_KEY_PRESS:
1158 g_print ("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key));
1159 break;
1160 case GDK_KEY_RELEASE:
1161 g_print ("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key));
1162 break;
1163 default:
1164 //g_print ("even type not recognized");
1165 break;
1166 }
1168 if (print_return) {
1169 g_print ("\n");
1170 }
1171 }
1173 void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin)
1174 {
1175 static guint32 prev_time;
1176 static boost::optional<Geom::Point> prev_pos;
1178 // Snapping occurs when dragging with the left mouse button down, or when hovering e.g. in the pen tool with left mouse button up
1179 bool const c1 = event->state & GDK_BUTTON2_MASK; // We shouldn't hold back any events when other mouse buttons have been
1180 bool const c2 = event->state & GDK_BUTTON3_MASK; // pressed, e.g. when scrolling with the middle mouse button; if we do then
1181 // Inkscape will get stuck in an unresponsive state
1183 if (c1 || c2) {
1184 // Make sure that we don't send any pending snap events to a context if we know in advance
1185 // that we're not going to snap any way (e.g. while scrolling with middle mouse button)
1186 // Any motion event might affect the state of the context, leading to unexpected behavior
1187 delete ec->_delayed_snap_event;
1188 ec->_delayed_snap_event = NULL;
1189 }
1191 if (ec->_snap_window_open && !c1 && !c2 && ec->desktop && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
1192 // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occurred for some period.
1193 // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never
1194 // be fully at stand still and might keep spitting out motion events.
1195 ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold
1197 Geom::Point event_pos(event->x, event->y);
1198 guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
1200 if (prev_pos) {
1201 Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
1202 guint32 delta_t = event_t - prev_time;
1203 gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
1204 //std::cout << "Mouse speed = " << speed << " px/msec " << std::endl;
1205 if (speed > 0.02) { // Jitter threshold, might be needed for tablets
1206 // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We
1207 // will keep on postponing the snapping as long as the speed is high.
1208 // We must snap at some point in time though, so set a watchdog timer at some time from
1209 // now, just in case there's no future motion event that drops under the speed limit (when
1210 // stopping abruptly)
1211 delete ec->_delayed_snap_event;
1212 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin); // watchdog is reset, i.e. pushed forward in time
1213 // If the watchdog expires before a new motion event is received, we will snap (as explained
1214 // above). This means however that when the timer is too short, we will always snap and that the
1215 // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will
1216 // be immediate, as it used to be in the old days ;-).
1217 } else { // Speed is very low, so we're virtually at stand still
1218 // But if we're really standing still, then we should snap now. We could use some low-pass filtering,
1219 // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire,
1220 // snap, and set a new watchdog again.
1221 if (ec->_delayed_snap_event == NULL) { // no watchdog has been set
1222 // it might have already expired, so we'll set a new one; the snapping frequency will be limited by this
1223 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
1224 } // else: watchdog has been set before and we'll wait for it to expire
1225 }
1226 } else {
1227 // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
1228 g_assert(ec->_delayed_snap_event == NULL);
1229 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
1230 }
1232 prev_pos = event_pos;
1233 prev_time = event_t;
1234 }
1235 }
1237 gboolean sp_event_context_snap_watchdog_callback(gpointer data)
1238 {
1239 // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated
1240 DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*>(data);
1242 if (dse == NULL) {
1243 // This might occur when this method is called directly, i.e. not through the timer
1244 // E.g. on GDK_BUTTON_RELEASE in sp_event_context_root_handler()
1245 return FALSE;
1246 }
1248 SPEventContext *ec = dse->getEventContext();
1249 if (ec == NULL || ec->desktop == NULL) {
1250 return false;
1251 }
1253 SPDesktop *dt = ec->desktop;
1254 dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
1256 switch (dse->getOrigin()) {
1257 case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
1258 sp_event_context_virtual_root_handler(ec, dse->getEvent());
1259 break;
1260 case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER:
1261 {
1262 SPItem* item = NULL;
1263 item = dse->getItem();
1264 if (item && SP_IS_ITEM(item)) {
1265 sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
1266 }
1267 }
1268 break;
1269 case DelayedSnapEvent::KNOT_HANDLER:
1270 {
1271 SPKnot* knot = dse->getKnot();
1272 if (knot && SP_IS_KNOT(knot)) {
1273 sp_knot_handler_request_position(dse->getEvent(), knot);
1274 }
1275 }
1276 break;
1277 default:
1278 g_warning("Origin of snap-delay event has not been defined!;");
1279 break;
1280 }
1282 ec->_delayed_snap_event = NULL;
1283 delete dse;
1285 return FALSE; //Kills the timer and stops it from executing this callback over and over again.
1286 }
1288 void sp_event_context_snap_window_open(SPEventContext *ec, bool show_debug_warnings)
1289 {
1290 // Only when ec->_snap_window_open has been set, Inkscape will know that snapping is active
1291 // and will delay any snapping events (but only when asked to through the preferences)
1293 // When snapping is being delayed, then that will also mean that at some point the last event
1294 // might be re-triggered. This should only occur when Inkscape is still in the same tool or context,
1295 // and even more specifically, the tool should even be in the same state. If for example snapping is being delayed while
1296 // creating a rectangle, then the rect-context will be active and it will be in the "dragging" state
1297 // (see the static boolean variable "dragging" in the sp_rect_context_root_handler). The procedure is
1298 // as follows: call sp_event_context_snap_window_open(*, TRUE) when entering the "dragging" state, which will delay
1299 // snapping from that moment on, and call sp_event_context_snap_window_open(*, FALSE) when leaving the "dragging"
1300 // state. This last call will also make sure that any pending snap events will be canceled.
1302 //std::cout << "sp_event_context_snap_window_open" << std::endl;
1303 if (!ec) {
1304 if (show_debug_warnings) {
1305 g_warning("sp_event_context_snap_window_open() has been called without providing an event context!");
1306 }
1307 return;
1308 }
1310 if (ec->_snap_window_open == true && show_debug_warnings) {
1311 g_warning("Snap window was already open! This is a bug, please report it.");
1312 }
1314 ec->_snap_window_open = true;
1315 }
1317 void sp_event_context_snap_window_closed(SPEventContext *ec, bool show_debug_warnings)
1318 {
1319 //std::cout << "sp_event_context_snap_window_closed" << std::endl;
1320 if (!ec) {
1321 if (show_debug_warnings) {
1322 g_warning("sp_event_context_snap_window_closed() has been called without providing an event context!");
1323 }
1324 return;
1325 }
1327 if (ec->_snap_window_open == false && show_debug_warnings) {
1328 g_warning("Snap window was already closed! This is a bug, please report it.");
1329 }
1331 ec->_snap_window_open = false;
1333 delete ec->_delayed_snap_event;
1334 ec->_delayed_snap_event = NULL;
1335 }
1339 /*
1340 Local Variables:
1341 mode:c++
1342 c-file-style:"stroustrup"
1343 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1344 indent-tabs-mode:nil
1345 fill-column:99
1346 End:
1347 */
1348 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :