Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Loop/Extensions/Defaults+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension Defaults.Keys {
static let enablePadding = Key<Bool>("enablePadding", default: false)
static let padding = Key<PaddingModel>("padding", default: .zero)
static let useScreenWithCursor = Key<Bool>("useScreenWithCursor", default: true)
static let moveCursorWithWindow = Key<Bool>("moveCursorWithWindow", default: false)
static let resizeWindowUnderCursor = Key<Bool>("resizeWindowUnderCursor", default: false)
static let focusWindowOnResize = Key<Bool>("focusWindowOnResize", default: true)
static let respectStageManager = Key<Bool>("respectStageManager", default: true)
Expand Down
6 changes: 6 additions & 0 deletions Loop/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@
}
}
}
},
"Cannot be enabled when the preview is disabled." : {

},
"Change" : {

Expand Down Expand Up @@ -1483,6 +1486,9 @@
}
}
}
},
"Move cursor with window" : {

},
"Name" : {
"extractionState" : "stale",
Expand Down
14 changes: 14 additions & 0 deletions Loop/Luminare/Settings/Behavior/BehaviorConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class BehaviorConfigurationModel: ObservableObject {
}
}

@Published var moveCursorWithWindow = Defaults[.moveCursorWithWindow] {
didSet {
Defaults[.moveCursorWithWindow] = moveCursorWithWindow
}
}

@Published var resizeWindowUnderCursor = Defaults[.resizeWindowUnderCursor] {
didSet {
Defaults[.resizeWindowUnderCursor] = resizeWindowUnderCursor
Expand All @@ -84,6 +90,8 @@ class BehaviorConfigurationModel: ObservableObject {
}

@Published var isPaddingConfigurationViewPresented = false

let previewVisibility = Defaults[.previewVisibility]
}

struct BehaviorConfigurationView: View {
Expand Down Expand Up @@ -120,6 +128,12 @@ struct BehaviorConfigurationView: View {

LuminareSection("Cursor") {
LuminareToggle("Use screen with cursor", isOn: $model.useScreenWithCursor)
LuminareToggle(
"Move cursor with window",
info: model.previewVisibility ? nil : .init("Cannot be enabled when the preview is disabled."),
isOn: $model.moveCursorWithWindow,
disabled: !model.previewVisibility
)
LuminareToggle("Resize window under cursor", isOn: $model.resizeWindowUnderCursor.animation(.smooth(duration: 0.25)))

if model.resizeWindowUnderCursor {
Expand Down
5 changes: 5 additions & 0 deletions Loop/Luminare/Theming/PreviewConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class PreviewConfigurationModel: ObservableObject {
@Published var previewVisibility = Defaults[.previewVisibility] {
didSet {
Defaults[.previewVisibility] = previewVisibility

// We can't move the cursor with the window if the window is going to be moving everywhere
if !previewVisibility {
Defaults[.moveCursorWithWindow] = false
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Loop/Window Management/WindowEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ enum WindowEngine {

WindowEngine.handleSizeConstrainedWindow(window: window, screenFrame: screen.safeScreenFrame)
}

if Defaults[.moveCursorWithWindow] {
CGWarpMouseCursorPosition(targetFrame.center)
}
}

static func getTargetWindow() -> Window? {
Expand Down