Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Nov 11, 2023
1 parent a8babaa commit e139290
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/mouse/moveWithMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ private func moveFloatingWindow(_ window: Window) {

private func moveTilingWindow(_ window: Window) {
currentlyManipulatedWithMouseWindowId = window.windowId
window.lastAppliedLayoutRect = nil
window.lastAppliedLayoutTilingRectForMouse = nil
let mouseLocation = mouseLocation
let targetWorkspace = mouseLocation.monitorApproximation.activeWorkspace
let swapTarget = mouseLocation.findIn(tree: targetWorkspace.workspace.rootTilingContainer)?.takeIf({ $0 != window })
if targetWorkspace != window.workspace { // Move window to a different display
let index: Int
if let swapTarget, let parent = swapTarget.parent as? TilingContainer, let targetRect = swapTarget.lastAppliedLayoutRect {
if let swapTarget, let parent = swapTarget.parent as? TilingContainer, let targetRect = swapTarget.lastAppliedLayoutTilingRectForMouse {
index = mouseLocation.getProjection(parent.orientation) >= targetRect.center.getProjection(parent.orientation)
? swapTarget.ownIndex + 1
: swapTarget.ownIndex
Expand Down Expand Up @@ -78,7 +78,7 @@ extension CGPoint {
let target: TreeNode?
switch tree.layout {
case .list:
target = tree.children.first(where: { $0.lastAppliedLayoutRect?.contains(point) == true })
target = tree.children.first(where: { $0.lastAppliedLayoutTilingRectForMouse?.contains(point) == true })
case .accordion:
target = tree.mostRecentChild
}
Expand Down
4 changes: 2 additions & 2 deletions src/mouse/resizeWithMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private func resizeWithMouseIfTheCase(_ window: Window) { // todo cover with tes
return // Nothing to do for floating windows
case .tilingContainer:
guard let rect = window.getRect() else { return }
guard let lastAppliedLayoutRect = window.lastAppliedLayoutRect else { return }
guard let lastAppliedLayoutRect = window.lastAppliedLayoutTilingRectForMouse else { return }
let (lParent, lOwnIndex) = window.closestParent(hasChildrenInDirection: .left, withLayout: .list) ?? (nil, nil)
let (dParent, dOwnIndex) = window.closestParent(hasChildrenInDirection: .down, withLayout: .list) ?? (nil, nil)
let (uParent, uOwnIndex) = window.closestParent(hasChildrenInDirection: .up, withLayout: .list) ?? (nil, nil)
Expand Down Expand Up @@ -66,7 +66,7 @@ private extension TreeNode {
func getWeightBeforeResize(_ orientation: Orientation) -> CGFloat {
let currentWeight = getWeight(orientation) // Check preconditions
return getUserData(key: adaptiveWeightBeforeResizeWithMouseKey)
?? (lastAppliedLayoutRect?.getDimension(orientation) ?? currentWeight)
?? (lastAppliedLayoutTilingRectForMouse?.getDimension(orientation) ?? currentWeight)
.also { putUserData(key: adaptiveWeightBeforeResizeWithMouseKey, data: $0) }
}

Expand Down
2 changes: 1 addition & 1 deletion src/tree/TreeNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TreeNode: Equatable {
var mostRecentChildren: some Sequence<TreeNode> { _mruChildren }
/// Helps to avoid flickering when cycling children of accordion container with focus command
var mostRecentChildIndexForAccordion: Int? = nil
var lastAppliedLayoutRect: Rect? = nil
var lastAppliedLayoutTilingRectForMouse: Rect? = nil

init(parent: NonLeafTreeNode, adaptiveWeight: CGFloat, index: Int) {
self.adaptiveWeight = adaptiveWeight
Expand Down
6 changes: 3 additions & 3 deletions src/tree/layoutRecursive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ extension TreeNode {
}
switch genericKind {
case .workspace(let workspace):
lastAppliedLayoutRect = rect
lastAppliedLayoutTilingRectForMouse = rect
workspace.rootTilingContainer.layoutRecursive(point, focusedWindow: focusedWindow, width: width, height: height)
case .window(let window):
if window.windowId != currentlyManipulatedWithMouseWindowId {
lastAppliedLayoutRect = rect // todo rename
lastAppliedLayoutTilingRectForMouse = rect
if window.isFullscreen && window == focusedWindow {
let monitorRect = window.workspace.monitor.visibleRect
window.setTopLeftCorner(monitorRect.topLeftCorner)
Expand All @@ -26,7 +26,7 @@ extension TreeNode {
}
}
case .tilingContainer(let container):
lastAppliedLayoutRect = rect
lastAppliedLayoutTilingRectForMouse = rect
switch container.layout {
case .list:
container.layoutList(point, focusedWindow: focusedWindow, width: width, height: height)
Expand Down

0 comments on commit e139290

Please sign in to comment.