feat: allow cursor follow focus behavior
This commit is contained in:
1 parent
f5fc5ba813
commit
be50758451
5 files changed
+38
-6
No files matched your search
@@ -37,6 +37,12 @@
|
|||||||
/* No comment provided by engineer. */
|
/* No comment provided by engineer. */
|
||||||
"Also select windows using:" = "Also select windows using:";
|
"Also select windows using:" = "Also select windows using:";
|
||||||
|
|
||||||
|
/* No comment provided by engineer. */
|
||||||
|
"Miscellaneous:" = "Miscellaneous:";
|
||||||
|
|
||||||
|
/* No comment provided by engineer. */
|
||||||
|
"Cursor follows focus" = "Cursor follows focus"
|
||||||
|
|
||||||
/* No comment provided by engineer. */
|
/* No comment provided by engineer. */
|
||||||
"AltTab crashed last time you used it. Sending a crash report will help get the issue fixed" = "AltTab crashed last time you used it. Sending a crash report will help get the issue fixed";
|
"AltTab crashed last time you used it. Sending a crash report will help get the issue fixed" = "AltTab crashed last time you used it. Sending a crash report will help get the issue fixed";
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,12 @@
|
|||||||
/*No comment provided by engineer.*/
|
/*No comment provided by engineer.*/
|
||||||
"Also select windows using:" = "Also select windows using:";
|
"Also select windows using:" = "Also select windows using:";
|
||||||
|
|
||||||
|
/* No comment provided by engineer. */
|
||||||
|
"Miscellaneous:" = "Miscellaneous:";
|
||||||
|
|
||||||
|
/* No comment provided by engineer. */
|
||||||
|
"Cursor follows focus" = "Cursor follows focus"
|
||||||
|
|
||||||
/*No comment provided by engineer.*/
|
/*No comment provided by engineer.*/
|
||||||
"AltTab crashed last time you used it. Sending a crash report will help get the issue fixed" = "AltTab crashed last time you used it. Sending a crash report will help get the issue fixed";
|
"AltTab crashed last time you used it. Sending a crash report will help get the issue fixed" = "AltTab crashed last time you used it. Sending a crash report will help get the issue fixed";
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class Preferences {
|
|||||||
"hideShowAppShortcut": "H",
|
"hideShowAppShortcut": "H",
|
||||||
"arrowKeysEnabled": "true",
|
"arrowKeysEnabled": "true",
|
||||||
"mouseHoverEnabled": "true",
|
"mouseHoverEnabled": "true",
|
||||||
|
"cursorFollowFocusEnabled": "false",
|
||||||
"showMinimizedWindows": ShowHowPreference.show.rawValue,
|
"showMinimizedWindows": ShowHowPreference.show.rawValue,
|
||||||
"showMinimizedWindows2": ShowHowPreference.show.rawValue,
|
"showMinimizedWindows2": ShowHowPreference.show.rawValue,
|
||||||
"showHiddenWindows": ShowHowPreference.show.rawValue,
|
"showHiddenWindows": ShowHowPreference.show.rawValue,
|
||||||
@@ -90,6 +91,7 @@ class Preferences {
|
|||||||
static var hideShowAppShortcut: String { defaults.string("hideShowAppShortcut") }
|
static var hideShowAppShortcut: String { defaults.string("hideShowAppShortcut") }
|
||||||
static var arrowKeysEnabled: Bool { defaults.bool("arrowKeysEnabled") }
|
static var arrowKeysEnabled: Bool { defaults.bool("arrowKeysEnabled") }
|
||||||
static var mouseHoverEnabled: Bool { defaults.bool("mouseHoverEnabled") }
|
static var mouseHoverEnabled: Bool { defaults.bool("mouseHoverEnabled") }
|
||||||
|
static var cursorFollowFocusEnabled: Bool { defaults.bool("cursorFollowFocusEnabled") }
|
||||||
static var showTabsAsWindows: Bool { defaults.bool("showTabsAsWindows") }
|
static var showTabsAsWindows: Bool { defaults.bool("showTabsAsWindows") }
|
||||||
static var hideColoredCircles: Bool { defaults.bool("hideColoredCircles") }
|
static var hideColoredCircles: Bool { defaults.bool("hideColoredCircles") }
|
||||||
static var windowDisplayDelay: DispatchTimeInterval { DispatchTimeInterval.milliseconds(defaults.int("windowDisplayDelay")) }
|
static var windowDisplayDelay: DispatchTimeInterval { DispatchTimeInterval.milliseconds(defaults.int("windowDisplayDelay")) }
|
||||||
|
|||||||
+17
-3
@@ -189,10 +189,24 @@ class App: AppCenterApplication, NSApplicationDelegate {
|
|||||||
KeyRepeatTimer.toggleRepeatingKeyPreviousWindow()
|
KeyRepeatTimer.toggleRepeatingKeyPreviousWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
func focusSelectedWindow(_ window: Window?) {
|
func focusSelectedWindow(_ selectedWindow: Window?) {
|
||||||
hideUi()
|
hideUi()
|
||||||
guard !CGWindow.isMissionControlActive() else { return }
|
guard let window = selectedWindow, !CGWindow.isMissionControlActive() else { return }
|
||||||
window?.focus()
|
window.focus()
|
||||||
|
if Preferences.cursorFollowFocusEnabled {
|
||||||
|
moveCursorToSelectedWindow(window)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func moveCursorToSelectedWindow(_ window: Window) {
|
||||||
|
guard let position = window.position, let size = window.size else { return }
|
||||||
|
|
||||||
|
let point = CGPoint(
|
||||||
|
x: position.x + size.width / 2,
|
||||||
|
y: position.y + size.height / 2
|
||||||
|
)
|
||||||
|
|
||||||
|
CGWarpMouseCursorPosition(point)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reopenUi() {
|
func reopenUi() {
|
||||||
|
|||||||
@@ -32,8 +32,11 @@ class ControlsTab {
|
|||||||
let hideShowAppShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Hide/Show app", comment: ""), "hideShowAppShortcut", Preferences.hideShowAppShortcut, labelPosition: .right)
|
let hideShowAppShortcut = LabelAndControl.makeLabelWithRecorder(NSLocalizedString("Hide/Show app", comment: ""), "hideShowAppShortcut", Preferences.hideShowAppShortcut, labelPosition: .right)
|
||||||
let enableArrows = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Arrow keys", comment: ""), "arrowKeysEnabled", extraAction: ControlsTab.arrowKeysEnabledCallback, labelPosition: .right)
|
let enableArrows = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Arrow keys", comment: ""), "arrowKeysEnabled", extraAction: ControlsTab.arrowKeysEnabledCallback, labelPosition: .right)
|
||||||
let enableMouse = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Mouse hover", comment: ""), "mouseHoverEnabled", labelPosition: .right)
|
let enableMouse = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Mouse hover", comment: ""), "mouseHoverEnabled", labelPosition: .right)
|
||||||
let checkboxesExplanations = LabelAndControl.makeLabel(NSLocalizedString("Also select windows using:", comment: ""))
|
let enableCursorFollowFocus = LabelAndControl.makeLabelWithCheckbox(NSLocalizedString("Cursor follows focus", comment: ""), "cursorFollowFocusEnabled", labelPosition: .right)
|
||||||
let checkboxes = StackView([StackView(enableArrows), StackView(enableMouse)], .vertical)
|
let selectWindowcheckboxesExplanations = LabelAndControl.makeLabel(NSLocalizedString("Also select windows using:", comment: ""))
|
||||||
|
let selectWindowCheckboxes = StackView([StackView(enableArrows), StackView(enableMouse)], .vertical)
|
||||||
|
let miscCheckboxesExplanations = LabelAndControl.makeLabel(NSLocalizedString("Miscellaneous:", comment: ""))
|
||||||
|
let miscCheckboxes = StackView([StackView(enableCursorFollowFocus)], .vertical)
|
||||||
let shortcuts = StackView([focusWindowShortcut, previousWindowShortcut, cancelShortcut, closeWindowShortcut, minDeminWindowShortcut, quitAppShortcut, hideShowAppShortcut].map { (view: [NSView]) in StackView(view) }, .vertical)
|
let shortcuts = StackView([focusWindowShortcut, previousWindowShortcut, cancelShortcut, closeWindowShortcut, minDeminWindowShortcut, quitAppShortcut, hideShowAppShortcut].map { (view: [NSView]) in StackView(view) }, .vertical)
|
||||||
let orPress = LabelAndControl.makeLabel(NSLocalizedString("While open, press:", comment: ""), shouldFit: false)
|
let orPress = LabelAndControl.makeLabel(NSLocalizedString("While open, press:", comment: ""), shouldFit: false)
|
||||||
let (holdShortcut, nextWindowShortcut, tab1View) = toShowSection("")
|
let (holdShortcut, nextWindowShortcut, tab1View) = toShowSection("")
|
||||||
@@ -48,7 +51,8 @@ class ControlsTab {
|
|||||||
let grid = GridView([
|
let grid = GridView([
|
||||||
[tabView],
|
[tabView],
|
||||||
[orPress, shortcuts],
|
[orPress, shortcuts],
|
||||||
[checkboxesExplanations, checkboxes],
|
[selectWindowcheckboxesExplanations, selectWindowCheckboxes],
|
||||||
|
[miscCheckboxesExplanations, miscCheckboxes]
|
||||||
])
|
])
|
||||||
grid.column(at: 0).xPlacement = .trailing
|
grid.column(at: 0).xPlacement = .trailing
|
||||||
grid.mergeCells(inHorizontalRange: NSRange(location: 0, length: 2), verticalRange: NSRange(location: 0, length: 1))
|
grid.mergeCells(inHorizontalRange: NSRange(location: 0, length: 2), verticalRange: NSRange(location: 0, length: 1))
|
||||||
|
|||||||
Reference in new issue
Block a user