diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 36d85673b0..35a7e930ef 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2389,6 +2389,7 @@ CursorDrag::start_grab (GdkEvent* event, Gdk::Cursor* c) _grab_zoom = _editor->samples_per_pixel; framepos_t where = _editor->canvas_event_frame (event, 0, 0); + _editor->snap_to_with_modifier (where, event); _editor->_dragging_playhead = true; diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 0566bca2da..27a13a94b7 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -30,6 +30,7 @@ #include #include "canvas/group.h" +#include "canvas/canvas.h" #include "ardour/session.h" #include "ardour/tempo.h" @@ -250,8 +251,17 @@ Editor::ruler_button_press (GdkEventButton* ev) _session->cancel_audition (); } - /* playhead cursor */ - _drags->set (new CursorDrag (this, *playhead_cursor, false), reinterpret_cast (ev)); + /* playhead cursor drag: CursorDrag expects an event with + * canvas coordinates, so convert from window coordinates, + * since for now, rulers are still Gtk::Widgets. + */ + + GdkEventButton canvas_ev = *ev; + ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (ev->x, ev->y)); + canvas_ev.x = rint (d.x); + canvas_ev.y = rint (d.y); + + _drags->set (new CursorDrag (this, *playhead_cursor, false), reinterpret_cast (&canvas_ev)); _dragging_playhead = true; } @@ -265,21 +275,21 @@ Editor::ruler_button_release (GdkEventButton* ev) return false; } - gint x,y; - Gdk::ModifierType state; - if (_drags->active ()) { - _drags->end_grab (reinterpret_cast (ev)); + GdkEventButton canvas_ev = *ev; + ArdourCanvas::Duple d = _track_canvas->window_to_canvas (ArdourCanvas::Duple (ev->x, ev->y)); + canvas_ev.x = rint (d.x); + canvas_ev.x = rint (d.y); + _drags->end_grab (reinterpret_cast (&canvas_ev)); _dragging_playhead = false; } if (ev->button == 3) { - /* need to use the correct x,y, the event lies */ - time_canvas_event_box.get_window()->get_pointer (x, y, state); - + stop_canvas_autoscroll(); - framepos_t where = leftmost_frame + pixel_to_sample (x); + framepos_t where = window_event_frame ((GdkEvent*) ev); + snap_to (where); popup_ruler_menu (where); }