Skip to content

Commit f5a7e8f

Browse files
committed
修复Linux浮窗拖动失效
1 parent 62d94f9 commit f5a7e8f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG/v2.3.0-beta.1/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ v2.3 - Shirako (砂狼白子) beta 1
2424
- 修复 **简化模式** 设置项缺失崩溃
2525
- 修复 **Linux通知** 缺少notify-send崩溃
2626
- 修复 **Linux浮窗** 无焦点激活异常
27+
- 修复 **Linux浮窗** 拖动失效
2728

2829
## 🔧 其它变更
2930

app/view/floating_window/levitation.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 标准库导入
22
import ctypes
33
import os
4+
import time
45
from 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

Comments
 (0)