+ assert (x);
+ assert (y);
+
+ if (suspending_editor_updates ()) {
+
+ /* We are dragging, and configured not to update the editor window during drags,
+ so just return where the editor will be when the drag finishes.
+ */
+
+ *x = _pending_editor_x;
+ *y = _pending_editor_y;
+
+ } else {
+
+ /* Otherwise query the editor for its actual position */
+
+ x->first = (_editor->leftmost_position () - _start) * _x_scale;
+ x->second = x->first + _editor->current_page_frames() * _x_scale;
+
+ y->first = editor_y_to_summary (_editor->vertical_adjustment.get_value ());
+ y->second = editor_y_to_summary (_editor->vertical_adjustment.get_value () + _editor->canvas_height() - _editor->get_canvas_timebars_vsize());
+ }
+}
+
+/** Get an expression of the position of a point with respect to the view rectangle */
+EditorSummary::Position
+EditorSummary::get_position (double x, double y) const
+{
+ /* how close the mouse has to be to the edge of the view rectangle to be considered `on it',
+ in pixels */
+
+ int x_edge_size = (_view_rectangle_x.second - _view_rectangle_x.first) / 4;
+ x_edge_size = min (x_edge_size, 8);
+ x_edge_size = max (x_edge_size, 1);
+
+ int y_edge_size = (_view_rectangle_y.second - _view_rectangle_y.first) / 4;
+ y_edge_size = min (y_edge_size, 8);
+ y_edge_size = max (y_edge_size, 1);
+
+ bool const near_left = (std::abs (x - _view_rectangle_x.first) < x_edge_size);
+ bool const near_right = (std::abs (x - _view_rectangle_x.second) < x_edge_size);
+ bool const near_top = (std::abs (y - _view_rectangle_y.first) < y_edge_size);
+ bool const near_bottom = (std::abs (y - _view_rectangle_y.second) < y_edge_size);
+ bool const within_x = _view_rectangle_x.first < x && x < _view_rectangle_x.second;
+ bool const within_y = _view_rectangle_y.first < y && y < _view_rectangle_y.second;
+
+ if (near_left && near_top) {
+ return LEFT_TOP;
+ } else if (near_left && near_bottom) {
+ return LEFT_BOTTOM;
+ } else if (near_right && near_top) {
+ return RIGHT_TOP;
+ } else if (near_right && near_bottom) {
+ return RIGHT_BOTTOM;
+ } else if (near_left && within_y) {
+ return LEFT;
+ } else if (near_right && within_y) {
+ return RIGHT;
+ } else if (near_top && within_x) {
+ return TOP;
+ } else if (near_bottom && within_x) {
+ return BOTTOM;
+ } else if (within_x && within_y) {
+ return INSIDE;
+ } else if (within_x) {
+ return BELOW_OR_ABOVE;
+ } else if (within_y) {
+ return TO_LEFT_OR_RIGHT;
+ } else {
+ return OTHERWISE_OUTSIDE;
+ }
+}