This commit is contained in:
parent
94d44fefd2
commit
f455af4541
2 changed files with 47 additions and 4 deletions
|
|
@ -171,6 +171,7 @@ final class SidebarState: ObservableObject {
|
||||||
final class FileDropOverlayView: NSView {
|
final class FileDropOverlayView: NSView {
|
||||||
/// Fallback handler when no terminal is found under the drop point.
|
/// Fallback handler when no terminal is found under the drop point.
|
||||||
var onDrop: (([URL]) -> Bool)?
|
var onDrop: (([URL]) -> Bool)?
|
||||||
|
private var isForwardingMouseEvent = false
|
||||||
|
|
||||||
override var acceptsFirstResponder: Bool { false }
|
override var acceptsFirstResponder: Bool { false }
|
||||||
|
|
||||||
|
|
@ -207,12 +208,19 @@ final class FileDropOverlayView: NSView {
|
||||||
// window.sendEvent(), which caches the mouse target and causes infinite recursion.
|
// window.sendEvent(), which caches the mouse target and causes infinite recursion.
|
||||||
|
|
||||||
private func forwardEvent(_ event: NSEvent) {
|
private func forwardEvent(_ event: NSEvent) {
|
||||||
|
guard !isForwardingMouseEvent else { return }
|
||||||
guard let window, let contentView = window.contentView else { return }
|
guard let window, let contentView = window.contentView else { return }
|
||||||
|
|
||||||
|
isForwardingMouseEvent = true
|
||||||
isHidden = true
|
isHidden = true
|
||||||
|
defer {
|
||||||
|
isHidden = false
|
||||||
|
isForwardingMouseEvent = false
|
||||||
|
}
|
||||||
|
|
||||||
let point = contentView.convert(event.locationInWindow, from: nil)
|
let point = contentView.convert(event.locationInWindow, from: nil)
|
||||||
let target = contentView.hitTest(point)
|
let target = contentView.hitTest(point)
|
||||||
isHidden = false
|
guard let target, target !== self else { return }
|
||||||
guard let target else { return }
|
|
||||||
|
|
||||||
switch event.type {
|
switch event.type {
|
||||||
case .leftMouseDown: target.mouseDown(with: event)
|
case .leftMouseDown: target.mouseDown(with: event)
|
||||||
|
|
@ -273,9 +281,9 @@ final class FileDropOverlayView: NSView {
|
||||||
|
|
||||||
guard let window, let contentView = window.contentView else { return nil }
|
guard let window, let contentView = window.contentView else { return nil }
|
||||||
isHidden = true
|
isHidden = true
|
||||||
|
defer { isHidden = false }
|
||||||
let point = contentView.convert(windowPoint, from: nil)
|
let point = contentView.convert(windowPoint, from: nil)
|
||||||
let hitView = contentView.hitTest(point)
|
let hitView = contentView.hitTest(point)
|
||||||
isHidden = false
|
|
||||||
|
|
||||||
var current: NSView? = hitView
|
var current: NSView? = hitView
|
||||||
while let view = current {
|
while let view = current {
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,34 @@ up?.post(tap: .cghidEventTap)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def post_scroll_with_cgevent(x: float, y: float, delta_y: int = 3) -> None:
|
||||||
|
ix = int(round(x))
|
||||||
|
iy = int(round(y))
|
||||||
|
code = f"""
|
||||||
|
import CoreGraphics
|
||||||
|
let p = CGPoint(x: {ix}, y: {iy})
|
||||||
|
let source = CGEventSource(stateID: .hidSystemState)
|
||||||
|
if let scroll = CGEvent(
|
||||||
|
scrollWheelEvent2Source: source,
|
||||||
|
units: .line,
|
||||||
|
wheelCount: 1,
|
||||||
|
wheel1: Int32({delta_y}),
|
||||||
|
wheel2: 0,
|
||||||
|
wheel3: 0
|
||||||
|
) {{
|
||||||
|
scroll.location = p
|
||||||
|
scroll.post(tap: .cghidEventTap)
|
||||||
|
}}
|
||||||
|
"""
|
||||||
|
subprocess.run(
|
||||||
|
["swift", "-e", code],
|
||||||
|
check=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=10,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pick_top_bottom_terminal_panels(layout: dict) -> tuple[dict, dict]:
|
def pick_top_bottom_terminal_panels(layout: dict) -> tuple[dict, dict]:
|
||||||
candidates = []
|
candidates = []
|
||||||
for panel in layout.get("selectedPanels", []):
|
for panel in layout.get("selectedPanels", []):
|
||||||
|
|
@ -282,7 +310,14 @@ def main() -> int:
|
||||||
print("FAIL: real right click disrupted terminal focus routing")
|
print("FAIL: real right click disrupted terminal focus routing")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
print("PASS: stale file-drag overlay forwards real left/right clicks")
|
for _ in range(6):
|
||||||
|
post_scroll_with_cgevent(click_x, click_y, delta_y=2)
|
||||||
|
time.sleep(0.25)
|
||||||
|
if not client.is_terminal_focused(bottom_id):
|
||||||
|
print("FAIL: real scroll wheel disrupted terminal focus routing")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
print("PASS: stale file-drag overlay forwards real left/right clicks and scroll")
|
||||||
print(f" focused_panel={bottom_id}")
|
print(f" focused_panel={bottom_id}")
|
||||||
return 0
|
return 0
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue