all events propagate out of the canvas in canvas coordinates now, so revert changes in editor_drags.cc that worked around this not being the case

This commit is contained in:
Paul Davis 2013-10-31 16:43:35 -04:00
parent ba26316857
commit 85daa31ab5
3 changed files with 18 additions and 11 deletions

View file

@ -4404,7 +4404,7 @@ Editor::get_preferred_edit_position (bool ignore_playhead, bool from_context_men
EditPoint ep = _edit_point; EditPoint ep = _edit_point;
if (from_context_menu && (ep == EditAtMouse)) { if (from_context_menu && (ep == EditAtMouse)) {
return window_event_frame (&context_click_event, 0, 0); return canvas_event_frame (&context_click_event, 0, 0);
} }
if (entered_marker) { if (entered_marker) {

View file

@ -191,7 +191,7 @@ DragManager::window_motion_handler (GdkEvent* e, bool from_autoscroll)
{ {
bool r = false; bool r = false;
_current_pointer_frame = _editor->window_event_frame (e, &_current_pointer_x, &_current_pointer_y); _current_pointer_frame = _editor->canvas_event_frame (e, &_current_pointer_x, &_current_pointer_y);
for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) { for (list<Drag*>::iterator i = _drags.begin(); i != _drags.end(); ++i) {
bool const t = (*i)->motion_handler (e, from_autoscroll); bool const t = (*i)->motion_handler (e, from_autoscroll);
@ -259,7 +259,7 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
_y_constrained = false; _y_constrained = false;
} }
_raw_grab_frame = _editor->window_event_frame (event, &_grab_x, &_grab_y); _raw_grab_frame = _editor->canvas_event_frame (event, &_grab_x, &_grab_y);
setup_pointer_frame_offset (); setup_pointer_frame_offset ();
_grab_frame = adjusted_frame (_raw_grab_frame, event); _grab_frame = adjusted_frame (_raw_grab_frame, event);
_last_pointer_frame = _grab_frame; _last_pointer_frame = _grab_frame;

View file

@ -260,7 +260,8 @@ GtkCanvas::GtkCanvas ()
, _focused_item (0) , _focused_item (0)
{ {
/* these are the events we want to know about */ /* these are the events we want to know about */
add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK); add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK |
Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK);
} }
/** Handler for pointer motion events on the canvas. /** Handler for pointer motion events on the canvas.
@ -406,7 +407,7 @@ GtkCanvas::enter_leave_items (Duple const & point, int state)
} }
} }
#if 0 #if 1
cerr << "Within:\n"; cerr << "Within:\n";
for (set<Item const *>::const_iterator i = within_items.begin(); i != within_items.end(); ++i) { for (set<Item const *>::const_iterator i = within_items.begin(); i != within_items.end(); ++i) {
cerr << '\t' << (*i)->whatami() << '/' << (*i)->name << endl; cerr << '\t' << (*i)->whatami() << '/' << (*i)->name << endl;
@ -543,14 +544,18 @@ GtkCanvas::on_button_press_event (GdkEventButton* ev)
{ {
/* translate event coordinates from window to canvas */ /* translate event coordinates from window to canvas */
GdkEvent copy = *((GdkEvent*)ev);
Duple where = window_to_canvas (Duple (ev->x, ev->y)); Duple where = window_to_canvas (Duple (ev->x, ev->y));
copy.button.x = where.x;
copy.button.y = where.y;
/* Coordinates in the event will be canvas coordinates, correctly adjusted /* Coordinates in the event will be canvas coordinates, correctly adjusted
for scroll if this GtkCanvas is in a GtkCanvasViewport. for scroll if this GtkCanvas is in a GtkCanvasViewport.
*/ */
DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas button press @ %1, %2 => %3\n", ev->x, ev->y, where)); DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas button press @ %1, %2 => %3\n", ev->x, ev->y, where));
return deliver_event (where, reinterpret_cast<GdkEvent*>(ev)); return deliver_event (where, reinterpret_cast<GdkEvent*>(&copy));
} }
/** Handler for GDK button release events. /** Handler for GDK button release events.
@ -562,14 +567,18 @@ GtkCanvas::on_button_release_event (GdkEventButton* ev)
{ {
/* translate event coordinates from window to canvas */ /* translate event coordinates from window to canvas */
GdkEvent copy = *((GdkEvent*)ev);
Duple where = window_to_canvas (Duple (ev->x, ev->y)); Duple where = window_to_canvas (Duple (ev->x, ev->y));
copy.button.x = where.x;
copy.button.y = where.y;
/* Coordinates in the event will be canvas coordinates, correctly adjusted /* Coordinates in the event will be canvas coordinates, correctly adjusted
for scroll if this GtkCanvas is in a GtkCanvasViewport. for scroll if this GtkCanvas is in a GtkCanvasViewport.
*/ */
DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas button release @ %1, %2 => %3\n", ev->x, ev->y, where)); DEBUG_TRACE (PBD::DEBUG::CanvasEvents, string_compose ("canvas button release @ %1, %2 => %3\n", ev->x, ev->y, where));
return deliver_event (where, reinterpret_cast<GdkEvent*>(ev)); return deliver_event (where, reinterpret_cast<GdkEvent*>(&copy));
} }
/** Handler for GDK motion events. /** Handler for GDK motion events.
@ -604,7 +613,6 @@ GtkCanvas::on_enter_notify_event (GdkEventCrossing* ev)
bool bool
GtkCanvas::on_leave_notify_event (GdkEventCrossing* /*ev*/) GtkCanvas::on_leave_notify_event (GdkEventCrossing* /*ev*/)
{ {
cerr << "Clear all within items as we leave\n";
within_items.clear (); within_items.clear ();
return true; return true;
} }
@ -616,8 +624,7 @@ void
GtkCanvas::request_redraw (Rect const & request) GtkCanvas::request_redraw (Rect const & request)
{ {
Rect area = canvas_to_window (request); Rect area = canvas_to_window (request);
// cerr << this << " Invalidate " << request << " TRANSLATE AS " << area << endl; queue_draw_area (floor (area.x0), floor (area.y0), ceil (area.width()), ceil (area.height()));
queue_draw_area (floor (area.x0), floor (area.y0), ceil (area.x1) - floor (area.x0), ceil (area.y1) - floor (area.y0));
} }
/** Called to request that we try to get a particular size for ourselves. /** Called to request that we try to get a particular size for ourselves.