From 23502a8816a07a10917abd2ee77854083d857ca6 Mon Sep 17 00:00:00 2001 From: millia ampora <198710911+dappermint@users.noreply.github.com> Date: Fri, 30 Oct 2026 13:53:40 +0400 Subject: [PATCH 1/2] perf(surface): skip ordering out a parking edge fin that is already hidden every full surface reconcile reapplies the parking edge masks, and a mask with no navigation target hides its fin. hide() called orderOut on a fin that was never shown or already hidden, and inside OmniWM that runs a full AppKit window ordering transaction against the WindowServer each time. a sample of 20 focus plus workspace switch round trips on Dev put 29 main thread samples (about 3% of the busy main thread) under that orderOut. guard on isVisible so only a visible fin gets ordered out. the dwell progress still resets either way. --- .../OmniWM/Core/Surface/ParkingEdgeFin.swift | 1 + Tests/OmniWMTests/ParkingEdgeMaskTests.swift | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Sources/OmniWM/Core/Surface/ParkingEdgeFin.swift b/Sources/OmniWM/Core/Surface/ParkingEdgeFin.swift index 258a49b05..af5254550 100644 --- a/Sources/OmniWM/Core/Surface/ParkingEdgeFin.swift +++ b/Sources/OmniWM/Core/Surface/ParkingEdgeFin.swift @@ -93,6 +93,7 @@ final class ParkingEdgeFinWindow: NSPanel { func hide() { finView.reset() + guard isVisible else { return } orderOut(nil) } diff --git a/Tests/OmniWMTests/ParkingEdgeMaskTests.swift b/Tests/OmniWMTests/ParkingEdgeMaskTests.swift index 1b399eef4..116cc2170 100644 --- a/Tests/OmniWMTests/ParkingEdgeMaskTests.swift +++ b/Tests/OmniWMTests/ParkingEdgeMaskTests.swift @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (C) 2026 OmniNull — https://github.com/OmniNull/OmniWM +import AppKit @testable import OmniWM import XCTest @@ -231,6 +232,32 @@ final class ParkingEdgeMaskTests: XCTestCase { XCTAssertFalse(SurfaceCoordinator.shared.visibleSurfaceIDs().contains(surfaceId)) } + @MainActor + func testHidingAHiddenFinDoesNotOrderItOutAgain() { + let key = ParkingEdgeMaskKey(monitorId: Monitor.ID(displayId: 95_004), side: .left) + let fin = ParkingEdgeFinWindow(key: key, onHoverChange: {}, onActivate: {}) + defer { fin.destroy() } + var orderOuts = 0 + let observer = NotificationCenter.default.addObserver( + forName: NSNotification.Name("NSWindowDidOrderOffScreenAndFinishAnimatingNotification"), + object: fin, + queue: nil + ) { _ in MainActor.assumeIsolated { orderOuts += 1 } } + defer { NotificationCenter.default.removeObserver(observer) } + + fin.hide() + XCTAssertEqual(orderOuts, 0) + + let mask = CGRect(x: 91_000, y: 92_000, width: 1, height: 800) + fin.show(at: CGPoint(x: 91_000.5, y: 92_400), maskFrame: mask, animated: false) + XCTAssertTrue(fin.isVisible) + fin.hide() + XCTAssertFalse(fin.isVisible) + XCTAssertEqual(orderOuts, 1) + fin.hide() + XCTAssertEqual(orderOuts, 1) + } + private func makeTopology(first: Monitor, second: Monitor, firstIsFullscreen: Bool) -> SpaceTopology { SpaceTopology( displays: [ From 88698a41c08d3510aeee8ec898e0c00df6f877fa Mon Sep 17 00:00:00 2001 From: millia ampora <198710911+dappermint@users.noreply.github.com> Date: Fri, 30 Oct 2026 17:45:12 +0400 Subject: [PATCH 2/2] test(surface): check hiding a hidden fin clears dwell progress hide() resets the fin view before the isVisible guard so an armed dwell animation is dropped even when there is nothing to order out. nothing asserted that, so the guard could have moved above the reset unnoticed. --- Tests/OmniWMTests/ParkingEdgeMaskTests.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Tests/OmniWMTests/ParkingEdgeMaskTests.swift b/Tests/OmniWMTests/ParkingEdgeMaskTests.swift index 116cc2170..38fc31064 100644 --- a/Tests/OmniWMTests/ParkingEdgeMaskTests.swift +++ b/Tests/OmniWMTests/ParkingEdgeMaskTests.swift @@ -244,8 +244,14 @@ final class ParkingEdgeMaskTests: XCTestCase { queue: nil ) { _ in MainActor.assumeIsolated { orderOuts += 1 } } defer { NotificationCenter.default.removeObserver(observer) } + let dwellArmed = { + fin.contentView?.layer?.sublayers?.contains { $0.animation(forKey: "parkingEdge.dwell") != nil } == true + } + fin.setProgress(duration: 1.5) + XCTAssertTrue(dwellArmed()) fin.hide() + XCTAssertFalse(dwellArmed()) XCTAssertEqual(orderOuts, 0) let mask = CGRect(x: 91_000, y: 92_000, width: 1, height: 800)