Skip to content

perf:not monitor mouse move event when disable popbutton#946

Merged
tisfeng merged 3 commits intotisfeng:devfrom
xyzhou-1:dont-monitor-mouse-move
Aug 18, 2025
Merged

perf:not monitor mouse move event when disable popbutton#946
tisfeng merged 3 commits intotisfeng:devfrom
xyzhou-1:dont-monitor-mouse-move

Conversation

@xyzhou-1
Copy link
Copy Markdown
Contributor

@xyzhou-1 xyzhou-1 commented Aug 17, 2025

当关闭划词翻译后,不要监听鼠标移动事件
fix:#941,#223

根据简单统计,easydict在活动监视器的12小时能耗,从10,下降到1(具体数值取决于个人使用强度)

移除了 NSEventMaskAny | NSEventTypeSystemDefined,请检视.
NSEventTypeSystemDefined并不属于NSEventMask枚举,对应的应该是NSEventMaskSystemDefined,所以删除无影响
NSEventMaskAny监听了所有事件,其他mask就无效了,所以删除

@xyzhou-1 xyzhou-1 changed the title perf:not monitor mouse move event when diable popbutton perf:not monitor mouse move event when disable popbutton Aug 17, 2025
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello xyzhou-1, Thank you for your first PR contribution 🎉 xyzhou-1

@xyzhou-1 xyzhou-1 force-pushed the dont-monitor-mouse-move branch from 925773b to 73b4f14 Compare August 17, 2025 03:24
@tisfeng tisfeng requested review from AkaShark and Jerry23011 August 17, 2025 14:41
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Aug 17, 2025

你好,感谢你的 PR!

修正 NSEventMask 没问题,这个当初可能我没注意,写错了。

至于移除 NSEventMaskScrollWheel | NSEventMaskMouseMoved 这两个事件的监听,稍后我测试一下,如果没有影响到其他功能,那可以删除。

@xyzhou-1
Copy link
Copy Markdown
Contributor Author

你好,感谢你的 PR!

修正 NSEventMask 没问题,这个当初可能我没注意,写错了。

至于移除 NSEventMaskScrollWheel | NSEventMaskMouseMoved 这两个事件的监听,稍后我测试一下,如果没有影响到其他功能,那可以删除。

好的,辛苦测试.我通过在EZEventMonitor.m中搜索相关symbol来确定的影响范围,发现 NSEventMaskScrollWheel | NSEventMaskMouseMoved的处理只有这部分,都和popbutton有关,所以判断当关闭划词翻译后,不再需要.但还是麻烦再确认下

case NSEventTypeScrollWheel: {
if (self.isPopButtonVisible) {
CGFloat deltaY = event.scrollingDeltaY;
self.movedY += deltaY;
// MMLogInfo(@"movedY: %.1f", self.movedY);
CGFloat maxDeltaY = 80;
if (fabs(self.movedY) > maxDeltaY) {
[self dismissPopButton];
}
}
break;
}
case NSEventTypeMouseMoved: {
if (self.isPopButtonVisible) {
// Hide the button after exceeding a certain range of selected text frame.
if (![self isMouseInPopButtonExpandedFrame]) {
[self dismissPopButton];
}
}
break;
}

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

- Changed `NSEventTypeRightMouseDown` to `NSEventMaskRightMouseDown` in the global event mask.

- This ensures the right mouse down event is properly monitored for relevant actions.
@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Aug 18, 2025

ok,测了一下,看起来没什么问题。

Copy link
Copy Markdown
Owner

@tisfeng tisfeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tisfeng tisfeng merged commit a011b73 into tisfeng:dev Aug 18, 2025
4 checks passed
@xyzhou-1 xyzhou-1 deleted the dont-monitor-mouse-move branch January 16, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants