From 6f2bae11530c914a87a84b90e3af06fa2c3b1b1b Mon Sep 17 00:00:00 2001 From: vantu5z Date: Thu, 26 Sep 2019 10:08:10 +0300 Subject: [PATCH] fix drag on Windows OS --- GraphView/graphview.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/GraphView/graphview.py b/GraphView/graphview.py index 2433b7d42..8126cdced 100644 --- a/GraphView/graphview.py +++ b/GraphView/graphview.py @@ -1278,7 +1278,8 @@ def populate(self, active_person): # set the busy cursor, so the user knows that we are working self.uistate.set_busy_cursor(True) - 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 @@ -1448,7 +1449,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) @@ -1462,11 +1466,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([]) @@ -1485,14 +1486,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 @@ -1591,6 +1590,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: @@ -1603,6 +1603,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): """