Skip to content

Commit 74a3b38

Browse files
committed
improve: 当光标形状为Hand时,按下中键不应该teleport
1 parent b93d3cc commit 74a3b38

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

Log.txt

+14
Original file line numberDiff line numberDiff line change
@@ -837,3 +837,17 @@
837837

838838
9-18:
839839
啊没什么 就是新增多仓库同步push 测试一下
840+
841+
9-25:
842+
with MSVC编译器,之前提到使用QAudioDeviceInfo::availableDevices(QAudio::AudioInput);会有卡顿和输出同名设备的问题
843+
解决方案是:plugins/audio下 删除 qtaudio_wasapi.dll
844+
但是改用Windows API之后,就没有这个问题了,所以可以恢复过来(其他项目需要依赖)
845+
https://blog.csdn.net/m0_52040845/article/details/118761684
846+
847+
##2024:
848+
3-7:
849+
BUG:关于启动Follower后,首次输入命令会卡顿的问题,可能是UI渲染导致的? 但是更新Qt后重新编译,感觉没问题了?(Or错觉,先观察几天)
850+
851+
5-11:
852+
improve:按中间Teleport前,会检测当前鼠标光标形状,如果为Hand,则不Teleport,因为中键点击链接可以在后台打开页面(浏览器),此时不应弹出Follower
853+
而且,光标为Hand,基本意味着可以点击,此时也不应该弹出Follower

Utils/WinUtility.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,18 @@ QSet<DWORD> Win::getAvailableScreenReflashRates()
281281
list << lpDevMode.dmDisplayFrequency;
282282
return list;
283283
}
284+
285+
/// 测试全局光标形状
286+
/// - 因为Qt的cursor::shape()只能检测本程序窗口
287+
/// - ref: https://bbs.csdn.net/topics/392329000
288+
bool Win::testGlobalCursorShape(LPCWSTR cursorID)
289+
{
290+
CURSORINFO info;
291+
info.cbSize = sizeof(CURSORINFO); // 必需
292+
GetCursorInfo(&info);
293+
if (info.flags != CURSOR_SHOWING) return false; // 光标隐藏时,hCurosr为NULL
294+
// Windows API 没有直接获取光标形状的函数,只能通过比较光标句柄
295+
// LoadCursor [arg0:NULL] 意为加载预定义的系统游标
296+
// 原理:仅当游标资源尚未加载时,LoadCursor 函数才会加载游标资源; 否则,它将检索现有资源的句柄
297+
return info.hCursor == LoadCursor(NULL, cursorID);
298+
}

Utils/WinUtility.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Win //Windows API
3939
static bool setScreenReflashRate(int rate);
4040
static DWORD getCurrentScreenReflashRate(void);
4141
static QSet<DWORD> getAvailableScreenReflashRates(void);
42+
static bool testGlobalCursorShape(LPCWSTR cursorID);
4243
};
4344

4445
#endif // WIN_H

Utils/request.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ void Request::translate(const QString& text, std::function<void(const QString&)>
5858
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
5959
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
6060
loop.exec();
61+
// 局部事件循环可能有问题,试想:push Button发送一次请求,那么进入局部循环后再发送一次就会再嵌套一个局部循环
62+
// 那么就算外部的this循环超时了,也不能退出,得等最深的循环退出才可(参考递归与回溯)
63+
// 故换用其他方案,如定时abort https://blog.csdn.net/weixin_40774605/article/details/110007462
64+
// 貌似Qt5.15引入了:QNetworkRequest::setTransferTimeout !
6165

6266
if (timer.isActive()) { //normal
6367
timer.stop();

Utils/systemapi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SystemAPI::SystemAPI(QObject* parent)
2222
{ //need a function to delete these pointers(InputMethod is not a QObject but it Can be)//或者采用shared_ptr调用SystemAPI析构
2323
if (sys != nullptr) {
2424
qDebug() << "SystemAPI multi defined"; //只允许有一个对象
25-
QTimer::singleShot(0, [=]() { qApp->quit(); }); //等待进入事件循环
25+
QTimer::singleShot(0, this, [=]() { qApp->quit(); }); //等待进入事件循环
2626
return;
2727
}
2828
sys = this;

updateform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UpdateForm : public QDialog {
3737
QWinTaskbarButton* taskBarBtn = nullptr;
3838
QWinTaskbarProgress* taskBarProgress = nullptr;
3939

40-
const QString ver = "v2.14.7";
40+
const QString ver = "v2.14.8";
4141

4242
// QWidget interface
4343
protected:

widget.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ void Widget::updateWindow()
244244
switch (state) {
245245
case MOVE:
246246
isTeleport = false;
247-
if (KeyState::isRelease(VK_MBUTTON, 500) && teleportMode != OFF) {
247+
// 1. 500ms内释放中键,防止用户意图为在浏览器内长按触发滚动;2. 光标形状不为HAND时触发,防止意图为后台打开链接(浏览器)
248+
if (KeyState::isRelease(VK_MBUTTON, 500) && !Win::testGlobalCursorShape(IDC_HAND)) {
248249
if (teleportMode == ON || (teleportMode == AUTO && !Win::isForeFullScreen()))
249250
teleport(), isTeleport = true;
250251
} else if (isTeleportKey()) { //键盘快捷键无视全屏

0 commit comments

Comments
 (0)