Skip to content

Commit b4ed483

Browse files
authored
Add a button for hard resetting layouts (#1767)
1 parent 11b9284 commit b4ed483

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

Amethyst/AppDelegate.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
132132
windowManager?.markAllScreensForReflow(withChange: .unknown)
133133
}
134134

135+
@IBAction func resetLayouts(_ sender: AnyObject) {
136+
UserDefaults.standard.removeObject(forKey: AppDelegate.windowManagerEncodingKey)
137+
windowManager?.reset()
138+
}
139+
135140
@IBAction func relaunch(_ sender: AnyObject) {
136141
AppManager.relaunch()
137142
}

Amethyst/Base.lproj/MainMenu.xib

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/>
66
<capability name="Image references" minToolsVersion="12.0"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
@@ -45,10 +45,16 @@
4545
<action selector="checkForUpdates:" target="494" id="l9Y-Ct-Bzq"/>
4646
</connections>
4747
</menuItem>
48-
<menuItem title="Relaunch Amethyst" id="8DH-wG-R1x">
48+
<menuItem title="Reset Layouts" id="8DH-wG-R1x">
4949
<modifierMask key="keyEquivalentModifierMask"/>
5050
<connections>
51-
<action selector="relaunch:" target="494" id="SdJ-ap-5Vy"/>
51+
<action selector="resetLayouts:" target="494" id="Osy-WG-Dy8"/>
52+
</connections>
53+
</menuItem>
54+
<menuItem title="Relaunch Amethyst" id="crd-PN-Vy2">
55+
<modifierMask key="keyEquivalentModifierMask"/>
56+
<connections>
57+
<action selector="relaunch:" target="494" id="EeN-oj-Mtv"/>
5258
</connections>
5359
</menuItem>
5460
<menuItem isSeparatorItem="YES" id="553"/>

Amethyst/Managers/WindowManager.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class WindowManager<Application: ApplicationType>: NSObject, Codable {
4848

4949
private var applications: [pid_t: AnyApplication<Application>] = [:]
5050
private var applicationObservations: [pid_t: UndeterminedApplication] = [:]
51-
private let screens: Screens
51+
private var screens: Screens
5252
private let windows = Windows()
5353
private var lastReflowTime = Date()
5454
private var lastFocusDate: Date?
@@ -103,6 +103,12 @@ final class WindowManager<Application: ApplicationType>: NSObject, Codable {
103103
NotificationCenter.default.removeObserver(self)
104104
}
105105

106+
func reset() {
107+
screens = Screens()
108+
reevaluateWindows()
109+
screens.updateScreens(windowManager: self)
110+
}
111+
106112
private func addWorkspaceNotificationObserver(_ name: NSNotification.Name, selector: Selector) {
107113
let workspaceNotificationCenter = NSWorkspace.shared.notificationCenter
108114
workspaceNotificationCenter.addObserver(self, selector: selector, name: name, object: nil)

0 commit comments

Comments
 (0)