feat: bring back the cursor follow focus feature (#3882)
This commit is contained in:
1 parent
9bafd037c3
commit
73382db4a2
4 files changed
+31
-5
No files matched your search
@@ -151,6 +151,9 @@
|
||||
/* No comment provided by engineer. */
|
||||
"Crash reports policy" = "Crash reports policy";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Cursor follows focus" = "Cursor follows focus";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Customize App Icons style…" = "Customize App Icons style…";
|
||||
|
||||
@@ -265,6 +268,9 @@
|
||||
/* No comment provided by engineer. */
|
||||
"Minimize/Deminimize window" = "Minimize/Deminimize window";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Miscellaneous" = "Miscellaneous";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Multiple screens" = "Multiple screens";
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class Preferences {
|
||||
"arrowKeysEnabled": "true",
|
||||
"vimKeysEnabled": "false",
|
||||
"mouseHoverEnabled": "false",
|
||||
"cursorFollowFocusEnabled": "false",
|
||||
"showMinimizedWindows": ShowHowPreference.show.indexAsString,
|
||||
"showMinimizedWindows2": ShowHowPreference.show.indexAsString,
|
||||
"showMinimizedWindows3": ShowHowPreference.show.indexAsString,
|
||||
@@ -117,6 +118,7 @@ class Preferences {
|
||||
// periphery:ignore
|
||||
static var vimKeysEnabled: Bool { UserDefaults.standard.bool("vimKeysEnabled") }
|
||||
static var mouseHoverEnabled: Bool { UserDefaults.standard.bool("mouseHoverEnabled") }
|
||||
static var cursorFollowFocusEnabled: Bool { UserDefaults.standard.bool("cursorFollowFocusEnabled") }
|
||||
static var showTabsAsWindows: Bool { UserDefaults.standard.bool("showTabsAsWindows") }
|
||||
static var hideColoredCircles: Bool { UserDefaults.standard.bool("hideColoredCircles") }
|
||||
static var windowDisplayDelay: DispatchTimeInterval { DispatchTimeInterval.milliseconds(UserDefaults.standard.int("windowDisplayDelay")) }
|
||||
|
||||
@@ -234,11 +234,21 @@ class App: AppCenterApplication, NSApplicationDelegate {
|
||||
hideUi(true)
|
||||
if let window = selectedWindow, MissionControl.state() == .inactive {
|
||||
window.focus()
|
||||
if Preferences.cursorFollowFocusEnabled {
|
||||
moveCursorToSelectedWindow(window)
|
||||
}
|
||||
} else {
|
||||
previewPanel.orderOut(nil)
|
||||
}
|
||||
}
|
||||
|
||||
func moveCursorToSelectedWindow(_ window: Window) {
|
||||
let referenceWindow = window.referenceWindowForTabbedWindow()
|
||||
guard let position = referenceWindow?.position, let size = referenceWindow?.size else { return }
|
||||
let point = CGPoint(x: position.x + size.width / 2, y: position.y + size.height / 2)
|
||||
CGWarpMouseCursorPosition(point)
|
||||
}
|
||||
|
||||
func refreshOpenUi(_ windowsToUpdate: [Window]? = nil) {
|
||||
guard appIsBeingUsed else { return }
|
||||
let currentScreen = NSScreen.preferred() // fix screen between steps since it could change (e.g. mouse moved to another screen)
|
||||
|
||||
@@ -8,17 +8,25 @@ class AdditionalControlsSheet: SheetWindow {
|
||||
rightViews: [LabelAndControl.makeSwitch("vimKeysEnabled", extraAction: ControlsTab.vimKeysEnabledCallback)])
|
||||
let enableMouse = TableGroupView.Row(leftTitle: NSLocalizedString("Select windows on mouse hover", comment: ""),
|
||||
rightViews: [LabelAndControl.makeSwitch("mouseHoverEnabled")])
|
||||
let enableCursorFollowFocus = TableGroupView.Row(leftTitle: NSLocalizedString("Cursor follows focus", comment: ""),
|
||||
rightViews: [LabelAndControl.makeSwitch("cursorFollowFocusEnabled")])
|
||||
|
||||
ControlsTab.arrowKeysCheckbox = enableArrows.rightViews[0] as? Switch
|
||||
ControlsTab.vimKeysCheckbox = enableVimKeys.rightViews[0] as? Switch
|
||||
ControlsTab.arrowKeysEnabledCallback(ControlsTab.arrowKeysCheckbox)
|
||||
ControlsTab.vimKeysEnabledCallback(ControlsTab.vimKeysCheckbox)
|
||||
|
||||
let table = TableGroupView(title: NSLocalizedString("Additional controls", comment: ""),
|
||||
let table1 = TableGroupView(title: NSLocalizedString("Additional controls", comment: ""),
|
||||
width: PreferencesWindow.width)
|
||||
_ = table.addRow(enableArrows)
|
||||
_ = table.addRow(enableVimKeys)
|
||||
_ = table.addRow(enableMouse)
|
||||
return table
|
||||
_ = table1.addRow(enableArrows)
|
||||
_ = table1.addRow(enableVimKeys)
|
||||
_ = table1.addRow(enableMouse)
|
||||
|
||||
let table2 = TableGroupView(title: NSLocalizedString("Miscellaneous", comment: ""),
|
||||
width: PreferencesWindow.width)
|
||||
_ = table2.addRow(enableCursorFollowFocus)
|
||||
|
||||
let view = TableGroupSetView(originalViews: [table1, table2], padding: 0)
|
||||
return view
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user