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);
352 gint ret = FALSE;
354 switch (event->type) {
355 case GDK_2BUTTON_PRESS:
356 if (panning) {
357 panning = 0;
358 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
359 event->button.time);
360 ret = TRUE;
361 } else {
362 /* sp_desktop_dialog(); */
363 }
364 break;
365 case GDK_BUTTON_PRESS:
367 // save drag origin
368 xp = (gint) event->button.x;
369 yp = (gint) event->button.y;
370 within_tolerance = true;
372 button_w = Geom::Point(event->button.x, event->button.y);
374 switch (event->button.button) {
375 case 1:
376 if (event_context->space_panning) {
377 panning = 1;
378 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
379 GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
380 NULL, event->button.time-1);
381 ret = TRUE;
382 }
383 break;
384 case 2:
385 if (event->button.state == GDK_SHIFT_MASK) {
386 zoom_rb = 2;
387 } else {
388 panning = 2;
389 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
390 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
391 NULL, event->button.time-1);
392 }
393 ret = TRUE;
394 break;
395 case 3:
396 if (event->button.state & GDK_SHIFT_MASK
397 || event->button.state & GDK_CONTROL_MASK) {
398 panning = 3;
399 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
400 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
401 NULL, event->button.time);
402 ret = TRUE;
403 } else {
404 sp_event_root_menu_popup(desktop, NULL, event);
405 }
406 break;
407 default:
408 break;
409 }
410 break;
411 case GDK_MOTION_NOTIFY:
412 if (panning) {
413 if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK))
414 || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK))
415 || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))
416 ) {
417 /* Gdk seems to lose button release for us sometimes :-( */
418 panning = 0;
419 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
420 event->button.time);
421 ret = TRUE;
422 } else {
423 if ( within_tolerance
424 && ( abs( (gint) event->motion.x - xp ) < tolerance )
425 && ( abs( (gint) event->motion.y - yp ) < tolerance ))
426 {
427 // do not drag if we're within tolerance from origin
428 break;
429 }
430 // Once the user has moved farther than tolerance from
431 // the original location (indicating they intend to move
432 // the object, not click), then always process the motion
433 // notify coordinates as given (no snapping back to origin)
434 within_tolerance = false;
436 // gobble subsequent motion events to prevent "sticking"
437 // when scrolling is slow
438 gobble_motion_events(panning == 2 ?
439 GDK_BUTTON2_MASK :
440 (panning == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK));
442 Geom::Point const motion_w(event->motion.x, event->motion.y);
443 Geom::Point const moved_w( motion_w - button_w );
444 event_context->desktop->scroll_world(moved_w, true); // we're still scrolling, do not redraw
445 ret = TRUE;
446 }
447 } else if (zoom_rb) {
448 Geom::Point const motion_w(event->motion.x, event->motion.y);
449 Geom::Point const motion_dt(desktop->w2d(motion_w));
451 if ( within_tolerance
452 && ( abs( (gint) event->motion.x - xp ) < tolerance )
453 && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) {
454 break; // do not drag if we're within tolerance from origin
455 }
456 // Once the user has moved farther than tolerance from the original location
457 // (indicating they intend to move the object, not click), then always process the
458 // motion notify coordinates as given (no snapping back to origin)
459 within_tolerance = false;
461 if (Inkscape::Rubberband::get(desktop)->is_started()) {
462 Inkscape::Rubberband::get(desktop)->move(motion_dt);
463 } else {
464 Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt);
465 }
466 if (zoom_rb == 2)
467 gobble_motion_events(GDK_BUTTON2_MASK);
468 }
469 break;
470 case GDK_BUTTON_RELEASE:
471 xp = yp = 0;
472 if (within_tolerance && (panning || zoom_rb)) {
473 zoom_rb = 0;
474 if (panning) {
475 panning = 0;
476 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
477 event->button.time);
478 }
479 Geom::Point const event_w(event->button.x, event->button.y);
480 Geom::Point const event_dt(desktop->w2d(event_w));
481 double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
482 desktop->zoom_relative_keep_point(event_dt,
483 (event->button.state & GDK_SHIFT_MASK) ? 1/zoom_inc : zoom_inc);
484 desktop->updateNow();
485 ret = TRUE;
486 } else if (panning == event->button.button) {
487 panning = 0;
488 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
489 event->button.time);
491 // in slow complex drawings, some of the motion events are lost;
492 // to make up for this, we scroll it once again to the button-up event coordinates
493 // (i.e. canvas will always get scrolled all the way to the mouse release point,
494 // even if few intermediate steps were visible)
495 Geom::Point const motion_w(event->button.x, event->button.y);
496 Geom::Point const moved_w( motion_w - button_w );
497 event_context->desktop->scroll_world(moved_w);
498 desktop->updateNow();
499 ret = TRUE;
500 } else if (zoom_rb == event->button.button) {
501 zoom_rb = 0;
502 Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle();
503 Inkscape::Rubberband::get(desktop)->stop();
504 if (b && !within_tolerance) {
505 desktop->set_display_area(*b, 10);
506 }
507 ret = TRUE;
508 }
509 break;
510 case GDK_KEY_PRESS:
511 {
512 double const acceleration = prefs->getDoubleLimited("/options/scrollingacceleration/value", 0, 0, 6);
513 int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000);
515 switch (get_group0_keyval(&event->key)) {
516 // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
517 // in the editing window). So we resteal them back and run our regular shortcut
518 // invoker on them.
519 unsigned int shortcut;
520 case GDK_Tab:
521 case GDK_ISO_Left_Tab:
522 case GDK_F1:
523 shortcut = get_group0_keyval(&event->key);
524 if (event->key.state & GDK_SHIFT_MASK)
525 shortcut |= SP_SHORTCUT_SHIFT_MASK;
526 if (event->key.state & GDK_CONTROL_MASK)
527 shortcut |= SP_SHORTCUT_CONTROL_MASK;
528 if (event->key.state & GDK_MOD1_MASK)
529 shortcut |= SP_SHORTCUT_ALT_MASK;
530 ret = sp_shortcut_invoke(shortcut, desktop);
531 break;
533 case GDK_D:
534 case GDK_d:
535 if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
536 sp_toggle_dropper(desktop);
537 ret = TRUE;
538 }
539 break;
540 case GDK_Q:
541 case GDK_q:
542 if (desktop->quick_zoomed()) {
543 ret = TRUE;
544 }
545 if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
546 desktop->zoom_quick(true);
547 ret = TRUE;
548 }
549 break;
550 case GDK_W:
551 case GDK_w:
552 case GDK_F4:
553 /* Close view */
554 if (MOD__CTRL_ONLY) {
555 sp_ui_close_view(NULL);
556 ret = TRUE;
557 }
558 break;
559 case GDK_Left: // Ctrl Left
560 case GDK_KP_Left:
561 case GDK_KP_4:
562 if (MOD__CTRL_ONLY) {
563 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
564 gobble_key_events(get_group0_keyval(&event->key),
565 GDK_CONTROL_MASK);
566 event_context->desktop->scroll_world(i, 0);
567 ret = TRUE;
568 }
569 break;
570 case GDK_Up: // Ctrl Up
571 case GDK_KP_Up:
572 case GDK_KP_8:
573 if (MOD__CTRL_ONLY) {
574 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
575 gobble_key_events(get_group0_keyval(&event->key),
576 GDK_CONTROL_MASK);
577 event_context->desktop->scroll_world(0, i);
578 ret = TRUE;
579 }
580 break;
581 case GDK_Right: // Ctrl Right
582 case GDK_KP_Right:
583 case GDK_KP_6:
584 if (MOD__CTRL_ONLY) {
585 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
586 gobble_key_events(get_group0_keyval(&event->key),
587 GDK_CONTROL_MASK);
588 event_context->desktop->scroll_world(-i, 0);
589 ret = TRUE;
590 }
591 break;
592 case GDK_Down: // Ctrl Down
593 case GDK_KP_Down:
594 case GDK_KP_2:
595 if (MOD__CTRL_ONLY) {
596 int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, sp_desktop_canvas(desktop)));
597 gobble_key_events(get_group0_keyval(&event->key),
598 GDK_CONTROL_MASK);
599 event_context->desktop->scroll_world(0, -i);
600 ret = TRUE;
601 }
602 break;
603 case GDK_F10:
604 if (MOD__SHIFT_ONLY) {
605 sp_event_root_menu_popup(desktop, NULL, event);
606 ret= TRUE;
607 }
608 break;
609 case GDK_space:
610 if (prefs->getBool("/options/spacepans/value")) {
611 event_context->space_panning = true;
612 event_context->_message_context->set(Inkscape::INFORMATION_MESSAGE, _("<b>Space+mouse drag</b> to pan canvas"));
613 ret= TRUE;
614 } else {
615 sp_toggle_selector(desktop);
616 ret= TRUE;
617 }
618 break;
619 case GDK_z:
620 case GDK_Z:
621 if (MOD__ALT_ONLY) {
622 desktop->zoom_grab_focus();
623 ret = TRUE;
624 }
625 break;
626 default:
627 break;
628 }
629 }
630 break;
631 case GDK_KEY_RELEASE:
632 switch (get_group0_keyval(&event->key)) {
633 case GDK_space:
634 if (event_context->space_panning) {
635 event_context->space_panning = false;
636 event_context->_message_context->clear();
637 if (panning == 1) {
638 panning = 0;
639 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
640 event->key.time);
641 desktop->updateNow();
642 }
643 ret= TRUE;
644 }
645 break;
646 case GDK_Q:
647 case GDK_q:
648 if (desktop->quick_zoomed()) {
649 desktop->zoom_quick(false);
650 ret = TRUE;
651 }
652 break;
653 default:
654 break;
655 }
656 break;
657 case GDK_SCROLL:
658 {
659 bool ctrl = (event->scroll.state & GDK_CONTROL_MASK);
660 bool wheelzooms = prefs->getBool("/options/wheelzooms/value");
661 int const wheel_scroll = prefs->getIntLimited("/options/wheelscroll/value", 40, 0, 1000);
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 double const zoom_inc = prefs->getDoubleLimited("/options/zoomincrement/value", M_SQRT2, 1.01, 10);
680 switch (event->scroll.direction) {
681 case GDK_SCROLL_UP:
682 rel_zoom = zoom_inc;
683 break;
684 case GDK_SCROLL_DOWN:
685 rel_zoom = 1 / zoom_inc;
686 break;
687 default:
688 rel_zoom = 0.0;
689 break;
690 }
691 if (rel_zoom != 0.0) {
692 Geom::Point const scroll_dt = desktop->point();
693 desktop->zoom_relative_keep_point(scroll_dt, rel_zoom);
694 }
696 /* no modifier, pan up--down (left--right on multiwheel mice?) */
697 } else {
698 switch (event->scroll.direction) {
699 case GDK_SCROLL_UP:
700 desktop->scroll_world(0, wheel_scroll);
701 break;
702 case GDK_SCROLL_DOWN:
703 desktop->scroll_world(0, -wheel_scroll);
704 break;
705 case GDK_SCROLL_LEFT:
706 desktop->scroll_world(wheel_scroll, 0);
707 break;
708 case GDK_SCROLL_RIGHT:
709 desktop->scroll_world(-wheel_scroll, 0);
710 break;
711 }
712 }
713 break;
714 }
715 default:
716 break;
717 }
719 return ret;
720 }
722 /**
723 * Handles item specific events. Gets called from Gdk.
724 *
725 * Only reacts to right mouse button at the moment.
726 * \todo Fixme: do context sensitive popup menu on items.
727 */
728 gint
729 sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
730 {
731 int ret = FALSE;
733 switch (event->type) {
734 case GDK_BUTTON_PRESS:
735 if ((event->button.button == 3)
736 && !(event->button.state & GDK_SHIFT_MASK || event->button.state & GDK_CONTROL_MASK)) {
737 sp_event_root_menu_popup(ec->desktop, item, event);
738 ret = TRUE;
739 }
740 break;
741 default:
742 break;
743 }
745 return ret;
746 }
748 /**
749 * @brief An observer that relays pref changes to the derived classes
750 */
751 class ToolPrefObserver : public Inkscape::Preferences::Observer {
752 public:
753 ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) :
754 Inkscape::Preferences::Observer(path),
755 _ec(ec) {}
756 virtual void notify(Inkscape::Preferences::Entry const &val)
757 {
758 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set) {
759 ((SPEventContextClass *) G_OBJECT_GET_CLASS(_ec))->set(_ec,
760 const_cast<Inkscape::Preferences::Entry*>(&val));
761 }
762 }
763 private:
764 SPEventContext * const _ec;
765 };
767 /**
768 * Creates new SPEventContext object and calls its virtual setup() function.
769 * @todo This is bogus. pref_path should be a private property of the inheriting objects.
770 */
771 SPEventContext *
772 sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned int key)
773 {
774 g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
775 g_return_val_if_fail(desktop != NULL, NULL);
777 SPEventContext *const ec = (SPEventContext*)g_object_new(type, NULL);
779 ec->desktop = desktop;
780 ec->_message_context = new Inkscape::MessageContext(desktop->messageStack());
781 ec->key = key;
782 ec->pref_observer = NULL;
784 if (pref_path) {
785 ec->pref_observer = new ToolPrefObserver(pref_path, ec);
787 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
788 prefs->addObserver(*(ec->pref_observer));
789 }
791 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup)
792 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->setup(ec);
794 return ec;
795 }
797 /**
798 * Finishes SPEventContext.
799 */
800 void
801 sp_event_context_finish(SPEventContext *ec)
802 {
803 g_return_if_fail(ec != NULL);
804 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
806 ec->enableSelectionCue(false);
808 if (ec->next) {
809 g_warning("Finishing event context with active link\n");
810 }
812 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish)
813 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->finish(ec);
814 }
816 //-------------------------------member functions
818 /**
819 * Enables/disables the SPEventContext's SelCue.
820 */
821 void SPEventContext::enableSelectionCue(bool enable) {
822 if (enable) {
823 if (!_selcue) {
824 _selcue = new Inkscape::SelCue(desktop);
825 }
826 } else {
827 delete _selcue;
828 _selcue = NULL;
829 }
830 }
832 /**
833 * Enables/disables the SPEventContext's GrDrag.
834 */
835 void SPEventContext::enableGrDrag(bool enable) {
836 if (enable) {
837 if (!_grdrag) {
838 _grdrag = new GrDrag(desktop);
839 }
840 } else {
841 if (_grdrag) {
842 delete _grdrag;
843 _grdrag = NULL;
844 }
845 }
846 }
848 /**
849 * Calls virtual set() function of SPEventContext.
850 */
851 void
852 sp_event_context_read(SPEventContext *ec, gchar const *key)
853 {
854 g_return_if_fail(ec != NULL);
855 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
856 g_return_if_fail(key != NULL);
858 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set) {
859 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
860 Inkscape::Preferences::Entry val = prefs->getEntry(
861 ec->pref_observer->observed_path + '/' + key );
862 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->set(ec, &val);
863 }
864 }
866 /**
867 * Calls virtual activate() function of SPEventContext.
868 */
869 void
870 sp_event_context_activate(SPEventContext *ec)
871 {
872 g_return_if_fail(ec != NULL);
873 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
875 // Make sure no delayed snapping events are carried over after switching contexts
876 // (this is only an additional safety measure against sloppy coding, because each
877 // context should take care of this by itself. It might be hard to get each and every
878 // context perfect though)
879 sp_event_context_snap_window_closed(ec, false);
881 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate)
882 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec);
883 }
885 /**
886 * Calls virtual deactivate() function of SPEventContext.
887 */
888 void
889 sp_event_context_deactivate(SPEventContext *ec)
890 {
891 g_return_if_fail(ec != NULL);
892 g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
894 if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate)
895 ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->deactivate(ec);
896 }
898 /**
899 * Calls virtual root_handler(), the main event handling function.
900 */
901 gint
902 sp_event_context_root_handler(SPEventContext * event_context, GdkEvent * event)
903 {
904 //std::cout << "sp_event_context_root_handler" << std::endl;
905 switch (event->type) {
906 case GDK_MOTION_NOTIFY:
907 sp_event_context_snap_delay_handler(event_context, NULL, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
908 break;
909 case GDK_BUTTON_RELEASE:
910 if (event_context->_delayed_snap_event) {
911 // If we have any pending snapping action, then invoke it now
912 sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
913 }
914 break;
915 case GDK_BUTTON_PRESS:
916 case GDK_2BUTTON_PRESS:
917 case GDK_3BUTTON_PRESS:
918 // Snapping will be on hold if we're moving the mouse at high speeds. When starting
919 // drawing a new shape we really should snap though.
920 event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
921 break;
922 default:
923 break;
924 }
926 return sp_event_context_virtual_root_handler(event_context, event);
927 }
929 gint
930 sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event)
931 {
932 //std::cout << "sp_event_context_virtual_root_handler -> postponed: " << event_context->desktop->namedview->snap_manager.snapprefs.getSnapPostponedGlobally() << std::endl;
934 gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
935 set_event_location(event_context->desktop, event);
936 return ret;
937 }
939 /**
940 * Calls virtual item_handler(), the item event handling function.
941 */
942 gint
943 sp_event_context_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
944 {
945 //std::cout << "sp_event_context_item_handler" << std::endl;
946 switch (event->type) {
947 case GDK_MOTION_NOTIFY:
948 sp_event_context_snap_delay_handler(event_context, item, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
949 break;
950 case GDK_BUTTON_RELEASE:
951 if (event_context->_delayed_snap_event) {
952 // If we have any pending snapping action, then invoke it now
953 sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
954 }
955 break;
956 /*case GDK_BUTTON_PRESS:
957 case GDK_2BUTTON_PRESS:
958 case GDK_3BUTTON_PRESS:
959 // Snapping will be on hold if we're moving the mouse at high speeds. When starting
960 // drawing a new shape we really should snap though.
961 event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
962 break;
963 */
964 default:
965 break;
966 }
968 return sp_event_context_virtual_item_handler(event_context, item, event);
969 }
971 gint
972 sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
973 {
974 gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
976 if (! ret) {
977 ret = sp_event_context_virtual_root_handler(event_context, event);
978 } else {
979 set_event_location(event_context->desktop, event);
980 }
982 return ret;
983 }
985 /**
986 * Emits 'position_set' signal on desktop and shows coordinates on status bar.
987 */
988 static void set_event_location(SPDesktop *desktop, GdkEvent *event)
989 {
990 if (event->type != GDK_MOTION_NOTIFY) {
991 return;
992 }
994 Geom::Point const button_w(event->button.x, event->button.y);
995 Geom::Point const button_dt(desktop->w2d(button_w));
996 desktop->setPosition(button_dt);
997 desktop->set_coordinate_status(button_dt);
998 }
1000 //-------------------------------------------------------------------
1001 /**
1002 * Create popup menu and tell Gtk to show it.
1003 */
1004 void
1005 sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
1006 {
1007 GtkWidget *menu;
1009 /* fixme: This is not what I want but works for now (Lauris) */
1010 if (event->type == GDK_KEY_PRESS) {
1011 item = sp_desktop_selection(desktop)->singleItem();
1012 }
1013 menu = sp_ui_context_menu(desktop, item);
1014 gtk_widget_show(menu);
1016 switch (event->type) {
1017 case GDK_BUTTON_PRESS:
1018 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, event->button.button, event->button.time);
1019 break;
1020 case GDK_KEY_PRESS:
1021 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 0, NULL, 0, event->key.time);
1022 break;
1023 default:
1024 break;
1025 }
1026 }
1028 /**
1029 * Show tool context specific modifier tip.
1030 */
1031 void
1032 sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
1033 GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip,
1034 gchar const *alt_tip)
1035 {
1036 guint keyval = get_group0_keyval(&event->key);
1038 bool ctrl = ctrl_tip && (MOD__CTRL
1039 || (keyval == GDK_Control_L)
1040 || (keyval == GDK_Control_R));
1041 bool shift = shift_tip
1042 && (MOD__SHIFT || (keyval == GDK_Shift_L) || (keyval == GDK_Shift_R));
1043 bool alt = alt_tip
1044 && (MOD__ALT
1045 || (keyval == GDK_Alt_L)
1046 || (keyval == GDK_Alt_R)
1047 || (keyval == GDK_Meta_L)
1048 || (keyval == GDK_Meta_R));
1050 gchar *tip = g_strdup_printf("%s%s%s%s%s",
1051 ( ctrl ? ctrl_tip : "" ),
1052 ( ctrl && (shift || alt) ? "; " : "" ),
1053 ( shift ? shift_tip : "" ),
1054 ( (ctrl || shift) && alt ? "; " : "" ),
1055 ( alt ? alt_tip : "" ));
1057 if (strlen(tip) > 0) {
1058 message_context->flash(Inkscape::INFORMATION_MESSAGE, tip);
1059 }
1061 g_free(tip);
1062 }
1064 /**
1065 * Return the keyval corresponding to the key event in group 0, i.e.,
1066 * in the main (English) layout.
1067 *
1068 * Use this instead of simply event->keyval, so that your keyboard shortcuts
1069 * work regardless of layouts (e.g., in Cyrillic).
1070 */
1071 guint
1072 get_group0_keyval(GdkEventKey *event)
1073 {
1074 guint keyval = 0;
1075 gdk_keymap_translate_keyboard_state(
1076 gdk_keymap_get_for_display(gdk_display_get_default()),
1077 event->hardware_keycode,
1078 (GdkModifierType) event->state,
1079 0 /*event->key.group*/,
1080 &keyval, NULL, NULL, NULL);
1081 return keyval;
1082 }
1084 /**
1085 * Returns item at point p in desktop.
1086 *
1087 * If state includes alt key mask, cyclically selects under; honors
1088 * into_groups.
1089 */
1090 SPItem *
1091 sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p,
1092 bool select_under, bool into_groups)
1093 {
1094 SPItem *item;
1096 if (select_under) {
1097 SPItem *selected_at_point =
1098 desktop->item_from_list_at_point_bottom (desktop->selection->itemList(), p);
1099 item = desktop->item_at_point(p, into_groups, selected_at_point);
1100 if (item == NULL) { // we may have reached bottom, flip over to the top
1101 item = desktop->item_at_point(p, into_groups, NULL);
1102 }
1103 } else
1104 item = desktop->item_at_point(p, into_groups, NULL);
1106 return item;
1107 }
1109 /**
1110 * Returns item if it is under point p in desktop, at any depth; otherwise returns NULL.
1111 *
1112 * Honors into_groups.
1113 */
1114 SPItem *
1115 sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p)
1116 {
1117 GSList *temp = NULL;
1118 temp = g_slist_prepend (temp, item);
1119 SPItem *item_at_point = desktop->item_from_list_at_point_bottom (temp, p);
1120 g_slist_free (temp);
1122 return item_at_point;
1123 }
1125 ShapeEditor *
1126 sp_event_context_get_shape_editor (SPEventContext *ec)
1127 {
1128 return ec->shape_editor;
1129 }
1131 void
1132 event_context_print_event_info(GdkEvent *event, bool print_return) {
1133 switch (event->type) {
1134 case GDK_BUTTON_PRESS:
1135 g_print ("GDK_BUTTON_PRESS");
1136 break;
1137 case GDK_2BUTTON_PRESS:
1138 g_print ("GDK_2BUTTON_PRESS");
1139 break;
1140 case GDK_3BUTTON_PRESS:
1141 g_print ("GDK_3BUTTON_PRESS");
1142 break;
1144 case GDK_MOTION_NOTIFY:
1145 g_print ("GDK_MOTION_NOTIFY");
1146 break;
1147 case GDK_ENTER_NOTIFY:
1148 g_print ("GDK_ENTER_NOTIFY");
1149 break;
1151 case GDK_LEAVE_NOTIFY:
1152 g_print ("GDK_LEAVE_NOTIFY");
1153 break;
1154 case GDK_BUTTON_RELEASE:
1155 g_print ("GDK_BUTTON_RELEASE");
1156 break;
1158 case GDK_KEY_PRESS:
1159 g_print ("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key));
1160 break;
1161 case GDK_KEY_RELEASE:
1162 g_print ("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key));
1163 break;
1164 default:
1165 //g_print ("even type not recognized");
1166 break;
1167 }
1169 if (print_return) {
1170 g_print ("\n");
1171 }
1172 }
1174 void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin)
1175 {
1176 static guint32 prev_time;
1177 static boost::optional<Geom::Point> prev_pos;
1179 // Snapping occurs when dragging with the left mouse button down, or when hovering e.g. in the pen tool with left mouse button up
1180 bool const c1 = event->state & GDK_BUTTON2_MASK; // We shouldn't hold back any events when other mouse buttons have been
1181 bool const c2 = event->state & GDK_BUTTON3_MASK; // pressed, e.g. when scrolling with the middle mouse button; if we do then
1182 // Inkscape will get stuck in an unresponsive state
1184 if (c1 || c2) {
1185 // Make sure that we don't send any pending snap events to a context if we know in advance
1186 // that we're not going to snap any way (e.g. while scrolling with middle mouse button)
1187 // Any motion event might affect the state of the context, leading to unexpected behavior
1188 delete ec->_delayed_snap_event;
1189 ec->_delayed_snap_event = NULL;
1190 }
1192 if (ec->_snap_window_open && !c1 && !c2 && ec->desktop && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
1193 // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occurred for some period.
1194 // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never
1195 // be fully at stand still and might keep spitting out motion events.
1196 ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold
1198 Geom::Point event_pos(event->x, event->y);
1199 guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
1201 if (prev_pos) {
1202 Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
1203 guint32 delta_t = event_t - prev_time;
1204 gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
1205 //std::cout << "Mouse speed = " << speed << " px/msec " << std::endl;
1206 if (speed > 0.02) { // Jitter threshold, might be needed for tablets
1207 // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We
1208 // will keep on postponing the snapping as long as the speed is high.
1209 // We must snap at some point in time though, so set a watchdog timer at some time from
1210 // now, just in case there's no future motion event that drops under the speed limit (when
1211 // stopping abruptly)
1212 delete ec->_delayed_snap_event;
1213 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin); // watchdog is reset, i.e. pushed forward in time
1214 // If the watchdog expires before a new motion event is received, we will snap (as explained
1215 // above). This means however that when the timer is too short, we will always snap and that the
1216 // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will
1217 // be immediate, as it used to be in the old days ;-).
1218 } else { // Speed is very low, so we're virtually at stand still
1219 // But if we're really standing still, then we should snap now. We could use some low-pass filtering,
1220 // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire,
1221 // snap, and set a new watchdog again.
1222 if (ec->_delayed_snap_event == NULL) { // no watchdog has been set
1223 // it might have already expired, so we'll set a new one; the snapping frequency will be limited by this
1224 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
1225 } // else: watchdog has been set before and we'll wait for it to expire
1226 }
1227 } else {
1228 // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
1229 g_assert(ec->_delayed_snap_event == NULL);
1230 ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
1231 }
1233 prev_pos = event_pos;
1234 prev_time = event_t;
1235 }
1236 }
1238 gboolean sp_event_context_snap_watchdog_callback(gpointer data)
1239 {
1240 // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated
1241 DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*>(data);
1243 if (dse == NULL) {
1244 // This might occur when this method is called directly, i.e. not through the timer
1245 // E.g. on GDK_BUTTON_RELEASE in sp_event_context_root_handler()
1246 return FALSE;
1247 }
1249 SPEventContext *ec = dse->getEventContext();
1250 if (ec == NULL || ec->desktop == NULL) {
1251 return false;
1252 }
1254 SPDesktop *dt = ec->desktop;
1255 dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
1257 switch (dse->getOrigin()) {
1258 case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
1259 sp_event_context_virtual_root_handler(ec, dse->getEvent());
1260 break;
1261 case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER:
1262 {
1263 SPItem* item = NULL;
1264 item = dse->getItem();
1265 if (item && SP_IS_ITEM(item)) {
1266 sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
1267 }
1268 }
1269 break;
1270 case DelayedSnapEvent::KNOT_HANDLER:
1271 {
1272 SPKnot* knot = dse->getKnot();
1273 if (knot && SP_IS_KNOT(knot)) {
1274 sp_knot_handler_request_position(dse->getEvent(), knot);
1275 }
1276 }
1277 break;
1278 default:
1279 g_warning("Origin of snap-delay event has not been defined!;");
1280 break;
1281 }
1283 ec->_delayed_snap_event = NULL;
1284 delete dse;
1286 return FALSE; //Kills the timer and stops it from executing this callback over and over again.
1287 }
1289 void sp_event_context_snap_window_open(SPEventContext *ec, bool show_debug_warnings)
1290 {
1291 // Only when ec->_snap_window_open has been set, Inkscape will know that snapping is active
1292 // and will delay any snapping events (but only when asked to through the preferences)
1294 // When snapping is being delayed, then that will also mean that at some point the last event
1295 // might be re-triggered. This should only occur when Inkscape is still in the same tool or context,
1296 // and even more specifically, the tool should even be in the same state. If for example snapping is being delayed while
1297 // creating a rectangle, then the rect-context will be active and it will be in the "dragging" state
1298 // (see the static boolean variable "dragging" in the sp_rect_context_root_handler). The procedure is
1299 // as follows: call sp_event_context_snap_window_open(*, TRUE) when entering the "dragging" state, which will delay
1300 // snapping from that moment on, and call sp_event_context_snap_window_open(*, FALSE) when leaving the "dragging"
1301 // state. This last call will also make sure that any pending snap events will be canceled.
1303 //std::cout << "sp_event_context_snap_window_open" << std::endl;
1304 if (!ec) {
1305 if (show_debug_warnings) {
1306 g_warning("sp_event_context_snap_window_open() has been called without providing an event context!");
1307 }
1308 return;
1309 }
1311 if (ec->_snap_window_open == true && show_debug_warnings) {
1312 g_warning("Snap window was already open! This is a bug, please report it.");
1313 }
1315 ec->_snap_window_open = true;
1316 }
1318 void sp_event_context_snap_window_closed(SPEventContext *ec, bool show_debug_warnings)
1319 {
1320 //std::cout << "sp_event_context_snap_window_closed" << std::endl;
1321 if (!ec) {
1322 if (show_debug_warnings) {
1323 g_warning("sp_event_context_snap_window_closed() has been called without providing an event context!");
1324 }
1325 return;
1326 }
1328 if (ec->_snap_window_open == false && show_debug_warnings) {
1329 g_warning("Snap window was already closed! This is a bug, please report it.");
1330 }
1332 ec->_snap_window_open = false;
1334 delete ec->_delayed_snap_event;
1335 ec->_delayed_snap_event = NULL;
1336 }
1340 /*
1341 Local Variables:
1342 mode:c++
1343 c-file-style:"stroustrup"
1344 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1345 indent-tabs-mode:nil
1346 fill-column:99
1347 End:
1348 */
1349 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :