@@ -1192,7 +1192,8 @@ def populate(self, active_person):
1192
1192
# set the busy cursor, so the user knows that we are working
1193
1193
self .uistate .set_busy_cursor (True )
1194
1194
1195
- self ._in_drag = False
1195
+ self ._in_drag = False # True - when drag can be started
1196
+ self ._do_drag = False # True - when drag is started
1196
1197
self .clear ()
1197
1198
self .active_person_handle = active_person
1198
1199
@@ -1357,7 +1358,10 @@ def motion_notify_event(self, item, target, event):
1357
1358
self .vadjustment .set_value (new_y )
1358
1359
return True
1359
1360
1360
- if self ._in_drag and (event .type == Gdk .EventType .MOTION_NOTIFY ):
1361
+ if not (event .type == Gdk .EventType .MOTION_NOTIFY ):
1362
+ return False
1363
+
1364
+ if self ._in_drag and (not self ._do_drag ):
1361
1365
# start drag when cursor moved more then 5
1362
1366
# to separate it from simple click
1363
1367
if ((abs (self ._last_x - event .x_root ) > 5 )
@@ -1371,11 +1375,8 @@ def motion_notify_event(self, item, target, event):
1371
1375
1372
1376
# translate to drag_widget coords
1373
1377
scale_coef = self .canvas .get_scale ()
1374
- bounds = self .canvas .get_root_item ().get_bounds ()
1375
- height_canvas = bounds .y2 - bounds .y1
1376
1378
x = self ._last_x * scale_coef - self .hadjustment .get_value ()
1377
- y = ((height_canvas + self ._last_y ) * scale_coef -
1378
- self .vadjustment .get_value ())
1379
+ y = self ._last_y * scale_coef - self .vadjustment .get_value ()
1379
1380
1380
1381
# setup targets
1381
1382
tglist = Gtk .TargetList .new ([])
@@ -1394,14 +1395,12 @@ def motion_notify_event(self, item, target, event):
1394
1395
# allow drag to a text document, info on drag_get will be 1
1395
1396
tglist .add_text_targets (1 )
1396
1397
1397
- drag_widget = self .get_widget ()
1398
- # change event window
1399
- event .window = drag_widget .get_window ()
1400
1398
# start drag
1399
+ drag_widget = self .get_widget ()
1401
1400
drag_widget .drag_begin_with_coordinates (
1402
1401
tglist ,
1403
1402
Gdk .DragAction .COPY ,
1404
- Gdk . KEY_Pointer_Button1 ,
1403
+ 1 , # left mouse button = 1
1405
1404
event ,
1406
1405
x , y )
1407
1406
return True
@@ -1500,6 +1499,7 @@ def cb_drag_begin(self, widget, context):
1500
1499
"""
1501
1500
Called on start drag.
1502
1501
"""
1502
+ self ._do_drag = True
1503
1503
tgs = [x .name () for x in context .list_targets ()]
1504
1504
# set icon depending on person or family drag
1505
1505
if DdTargets .PERSON_LINK .drag_type in tgs :
@@ -1512,6 +1512,7 @@ def cb_drag_end(self, widget, context):
1512
1512
Called when drag is end.
1513
1513
"""
1514
1514
self ._in_drag = False
1515
+ self ._do_drag = False
1515
1516
1516
1517
def cb_drag_data_get (self , widget , context , sel_data , info , time ):
1517
1518
"""
0 commit comments