diff --git a/GraphView/graphview.py b/GraphView/graphview.py index bbce87639..cf05e899b 100644 --- a/GraphView/graphview.py +++ b/GraphView/graphview.py @@ -1425,7 +1425,8 @@ def populate(self, active_person): if self.uistate.window.get_window().is_visible(): process_pending_events() - self._in_drag = False + self._in_drag = False # True - when drag can be started + self._do_drag = False # True - when drag is started self.clear() self.active_person_handle = active_person @@ -1595,7 +1596,10 @@ def motion_notify_event(self, _item, _target, event): self.vadjustment.set_value(new_y) return True - if self._in_drag and (event.type == Gdk.EventType.MOTION_NOTIFY): + if not (event.type == Gdk.EventType.MOTION_NOTIFY): + return False + + if self._in_drag and (not self._do_drag): # start drag when cursor moved more then 5 # to separate it from simple click if ((abs(self._last_x - event.x_root) > 5) @@ -1609,11 +1613,8 @@ def motion_notify_event(self, _item, _target, event): # translate to drag_widget coords scale_coef = self.canvas.get_scale() - bounds = self.canvas.get_root_item().get_bounds() - height_canvas = bounds.y2 - bounds.y1 x = self._last_x * scale_coef - self.hadjustment.get_value() - y = ((height_canvas + self._last_y) * scale_coef - - self.vadjustment.get_value()) + y = self._last_y * scale_coef - self.vadjustment.get_value() # setup targets tglist = Gtk.TargetList.new([]) @@ -1632,14 +1633,12 @@ def motion_notify_event(self, _item, _target, event): # allow drag to a text document, info on drag_get will be 1 tglist.add_text_targets(1) - drag_widget = self.get_widget() - # change event window - event.window = drag_widget.get_window() # start drag + drag_widget = self.get_widget() drag_widget.drag_begin_with_coordinates( tglist, Gdk.DragAction.COPY, - Gdk.KEY_Pointer_Button1, + 1, # left mouse button = 1 event, x, y) return True @@ -1735,6 +1734,7 @@ def cb_drag_begin(self, widget, context): """ Called on start drag. """ + self._do_drag = True tgs = [x.name() for x in context.list_targets()] # set icon depending on person or family drag if DdTargets.PERSON_LINK.drag_type in tgs: @@ -1747,6 +1747,7 @@ def cb_drag_end(self, widget, context): Called when drag is end. """ self._in_drag = False + self._do_drag = False def cb_drag_data_get(self, widget, context, sel_data, info, time): """