fix: align action popup background with launcher

This commit is contained in:
2026-10-17 00:35:35 +02:00
parent a891d49bb1
commit 8766584fe3
4 changed files with 49 additions and 6 deletions
@@ -0,0 +1,31 @@
import AppKit
import ConjureKit
import Testing
@testable import Conjure
@Test @MainActor func actionsBackgroundKeepsWindowCoordinates() throws {
_ = NSApplication.shared
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 750, height: 480),
styleMask: [.borderless], backing: .buffered, defer: false)
let host = try #require(window.contentView)
let anchor = NSView(frame: NSRect(x: 700, y: 20, width: 30, height: 30))
host.addSubview(anchor)
let actions = ApplicationActionsController()
defer { actions.close(animated: false) }
func descendants(_ view: NSView) -> [NSView] { [view] + view.subviews.flatMap(descendants) }
for width in [750.0, 900.0] {
window.setContentSize(NSSize(width: width, height: 480))
actions.showEmoji(named: "Smile", relativeTo: anchor)
let background = try #require(descendants(host).compactMap { $0 as? LauncherBackground }.first)
let search = try #require(descendants(actions.view).compactMap { $0 as? NSSearchField }.first)
for query in ["", "Copy Emoji", "no matching action"] {
search.stringValue = query
actions.controlTextDidChange(Notification(name: NSControl.textDidChangeNotification, object: search))
host.layoutSubtreeIfNeeded()
let rect = background.convert(background.bounds, to: host)
#expect(rect == host.bounds)
#expect(background.bounds.size != actions.view.bounds.size)
}
actions.close(animated: false)
}
}