From 0ae8efb897c655a7e190e91427360f1d80e21792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=9F=E9=9B=80?= Date: Tue, 17 Dec 2024 10:32:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=94=AF=E6=8C=81MacOS14.6;=20(=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E6=94=AF=E6=8C=81=E4=BD=8E=E7=89=88=E6=9C=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++- Mos.xcodeproj/project.pbxproj | 36 +++++++++------- Mos/ScrollCore/ScrollPoster.swift | 69 ++++++++++++++++++++++--------- 3 files changed, 76 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1bc721..1108f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# [5.0.0] + +- 支持 MacOS 14, 解决平滑滚动时崩溃问题 + # [2.2.0](https://github.com/Caldis/Mos/releases/tag/2.2.0) 真帅 @@ -356,4 +360,4 @@ SmoothScroll performance improved. --- -First version released ! \ No newline at end of file +First version released ! diff --git a/Mos.xcodeproj/project.pbxproj b/Mos.xcodeproj/project.pbxproj index 27a85d0..147e4de 100644 --- a/Mos.xcodeproj/project.pbxproj +++ b/Mos.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -18,7 +18,6 @@ 0B6D3B6A2041C348004CC064 /* ScrollEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B6D3B692041C348004CC064 /* ScrollEvent.swift */; }; 0B6D3B702042BBCD004CC064 /* Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B6D3B6F2042BBCD004CC064 /* Localizable.swift */; }; 0B74C441205E386D00E3F942 /* Interceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B74C440205E386D00E3F942 /* Interceptor.swift */; }; - 0B99C5FC2577FC9200021578 /* ScrollPoster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B99C5FB2577FC9200021578 /* ScrollPoster.swift */; }; 0BB0F1BE20F3A04F00909B7D /* WelcomeWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BB0F1BD20F3A04F00909B7D /* WelcomeWindowController.swift */; }; 0BB0F1C020F3A05D00909B7D /* WelcomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BB0F1BF20F3A05D00909B7D /* WelcomeViewController.swift */; }; 0BC2AD2F20F3BA090084416B /* PreferencesContributorsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC2AD2E20F3BA090084416B /* PreferencesContributorsViewController.swift */; }; @@ -55,6 +54,7 @@ 23BB4D3121D775D4009B51E9 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23BB4D3021D775D4009B51E9 /* EventMonitor.swift */; }; 23E3C96D21DCE8F10098B107 /* StatusItemPopoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23E3C96C21DCE8F10098B107 /* StatusItemPopoverView.swift */; }; 23E9673F23613D1100E652F6 /* PreferencesExceptionInputViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23E9673E23613D1100E652F6 /* PreferencesExceptionInputViewController.swift */; }; + 6D6893ED2D101933003CE1BF /* ScrollPoster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D6893EC2D101933003CE1BF /* ScrollPoster.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -81,7 +81,6 @@ 0B74C440205E386D00E3F942 /* Interceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interceptor.swift; sourceTree = ""; }; 0B7C970A253F1C0200B26AF3 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = ""; }; 0B7C970B253F1C0300B26AF3 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; - 0B99C5FB2577FC9200021578 /* ScrollPoster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollPoster.swift; sourceTree = ""; }; 0BAC4070251651BC00E8A1FD /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Main.strings; sourceTree = ""; }; 0BAC4071251651BC00E8A1FD /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = ""; }; 0BAC4072251654C500E8A1FD /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Main.strings; sourceTree = ""; }; @@ -125,6 +124,9 @@ 23BB4D3021D775D4009B51E9 /* EventMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = ""; }; 23E3C96C21DCE8F10098B107 /* StatusItemPopoverView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusItemPopoverView.swift; sourceTree = ""; }; 23E9673E23613D1100E652F6 /* PreferencesExceptionInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesExceptionInputViewController.swift; sourceTree = ""; }; + 6D6893EC2D101933003CE1BF /* ScrollPoster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollPoster.swift; sourceTree = ""; }; + 6D6893F12D1115D1003CE1BF /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = SOURCE_ROOT; }; + 6D6893F22D1115D1003CE1BF /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -144,11 +146,11 @@ isa = PBXGroup; children = ( 2291A8A21E2A5400004181B8 /* ScrollCore.swift */, + 6D6893EC2D101933003CE1BF /* ScrollPoster.swift */, 0B12EF1C203ADD230058B169 /* ScrollUtils.swift */, 0BE4C93A20617C6E0001EA0E /* ScrollFilter.swift */, 0B6D3B692041C348004CC064 /* ScrollEvent.swift */, 0B474328258E12A200A5F8A3 /* ScrollPhase.swift */, - 0B99C5FB2577FC9200021578 /* ScrollPoster.swift */, 0B12EF1E203ADFB10058B169 /* Interpolator.swift */, ); path = ScrollCore; @@ -251,6 +253,8 @@ 22142DA21E25344E00E4BFBF /* Mos */ = { isa = PBXGroup; children = ( + 6D6893F12D1115D1003CE1BF /* CHANGELOG.md */, + 6D6893F22D1115D1003CE1BF /* README.md */, 22142DA31E25344E00E4BFBF /* AppDelegate.swift */, 0B6D3B6420419EF5004CC064 /* Utils */, 0B12EF5B203C3D510058B169 /* Options */, @@ -433,7 +437,6 @@ 239E851123562C34006DE0B0 /* StatusItemPopoverViewContentView.swift in Sources */, 23BB4D2D21D7512F009B51E9 /* StatusItemPopoverViewController.swift in Sources */, 23BB4D3121D775D4009B51E9 /* EventMonitor.swift in Sources */, - 0B99C5FC2577FC9200021578 /* ScrollPoster.swift in Sources */, 22816CFF1E2B31020020D6B1 /* MonitorWindowController.swift in Sources */, 234B5EB723506D1F00233097 /* StatusItemMainPanelViewController.swift in Sources */, 22F4EFEF1E325C36009EED31 /* PreferencesTabViewController.swift in Sources */, @@ -444,6 +447,7 @@ 23E9673F23613D1100E652F6 /* PreferencesExceptionInputViewController.swift in Sources */, 232E50A7236B372100265C58 /* PreferencesAdvanceWithApplicationViewController.swift in Sources */, 22A32B331E334B2E00A5CF38 /* PreferencesAboutViewController.swift in Sources */, + 6D6893ED2D101933003CE1BF /* ScrollPoster.swift in Sources */, 0BE4C93B20617C6E0001EA0E /* ScrollFilter.swift in Sources */, 0B6D3B682041A790004CC064 /* WindowManager.swift in Sources */, 0B12EF1A203AD9C80058B169 /* Options.swift in Sources */, @@ -623,22 +627,23 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_IDENTITY = "-"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2022.10.08; + CURRENT_PROJECT_VERSION = 2024.12.17; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = 2H959AEV62; + DEVELOPMENT_TEAM = KN2ZDPF9SC; ENABLE_HARDENED_RUNTIME = NO; INFOPLIST_FILE = Mos/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.4.1; + MACOSX_DEPLOYMENT_TARGET = 14.6; + MARKETING_VERSION = 5.0.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.caldis.Mos; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -659,22 +664,23 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_IDENTITY = "-"; - "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2022.10.08; + CURRENT_PROJECT_VERSION = 2024.12.17; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = 2H959AEV62; + DEVELOPMENT_TEAM = KN2ZDPF9SC; ENABLE_HARDENED_RUNTIME = NO; GCC_OPTIMIZATION_LEVEL = fast; INFOPLIST_FILE = Mos/Info.plist; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); - MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.4.1; + MACOSX_DEPLOYMENT_TARGET = 14.6; + MARKETING_VERSION = 5.0.0; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.caldis.Mos; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Mos/ScrollCore/ScrollPoster.swift b/Mos/ScrollCore/ScrollPoster.swift index 7737ce8..2cae094 100644 --- a/Mos/ScrollCore/ScrollPoster.swift +++ b/Mos/ScrollCore/ScrollPoster.swift @@ -8,16 +8,17 @@ import Cocoa +@available(macOS 14.0, *) class ScrollPoster { // 单例 static let shared = ScrollPoster() - init() { NSLog("Module initialized: ScrollPoster") } + init() { NSLog("Module initialized: ScrollPosterNew") } // 插值器 private let filter = ScrollFilter() // 发送器 - private var poster: CVDisplayLink? + private var poster: CADisplayLink? // 滚动数据 private var current = (y: 0.0, x: 0.0) // 当前滚动距离 private var delta = (y: 0.0, x: 0.0) // 滚动方向记录 @@ -27,9 +28,12 @@ class ScrollPoster { private var duration = Options.shared.scrollAdvanced.durationTransition // 外部依赖 var ref: (event: CGEvent?, proxy: CGEventTapProxy?) = (event: nil, proxy: nil) + + private var canRun = false } // MARK: - 滚动数据更新控制 +@available(macOS 14.0, *) extension ScrollPoster { func update(event: CGEvent, proxy: CGEventTapProxy, duration: Double, y: Double, x: Double, speed: Double, amplification: Double = 1) -> Self { // 更新依赖数据 @@ -84,33 +88,58 @@ extension ScrollPoster { } } -// MARK: - 插值数据发送控制 + +// MARK: - 插值数据发送控制 - 高版本 MacOS +@available(macOS 14.0, *) extension ScrollPoster { + + func createDisplayLink() { + NSLog("poster?.isPaused: \(String(describing: poster?.isPaused))") + // 还在就不用创建, isPaused 判断存在问题, 先不用, 改为每次都用新的 +// if !(poster?.isPaused ?? true) { +// return +// } + // 先销毁上一次的 + poster?.invalidate() + +// for one in NSScreen.screens { +// one.displayLink(target: self, selector: #selector(step)).add(to: .current, forMode: .eventTracking) +// } + poster = NSScreen.main?.displayLink(target: self, selector: #selector(step)) + poster?.add(to: .current, forMode: .default) + + // MacOS 14 初始化不了 +// let displaylink = CADisplayLink(target: self, +// selector: #selector(step)) +// +// displaylink.add(to: .current, +// forMode: RunLoop.Mode.default) + } + + @objc func step(displaylink: CADisplayLink) { + if canRun{ + print(displaylink.targetTimestamp) + poster = displaylink + ScrollPoster.shared.processing() + } + } + // 初始化 CVDisplayLink func create() { - // 新建一个 CVDisplayLinkSetOutputCallback 来执行循环 - CVDisplayLinkCreateWithActiveCGDisplays(&poster) - if let validPoster = poster { - CVDisplayLinkSetOutputCallback(validPoster, { (displayLink, inNow, inOutputTime, flagsIn, flagsOut, displayLinkContext) -> CVReturn in - ScrollPoster.shared.processing() - return kCVReturnSuccess - }, nil) - } + // createDisplayLink() } + // 启动事件发送器 func tryStart() { - if let validPoster = poster { - if !CVDisplayLinkIsRunning(validPoster) { - CVDisplayLinkStart(validPoster) - } - } + canRun = true + // 检查上一次事件停止了就再启动 + createDisplayLink() } // 停止事件发送器 func stop(_ phase: Phase = Phase.PauseManual) { // 停止循环 - if let validPoster = poster { - CVDisplayLinkStop(validPoster) - } + canRun = false + poster?.invalidate() // 先设置阶段为停止 ScrollPhase.shared.stop(phase) // 对于 Phase.PauseAuto, 我们在结束前额外发送一个事件来重置 Chrome 的滚动缓冲区 @@ -125,7 +154,9 @@ extension ScrollPoster { } } + // MARK: - 数据处理及发送 +@available(macOS 14.0, *) private extension ScrollPoster { // 处理滚动事件 func processing() { From cbce6a3d04ff8ccd39924bf0f184fb871e607f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=9F=E9=9B=80?= Date: Wed, 18 Dec 2024 09:54:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8C=80=E9=80=9F=E5=B9=B3=E6=BB=91-?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E8=99=9A=E6=8B=9F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 + Mos/Base.lproj/Main.storyboard | 490 ++++++++++-------- Mos/Options/ExceptionalApplication.swift | 6 + Mos/Options/Options.swift | 2 + Mos/ScrollCore/ScrollCore.swift | 5 +- Mos/ScrollCore/ScrollPoster.swift | 56 +- Mos/Utils/Constants.swift | 10 + .../PreferencesAdvanceViewController.swift | 36 ++ Mos/en.lproj/Main.strings | 2 + Mos/zh-Hans.lproj/Main.strings | 2 + Mos/zh-Hant-HK.lproj/Main.strings | 2 + Mos/zh-Hant-TW.lproj/Main.strings | 2 + Mos/zh-Hant.lproj/Main.strings | 2 + README.md | 20 + docs/resources/image/uniform-scroll.jpg | Bin 0 -> 266764 bytes 15 files changed, 418 insertions(+), 222 deletions(-) create mode 100644 docs/resources/image/uniform-scroll.jpg diff --git a/CHANGELOG.md b/CHANGELOG.md index 1108f07..54f1649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +# [5.1.0] + +- 新增匀速平滑以适配 `parallels` 虚拟机精细滚动. (原来的滚动太长了) + # [5.0.0] - 支持 MacOS 14, 解决平滑滚动时崩溃问题 diff --git a/Mos/Base.lproj/Main.storyboard b/Mos/Base.lproj/Main.storyboard index 19d5807..c858afb 100644 --- a/Mos/Base.lproj/Main.storyboard +++ b/Mos/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -77,33 +77,33 @@ - + @@ -111,7 +111,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -365,7 +365,7 @@ - + @@ -378,19 +378,19 @@ - + @@ -400,18 +400,18 @@ - + @@ -425,7 +425,7 @@ - + @@ -438,19 +438,19 @@ - + @@ -460,33 +460,33 @@ - + @@ -581,7 +581,7 @@ - + @@ -589,7 +589,7 @@ - + @@ -597,7 +597,7 @@ - + @@ -619,7 +619,7 @@ - + @@ -627,7 +627,7 @@ - + @@ -636,7 +636,7 @@ - + @@ -644,7 +644,7 @@ - + @@ -653,7 +653,7 @@ - + @@ -661,7 +661,7 @@ - + @@ -671,19 +671,19 @@ - + @@ -693,14 +693,14 @@ @@ -1048,16 +1048,16 @@ - - - + @@ -1439,10 +1439,54 @@ Gw - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1455,9 +1499,6 @@ Gw - - - @@ -1482,11 +1523,14 @@ Gw + + + - + @@ -1494,7 +1538,7 @@ Gw - + @@ -1507,9 +1551,6 @@ Gw - - - @@ -1534,11 +1575,14 @@ Gw + + + - + @@ -1546,7 +1590,7 @@ Gw - + @@ -1559,9 +1603,6 @@ Gw - - - @@ -1586,11 +1627,14 @@ Gw + + + - + @@ -1604,7 +1648,7 @@ Gw - + @@ -1626,7 +1670,7 @@ Gw - + @@ -1651,7 +1695,7 @@ Gw - + @@ -1659,7 +1703,7 @@ Gw - + @@ -1677,7 +1721,7 @@ Gw - + @@ -1703,7 +1747,7 @@ Gw - + @@ -1711,7 +1755,7 @@ Gw - + @@ -1729,7 +1773,7 @@ Gw - + @@ -1752,7 +1796,7 @@ Gw - + @@ -1760,7 +1804,7 @@ Gw - - - - - @@ -2412,13 +2468,13 @@ Gw - + @@ -2970,7 +3026,7 @@ Path: - - + @@ -3034,7 +3090,7 @@ Path: - -