Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inform the user when macOS 15 tiling is enabled #1418

Merged
merged 1 commit into from
Jul 13, 2024
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
8 changes: 8 additions & 0 deletions Rectangle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
6490B3A127BF98C70056C220 /* BottomRightEighthCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6490B3A027BF98C70056C220 /* BottomRightEighthCalculation.swift */; };
729E0A982AFF76B1006E2F48 /* CenterProminentlyCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 729E0A972AFF76B1006E2F48 /* CenterProminentlyCalculation.swift */; };
866661F2257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 866661F1257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift */; };
94E9B08E2C3B8D97004C7F41 /* MacTilingDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94E9B08D2C3B8D97004C7F41 /* MacTilingDefaults.swift */; };
94E9B0902C3E4578004C7F41 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94E9B08F2C3E4578004C7F41 /* StringExtension.swift */; };
9818E00D28B59205004AA524 /* CompoundSnapArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9818E00C28B59205004AA524 /* CompoundSnapArea.swift */; };
9818E01028B59396004AA524 /* HalvesCompoundCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9818E00F28B59396004AA524 /* HalvesCompoundCalculation.swift */; };
9818E01228B59B64004AA524 /* ThirdsCompoundCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9818E01128B59B64004AA524 /* ThirdsCompoundCalculation.swift */; };
Expand Down Expand Up @@ -185,6 +187,8 @@
6490B3A027BF98C70056C220 /* BottomRightEighthCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomRightEighthCalculation.swift; sourceTree = "<group>"; };
729E0A972AFF76B1006E2F48 /* CenterProminentlyCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenterProminentlyCalculation.swift; sourceTree = "<group>"; };
866661F1257D248A00A9CD2D /* RepeatedExecutionsInThirdsCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepeatedExecutionsInThirdsCalculation.swift; sourceTree = "<group>"; };
94E9B08D2C3B8D97004C7F41 /* MacTilingDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacTilingDefaults.swift; sourceTree = "<group>"; };
94E9B08F2C3E4578004C7F41 /* StringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
9808018523D05C0B0077774A /* RectangleRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RectangleRelease.entitlements; sourceTree = "<group>"; };
9808018623D05C1F0077774A /* RectangleLauncherRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RectangleLauncherRelease.entitlements; sourceTree = "<group>"; };
9818E00C28B59205004AA524 /* CompoundSnapArea.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompoundSnapArea.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -498,6 +502,8 @@
98BEFA472620DEDC00D9D54F /* NSImageExtension.swift */,
98192DD9270F606C00015E66 /* Debounce.swift */,
AA0ACC2E2864A86D0025E376 /* StageUtil.swift */,
94E9B08D2C3B8D97004C7F41 /* MacTilingDefaults.swift */,
94E9B08F2C3E4578004C7F41 /* StringExtension.swift */,
AAADE1AE28CBAB0000036331 /* WindowUtil.swift */,
AA4DA2FA28FDC94A00355CEB /* DispatchTimeExtension.swift */,
AA536C2629005DD000579AC6 /* TimeoutCache.swift */,
Expand Down Expand Up @@ -840,6 +846,7 @@
98A009AB2512491300CFBF0C /* CenterHalfCalculation.swift in Sources */,
9818E01828B63C48004AA524 /* FourthsCompoundCalculation.swift in Sources */,
D0CFE33327A8CCB1004DA47B /* TopRightThirdCalculation.swift in Sources */,
94E9B08E2C3B8D97004C7F41 /* MacTilingDefaults.swift in Sources */,
9821403522B38A2B00ABFB3F /* UpperRightCalculation.swift in Sources */,
984EDB0F29A42ED200D119D2 /* LaunchOnLogin.swift in Sources */,
9824702F22AFA2E50037B409 /* AccessibilityAuthorization.swift in Sources */,
Expand Down Expand Up @@ -883,6 +890,7 @@
9824703B22B139780037B409 /* CUtil.swift in Sources */,
988D067D22EB4E17004EABD7 /* AlmostMaximizeCalculation.swift in Sources */,
98C1008C2305F1FA006E5344 /* SubsequentExecutionMode.swift in Sources */,
94E9B0902C3E4578004C7F41 /* StringExtension.swift in Sources */,
6490B3A127BF98C70056C220 /* BottomRightEighthCalculation.swift in Sources */,
985B9BF922BB6F5100A2E8F0 /* MessageView.swift in Sources */,
988D066722EB4CC0004EABD7 /* LastTwoThirdsCalculation.swift in Sources */,
Expand Down
35 changes: 35 additions & 0 deletions Rectangle/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self.titleBarManager = TitleBarManager()
self.initializeTodo()
checkForProblematicApps()
checkForBuiltInTiling()
}

func checkForConflictingApps() {
Expand Down Expand Up @@ -191,6 +192,40 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

func checkForBuiltInTiling() {
guard #available(macOS 15, *), !Defaults.internalTilingNotified.enabled
else {
return
}

Defaults.internalTilingNotified.enabled = true
if MacTilingDefaults.tilingByEdgeDrag.enabled || MacTilingDefaults.tilingOptionAccelerator.enabled {
let result = AlertUtil.threeButtonAlert(
question: "Conflict with macOS tiling".localized,
text: "Drag to screen edge tiling is enabled in both Rectangle and macOS.".localized,
buttonOneText: "Disable in macOS".localized,
buttonTwoText: "Disable in Rectangle".localized,
buttonThreeText: "Dismiss".localized)
switch result {
case .alertFirstButtonReturn:
MacTilingDefaults.tilingByEdgeDrag.disable()
MacTilingDefaults.tilingOptionAccelerator.disable()

let result = AlertUtil.twoButtonAlert(
question: "Tiling in macOS has been disabled".localized,
text: "To re-enable it, go to System Settings → Desktop & Dock → Windows".localized,
cancelText: "Open System Settings".localized)
if result == .alertSecondButtonReturn {
MacTilingDefaults.openSystemSettings()
}
case .alertSecondButtonReturn:
Defaults.windowSnapping.enabled = false
default:
break
}
}
}

private func showWelcomeWindow() {
let welcomeWindowController = NSStoryboard(name: "Main", bundle: nil)
.instantiateController(withIdentifier: "WelcomeWindowController") as? NSWindowController
Expand Down
1 change: 1 addition & 0 deletions Rectangle/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class Defaults {
static let ignoreDragSnapToo = OptionalBoolDefault(key: "ignoreDragSnapToo")
static let systemWideMouseDown = OptionalBoolDefault(key: "systemWideMouseDown")
static let systemWideMouseDownApps = JSONDefault<Set<String>>(key:"systemWideMouseDownApps", defaultValue: Set<String>(["org.languagetool.desktop", "com.microsoft.teams2"]))
static let internalTilingNotified = BoolDefault(key: "internalTilingNotified")

static var array: [Default] = [
launchOnLogin,
Expand Down
42 changes: 42 additions & 0 deletions Rectangle/Utilities/MacTilingDefaults.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// MacTilingDefaults.swift
// Rectangle
//
// Copyright © 2024 Ryan Hanson. All rights reserved.
//

import Foundation

/// Read / disable the user defaults values for the macOS built-in window tiling, added in macOS 15 Sequoia.
/// These are toggled in the Desktop & Dock System Settings Pane:
enum MacTilingDefaults: String {
case tilingByEdgeDrag = "EnableTilingByEdgeDrag"
case tilingOptionAccelerator = "EnableTilingOptionAccelerator"
case tiledWindowMargins = "EnableTiledWindowMargins"

var enabled: Bool {
guard #available(macOS 15, *), let defaults = UserDefaults(suiteName: "com.apple.WindowManager")
else {
return false
}

if defaults.object(forKey: self.rawValue) == nil { // These are enabled by default
return true
}
return defaults.bool(forKey: self.rawValue)
}

func disable() {
guard let defaults = UserDefaults(suiteName: "com.apple.WindowManager")
else {
return
}

defaults.set(false, forKey: self.rawValue)
defaults.synchronize()
}

static func openSystemSettings() {
NSWorkspace.shared.open(URL(string:"x-apple.systempreferences:com.apple.preference.Desktop-Settings.extension")!)
}
}
16 changes: 16 additions & 0 deletions Rectangle/Utilities/StringExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// StringExtension.swift
// Rectangle
//
// Copyright © 2024 Ryan Hanson. All rights reserved.
//

import Foundation

extension String {

var localized: String {
NSLocalizedString(self, tableName: "Main", comment: "")
}

}
21 changes: 21 additions & 0 deletions Rectangle/mul.lproj/Main.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -11643,6 +11643,9 @@
}
}
},
"Conflict with macOS tiling" : {
"extractionState" : "manual"
},
"Conflict with system setting" : {
"localizations" : {
"ar" : {
Expand Down Expand Up @@ -13741,6 +13744,15 @@
}
}
},
"Disable in macOS" : {
"extractionState" : "manual"
},
"Disable in Rectangle" : {
"extractionState" : "manual"
},
"Dismiss" : {
"extractionState" : "manual"
},
"Display" : {
"localizations" : {
"ar" : {
Expand Down Expand Up @@ -14093,6 +14105,9 @@
}
}
},
"Drag to screen edge tiling is enabled in both Rectangle and macOS." : {
"extractionState" : "manual"
},
"dRJ-4n-Yzg.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Undo\"; ObjectID = \"dRJ-4n-Yzg\";",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -39755,6 +39770,9 @@
}
}
},
"Tiling in macOS has been disabled" : {
"extractionState" : "manual"
},
"tlD-Oa-oAM.title" : {
"comment" : "Class = \"NSMenu\"; title = \"Kern\"; ObjectID = \"tlD-Oa-oAM\";",
"extractionState" : "manual",
Expand Down Expand Up @@ -40065,6 +40083,9 @@
}
}
},
"To re-enable it, go to System Settings → Desktop & Dock → Windows" : {
"extractionState" : "manual"
},
"Top sixths from corners; maximize" : {
"localizations" : {
"ar" : {
Expand Down
Loading