Repository navigation
fix(macos): Khắc phục lỗi đơ phím Apple Mail, Watchdog EventTap, SMAppService & hỗ trợ app lập trình - #333
Open
hungmtuci wants to merge 1 commit into
Conversation
…and modern dev app support - Fix Apple Mail event queue congestion by replacing static backspace CGEventRef with dynamic allocation (PostBackspaceEvent) - Add EventTap Watchdog Timer (0.5s) to automatically recover from system-disabled taps - Remove high-frequency mouse dragged events (120Hz) to eliminate WindowServer IPC bottlenecks - Modernize login item API using SMAppService.mainAppService on macOS 13+ (Ventura, Sonoma, Sequoia) - Remove redundant setRunOnStartup call in fillData to ensure language switching is 100% in-memory - Extend SmartSwitchKey default English mode for modern developer tools and terminals (VS Code, Cursor, Zed, Ghostty, Xcode, iTerm2, JetBrains, etc.) - Add standalone native build system (build_macos.sh, Makefile) with Link-Time Optimization (-flto) and dead code stripping (-Wl,-dead_strip) - Update README with attribution to original author Mai Vũ Tuyên (@tuyenvm) and detailed fork changelog
jetaudio
added a commit
to jetaudio/Omnikey
that referenced
this pull request
Oct 7, 2026
Adapt upstream PRs tuyenvm#297 and tuyenvm#333 while preserving single-character VNI/CP1258 decoding. Add sanitizer-backed regression coverage.
jetaudio
added a commit
to jetaudio/Omnikey
that referenced
this pull request
Oct 7, 2026
Adapt upstream PRs tuyenvm#324, tuyenvm#329, tuyenvm#332 and tuyenvm#333. Preserve saved shortcuts, bound Spotlight focus queries, avoid reusing backspace events, and send complete UTF-16 chunks. Cover event processing and tap lifecycle under sanitizers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Tóm tắt / Summary
Bản PR này tập trung giải quyết triệt để các vấn đề liên quan đến độ ổn định, đơ phím và tương thích trên các phiên bản macOS hiện đại (macOS 13+ Ventura, Sonoma, Sequoia):
🛠️ Các thay đổi & bản vá chính / Key Changes & Fixes
Khắc phục lỗi đơ gõ phím & mất ký tự trên Apple Mail & WebKit:
eventBackSpaceDownvàeventBackSpaceUpđược tạo tĩnh 1 lần (CGEventCreateKeyboardEvent) và tái sử dụng liên tục quaCGEventTapPostEvent. Do đối tượngCGEventRefmang tính mutable, việc gửi nhiều lần làm sai lệch sequence number và timestamp nội bộ của WindowServer, dẫn đến tắc nghẽn hàng đợi sự kiện bàn phím sau một vài từ gõ trong Apple Mail.PostBackspaceEvent()tự cấp phát mới và giải phóng tức thì bằngCFRelease()sau khi post sự kiện.Bổ sung Watchdog Timer (0.5s) bảo vệ
EventTap:kCGEventTapDisabledByTimeout) nếu callback xử lý chậm hoặc khi máy chuyển đổi trạng thái sleep/lock.CGEventTapIsEnabled(eventTap)và tự động tái kích hoạt tap nếu bị tắt.Loại bỏ sự kiện kéo chuột (
MouseDragged120Hz):kCGEventLeftMouseDraggedvàkCGEventRightMouseDraggedkhỏieventMask. Việc hook kéo chuột ở tần số quét cao (120Hz ProMotion) gây nghẽn luồng IPC của WindowServer mà không mang lại giá trị thực tế cho bộ gõ (chỉ cần giữMouseDownđể reset phiên gõ).Hiện đại hóa API khởi động cùng hệ thống (
SMAppService):SMLoginItemSetEnabled. Đã nâng cấp sử dụng[SMAppService mainAppService]giúp OpenKey hiển thị minh bạch trong mục System Settings ➔ Login Items mà không phụ thuộc helper process riêng biệt.setRunOnStartuptrong hàmfillData, giúp thao tác chuyển đổi ngôn ngữ/bảng mã diễn ra 100% trong RAM mà không phát sinh system call thừa.Mở rộng Smart Switch Key cho các công cụ lập trình & terminal hiện đại:
Tối ưu hóa biên dịch & Link-Time Optimization (LTO):
build_macos.shvàMakefilehỗ trợ biên dịch độc lập với Apple Clang native (-O3 -flto -Wl,-dead_strip), giúp nhị phân gọn gàng hơn và inlining tối ưu giữa Core Engine C++ và Objective-C.🧪 Kiểm thử / Verification