11# 标准库导入
22import ctypes
33import os
4+ import time
45from typing import Dict , Any
56
67# 第三方库导入
@@ -924,7 +925,7 @@ def mousePressEvent(self, e):
924925 if not self ._draggable :
925926 return # 如果不可拖动,直接返回
926927 self ._press_pos = e .globalPosition ().toPoint ()
927- self ._press_time = e . timestamp () # 记录鼠标按下时间戳
928+ self ._press_time = int ( time . monotonic () * 1000 )
928929 self ._dragging = False
929930 self ._drag_timer .stop ()
930931 self ._drag_timer .start (self ._long_press_ms )
@@ -952,7 +953,9 @@ def mouseMoveEvent(self, e):
952953 if not self ._dragging :
953954 delta = cur - self ._press_pos
954955 press_duration = (
955- e .timestamp () - self ._press_time if self ._press_time > 0 else 0
956+ int (time .monotonic () * 1000 ) - self ._press_time
957+ if self ._press_time > 0
958+ else 0
956959 )
957960 if self ._should_start_drag (delta , press_duration ):
958961 self ._begin_drag ()
@@ -1018,7 +1021,7 @@ def _handle_mouse_press_event(self, event) -> bool:
10181021 # 如果不可拖动,不启动拖动计时器
10191022 return False
10201023 self ._press_pos = event .globalPosition ().toPoint ()
1021- self ._press_time = event . timestamp () # 记录时间戳
1024+ self ._press_time = int ( time . monotonic () * 1000 )
10221025 self ._dragging = False
10231026 self ._drag_timer .stop ()
10241027 self ._drag_timer .start (self ._long_press_ms )
@@ -1040,7 +1043,9 @@ def _handle_mouse_move_event(self, event) -> bool:
10401043 if not self ._dragging :
10411044 delta = cur - self ._press_pos
10421045 press_duration = (
1043- event .timestamp () - self ._press_time if self ._press_time > 0 else 0
1046+ int (time .monotonic () * 1000 ) - self ._press_time
1047+ if self ._press_time > 0
1048+ else 0
10441049 )
10451050 if self ._should_start_drag (delta , press_duration ):
10461051 self ._begin_drag ()
0 commit comments