perf(menubar): 降低绘制驻留并复用原生进程表与缩略图
This commit is contained in:
@@ -17,10 +17,20 @@ import AppKit
|
||||
NSApp.terminate(nil)
|
||||
return
|
||||
}
|
||||
@MainActor func plots(in view: NSView?) -> [NativePanelCurve.PlotView] {
|
||||
guard let view else { return [] }
|
||||
let own = (view as? NativePanelCurve.PlotView).map { [$0] } ?? []
|
||||
return own + view.subviews.flatMap { plots(in: $0) }
|
||||
}
|
||||
@MainActor func mark(_ event: String) {
|
||||
var report = metrics.snapshot
|
||||
report.processes = metrics.processSnapshot
|
||||
SamplingDiagnostics.record(report, event: "audit." + event, hiddenHostAlive: controller.lastHiddenContent != nil)
|
||||
let views = plots(in: controller.panel.contentView)
|
||||
SamplingDiagnostics.record(report, event: "audit." + event, hiddenHostAlive: controller.lastHiddenContent != nil,
|
||||
windowNumber: controller.panel.isVisible ? controller.panel.windowNumber : nil,
|
||||
hoveredPlots: views.filter { $0.input?.hoveredIndex != nil }.count, nativePlots: views.count,
|
||||
pointerInsidePanel: controller.panel.isVisible && controller.panel.frame.contains(NSEvent.mouseLocation),
|
||||
plotBounds: views.map { [Double($0.bounds.width), Double($0.bounds.height)] })
|
||||
}
|
||||
func wait(_ seconds: Int) async { try? await Task.sleep(for: .seconds(seconds)) }
|
||||
// Pin the test window so unrelated focus changes cannot invalidate a measurement.
|
||||
|
||||
Reference in New Issue
Block a user