@@ -1278,7 +1278,8 @@ def populate(self, active_person):
1278
1278
# set the busy cursor, so the user knows that we are working
1279
1279
self .uistate .set_busy_cursor (True )
1280
1280
1281
- self ._in_drag = False
1281
+ self ._in_drag = False # True - when drag can be started
1282
+ self ._do_drag = False # True - when drag is started
1282
1283
self .clear ()
1283
1284
self .active_person_handle = active_person
1284
1285
@@ -1448,7 +1449,10 @@ def motion_notify_event(self, _item, _target, event):
1448
1449
self .vadjustment .set_value (new_y )
1449
1450
return True
1450
1451
1451
- if self ._in_drag and (event .type == Gdk .EventType .MOTION_NOTIFY ):
1452
+ if not (event .type == Gdk .EventType .MOTION_NOTIFY ):
1453
+ return False
1454
+
1455
+ if self ._in_drag and (not self ._do_drag ):
1452
1456
# start drag when cursor moved more then 5
1453
1457
# to separate it from simple click
1454
1458
if ((abs (self ._last_x - event .x_root ) > 5 )
@@ -1462,11 +1466,8 @@ def motion_notify_event(self, _item, _target, event):
1462
1466
1463
1467
# translate to drag_widget coords
1464
1468
scale_coef = self .canvas .get_scale ()
1465
- bounds = self .canvas .get_root_item ().get_bounds ()
1466
- height_canvas = bounds .y2 - bounds .y1
1467
1469
x = self ._last_x * scale_coef - self .hadjustment .get_value ()
1468
- y = ((height_canvas + self ._last_y ) * scale_coef -
1469
- self .vadjustment .get_value ())
1470
+ y = self ._last_y * scale_coef - self .vadjustment .get_value ()
1470
1471
1471
1472
# setup targets
1472
1473
tglist = Gtk .TargetList .new ([])
@@ -1485,14 +1486,12 @@ def motion_notify_event(self, _item, _target, event):
1485
1486
# allow drag to a text document, info on drag_get will be 1
1486
1487
tglist .add_text_targets (1 )
1487
1488
1488
- drag_widget = self .get_widget ()
1489
- # change event window
1490
- event .window = drag_widget .get_window ()
1491
1489
# start drag
1490
+ drag_widget = self .get_widget ()
1492
1491
drag_widget .drag_begin_with_coordinates (
1493
1492
tglist ,
1494
1493
Gdk .DragAction .COPY ,
1495
- Gdk . KEY_Pointer_Button1 ,
1494
+ 1 , # left mouse button = 1
1496
1495
event ,
1497
1496
x , y )
1498
1497
return True
@@ -1591,6 +1590,7 @@ def cb_drag_begin(self, widget, context):
1591
1590
"""
1592
1591
Called on start drag.
1593
1592
"""
1593
+ self ._do_drag = True
1594
1594
tgs = [x .name () for x in context .list_targets ()]
1595
1595
# set icon depending on person or family drag
1596
1596
if DdTargets .PERSON_LINK .drag_type in tgs :
@@ -1603,6 +1603,7 @@ def cb_drag_end(self, widget, context):
1603
1603
Called when drag is end.
1604
1604
"""
1605
1605
self ._in_drag = False
1606
+ self ._do_drag = False
1606
1607
1607
1608
def cb_drag_data_get (self , widget , context , sel_data , info , time ):
1608
1609
"""
0 commit comments