File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ extension Window {
69
69
@MainActor // todo can be dropped in future Swift versions?
70
70
fileprivate func layoutFloatingWindow( _ context: LayoutContext ) async throws {
71
71
let workspace = context. workspace
72
- let currentMonitor = try await getCenter ( ) ? . monitorApproximation
72
+ let currentMonitor = try await getCenter ( ) ? . monitorApproximation // Probably not idempotent
73
73
if let currentMonitor, let windowTopLeftCorner = try await getAxTopLeftCorner ( ) , workspace != currentMonitor. activeWorkspace {
74
74
let xProportion = ( windowTopLeftCorner. x - currentMonitor. visibleRect. topLeftX) / currentMonitor. visibleRect. width
75
75
let yProportion = ( windowTopLeftCorner. y - currentMonitor. visibleRect. topLeftY) / currentMonitor. visibleRect. height
Original file line number Diff line number Diff line change @@ -124,18 +124,19 @@ final class MacWindow: Window {
124
124
macApp. closeAndUnregisterAxWindow ( windowId)
125
125
}
126
126
127
+ // todo it's part of the window layout and should be move to layoutRecursive.swift
127
128
@MainActor
128
129
func hideInCorner( _ corner: OptimalHideCorner ) async throws {
129
130
guard let nodeMonitor else { return }
130
131
// Don't accidentally override prevUnhiddenEmulationPosition in case of subsequent
131
132
// `hideEmulation` calls
132
133
if !isHiddenInCorner {
133
- guard let topLeftCorner = try await getAxTopLeftCorner ( ) else { return }
134
- guard let nodeWorkspace else { return } // hiding only makes sense for workspace windows
135
- let workspaceRect = nodeWorkspace . workspaceMonitor . rect
136
- let absolutePoint = topLeftCorner - workspaceRect . topLeftCorner
134
+ guard let windowRect = try await getAxRect ( ) else { return }
135
+ let topLeftCorner = windowRect . topLeftCorner
136
+ let monitorRect = windowRect . center . monitorApproximation . rect // Similar to layoutFloatingWindow. Non idempotent
137
+ let absolutePoint = topLeftCorner - monitorRect . topLeftCorner
137
138
prevUnhiddenProportionalPositionInsideWorkspaceRect =
138
- CGPoint ( x: absolutePoint. x / workspaceRect . width, y: absolutePoint. y / workspaceRect . height)
139
+ CGPoint ( x: absolutePoint. x / monitorRect . width, y: absolutePoint. y / monitorRect . height)
139
140
}
140
141
let p : CGPoint
141
142
switch corner {
You can’t perform that action at this time.
0 commit comments