Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rxhanson authored Nov 29, 2019
2 parents d3a3bd5 + a37c050 commit 9793d7b
Show file tree
Hide file tree
Showing 20 changed files with 292 additions and 145 deletions.
16 changes: 16 additions & 0 deletions Rectangle.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
988D068522EB4EFC004EABD7 /* MoveDownCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988D068422EB4EFC004EABD7 /* MoveDownCalculation.swift */; };
98910B3E231130AF0066EC23 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98910B3D231130AF0066EC23 /* SettingsViewController.swift */; };
98910B42231476B30066EC23 /* PrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98910B41231476B30066EC23 /* PrefsViewController.swift */; };
98987AA42391890400BE72C4 /* LogViewer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98987AA22391890300BE72C4 /* LogViewer.storyboard */; };
98987AA52391890400BE72C4 /* LogViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98987AA32391890400BE72C4 /* LogViewer.swift */; };
98C1008C2305F1FA006E5344 /* SubsequentExecutionMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C1008B2305F1FA006E5344 /* SubsequentExecutionMode.swift */; };
98C1008E230B9EF6006E5344 /* NextPrevDisplayCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C1008D230B9EF6006E5344 /* NextPrevDisplayCalculation.swift */; };
98C2755E231FF6A9009B9292 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98C2755D231FF6A9009B9292 /* EventMonitor.swift */; };
Expand Down Expand Up @@ -177,6 +179,8 @@
98910B6C231D16840066EC23 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Main.strings; sourceTree = "<group>"; };
98910B6D231D16B00066EC23 /* es-419 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-419"; path = "es-419.lproj/Main.strings"; sourceTree = "<group>"; };
98910B6E231D16B00066EC23 /* es-419 */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "es-419"; path = "es-419.lproj/Main.strings"; sourceTree = "<group>"; };
98987AA22391890300BE72C4 /* LogViewer.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LogViewer.storyboard; sourceTree = "<group>"; };
98987AA32391890400BE72C4 /* LogViewer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogViewer.swift; sourceTree = "<group>"; };
98C1008B2305F1FA006E5344 /* SubsequentExecutionMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubsequentExecutionMode.swift; sourceTree = "<group>"; };
98C1008D230B9EF6006E5344 /* NextPrevDisplayCalculation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextPrevDisplayCalculation.swift; sourceTree = "<group>"; };
98C2755D231FF6A9009B9292 /* EventMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -358,6 +362,7 @@
9824703E22B13FBC0037B409 /* ScreenDetection.swift */,
98C275662322E2DA009B9292 /* WindowHistory.swift */,
9824704022B186D00037B409 /* WindowManager.swift */,
98987AA62391890C00BE72C4 /* Logging */,
98910B3C2311304D0066EC23 /* PrefsWindow */,
98C2755F231FF6AE009B9292 /* Snapping */,
985B9BFA22BE218C00A2E8F0 /* Popover */,
Expand Down Expand Up @@ -396,6 +401,15 @@
path = PrefsWindow;
sourceTree = "<group>";
};
98987AA62391890C00BE72C4 /* Logging */ = {
isa = PBXGroup;
children = (
98987AA22391890300BE72C4 /* LogViewer.storyboard */,
98987AA32391890400BE72C4 /* LogViewer.swift */,
);
path = Logging;
sourceTree = "<group>";
};
98C2755F231FF6AE009B9292 /* Snapping */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -552,6 +566,7 @@
9824701122AF9B7E0037B409 /* Assets.xcassets in Resources */,
9824701422AF9B7E0037B409 /* Main.storyboard in Resources */,
981F27D12340E3E1006CD263 /* InternetAccessPolicy.plist in Resources */,
98987AA42391890400BE72C4 /* LogViewer.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -722,6 +737,7 @@
9824704F22B189250037B409 /* BestEffortWindowMover.swift in Sources */,
9824703922B0F37C0037B409 /* ShortcutManager.swift in Sources */,
9821403322B38A1B00ABFB3F /* UpperLeftCalculation.swift in Sources */,
98987AA52391890400BE72C4 /* LogViewer.swift in Sources */,
9824704C22B189250037B409 /* WindowMover.swift in Sources */,
988D066922EB4CCB004EABD7 /* LastThirdCalculation.swift in Sources */,
988D068522EB4EFC004EABD7 /* MoveDownCalculation.swift in Sources */,
Expand Down
21 changes: 8 additions & 13 deletions Rectangle/AccessibilityElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import Foundation
import Carbon
import Cocoa
import os.log

class AccessibilityElement {
private let underlyingElement: AXUIElement
Expand All @@ -27,8 +26,8 @@ class AccessibilityElement {

static func frontmostWindow() -> AccessibilityElement? {
guard let frontmostApplicationElement = AccessibilityElement.frontmostApplication() else {
if #available(OSX 10.12, *) {
os_log("Failed to find the application that currently has focus.", type: .info)
if Logger.logging {
Logger.log("Failed to find the application that currently has focus.")
}
return nil
}
Expand All @@ -44,8 +43,8 @@ class AccessibilityElement {
return AccessibilityElement(copiedUnderlyingElement as! AXUIElement)
}
}
if #available(OSX 10.12, *) {
os_log("Unable to obtain accessibility element", type: .debug)
if Logger.logging {
Logger.log("Unable to obtain accessibility element")
}
return nil
}
Expand Down Expand Up @@ -121,10 +120,8 @@ class AccessibilityElement {
private func set(position: CGPoint) {
if let value = AXValue.from(value: position, type: .cgPoint) {
AXUIElementSetAttributeValue(self.underlyingElement, kAXPositionAttribute as CFString, value)
if Defaults.debug.enabled {
if #available(OSX 10.12, *) {
os_log("AX position proposed: %{public}@, result: %{public}@", type: .debug, position.debugDescription, getPosition()?.debugDescription ?? "N/A")
}
if Logger.logging {
Logger.log("AX position proposed: \(position.debugDescription), result: \(getPosition()?.debugDescription ?? "N/A")")
}
}
}
Expand All @@ -136,10 +133,8 @@ class AccessibilityElement {
private func set(size: CGSize) {
if let value = AXValue.from(value: size, type: .cgSize) {
AXUIElementSetAttributeValue(self.underlyingElement, kAXSizeAttribute as CFString, value)
if Defaults.debug.enabled {
if #available(OSX 10.12, *) {
os_log("AX sizing proposed: %{public}@, result: %{public}@", type: .debug, size.debugDescription, getSize()?.debugDescription ?? "N/A")
}
if Logger.logging {
Logger.log("AX sizing proposed: \(size.debugDescription), result: \(getSize()?.debugDescription ?? "N/A")")
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions Rectangle/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var mainStatusMenu: NSMenu!
@IBOutlet weak var unauthorizedMenu: NSMenu!
@IBOutlet weak var ignoreMenuItem: NSMenuItem!
@IBOutlet weak var viewLoggingMenuItem: NSMenuItem!
@IBOutlet weak var quitMenuItem: NSMenuItem!

override init() {
self.windowCalculationFactory = WindowCalculationFactory()
Expand Down Expand Up @@ -77,6 +79,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSApp.orderFrontStandardAboutPanel(sender)
}

@IBAction func viewLogging(_ sender: Any) {
Logger.showLogging(sender: sender)
}

@IBAction func ignoreFrontMostApp(_ sender: NSMenuItem) {
if sender.state == .on {
applicationToggle.enableFrontApp()
Expand Down Expand Up @@ -138,6 +144,10 @@ extension AppDelegate: NSMenuDelegate {
menuItem.isEnabled = false
}
}

viewLoggingMenuItem.keyEquivalentModifierMask = .option
quitMenuItem.keyEquivalent = "q"
quitMenuItem.keyEquivalentModifierMask = .command
}

func menuDidClose(_ menu: NSMenu) {
Expand Down
21 changes: 14 additions & 7 deletions Rectangle/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@
<connections>
<outlet property="ignoreMenuItem" destination="D99-0O-MB6" id="iBN-Bc-ds7"/>
<outlet property="mainStatusMenu" destination="6wc-Rn-2EG" id="UWt-be-ZH1"/>
<outlet property="quitMenuItem" destination="A66-A4-cGD" id="Vul-Dd-RcH"/>
<outlet property="unauthorizedMenu" destination="HZt-qn-3MK" id="c4f-hw-GWr"/>
<outlet property="viewLoggingMenuItem" destination="O8K-y6-bva" id="31H-se-kyh"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
Expand All @@ -705,14 +707,19 @@
<action selector="showAbout:" target="Voe-Tx-rLC" id="dGA-Fy-dtB"/>
</connections>
</menuItem>
<menuItem title="View Logging..." alternate="YES" id="O8K-y6-bva">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="viewLogging:" target="Voe-Tx-rLC" id="8cH-2P-yKC"/>
</connections>
</menuItem>
<menuItem title="Check for Updates…" id="HIK-3r-i7E">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="Voe-Tx-rLC" id="kWZ-ie-6y9"/>
</connections>
</menuItem>
<menuItem title="Quit Rectangle" keyEquivalent="q" id="A66-A4-cGD">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="terminate:" target="hnw-xV-0zn" id="M1a-kx-BJY"/>
</connections>
Expand Down Expand Up @@ -2300,14 +2307,14 @@
<textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="gIp-Hu-6ns">
<rect key="frame" x="-2" y="110" width="454" height="14"/>
<textFieldCell key="cell" title="When the menu bar icon is hidden, relaunch Rectangle from Finder to open the menu." id="ltc-mf-BHr">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="95T-Ls-2ah">
<rect key="frame" x="-2" y="84" width="454" height="18"/>
<buttonCell key="cell" type="check" title="Traverse displays on subsequent left or right executions" bezelStyle="regularSquare" imagePosition="left" inset="2" id="SXx-HZ-GkB">
<buttonCell key="cell" type="check" title="Cycle across displays on repeated left or right commands" bezelStyle="regularSquare" imagePosition="left" inset="2" id="SXx-HZ-GkB">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
Expand All @@ -2317,8 +2324,8 @@
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Pe4-di-byb">
<rect key="frame" x="-2" y="48" width="454" height="28"/>
<textFieldCell key="cell" title="This applies to move or half actions only. Half actions will not perform 2/3 &amp; 1/3 behavior when enabled." id="01Z-t3-cBm">
<font key="font" metaFont="label" size="11"/>
<textFieldCell key="cell" title="If you repeat move or half actions, the window will move to the next display instead of 1/2, 2/3, and 1/3 size." id="01Z-t3-cBm">
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down Expand Up @@ -2398,7 +2405,7 @@
</viewController>
<customObject id="c9e-yT-Dp7" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="372" y="1267"/>
<point key="canvasLocation" x="372" y="1266.5"/>
</scene>
<!--Window Controller-->
<scene sceneID="lEt-lj-rQC">
Expand Down Expand Up @@ -2459,7 +2466,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XRC-ST-jLi">
<rect key="frame" x="-2" y="137" width="254" height="28"/>
<textFieldCell key="cell" alignment="center" title="Go to System Preferences → Security &amp; Privacy → Privacy → Accessibility" id="lgE-cR-cQ5">
<font key="font" metaFont="label" size="11"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down
1 change: 0 additions & 1 deletion Rectangle/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Defaults {
static let subsequentExecutionMode = SubsequentExecutionDefault()
static let allowAnyShortcut = BoolDefault(key: "allowAnyShortcut")
static let windowSnapping = OptionalBoolDefault(key: "windowSnapping")
static let debug = BoolDefault(key: "debug")
static let almostMaximizeRatio = FloatDefault(key: "almostMaximizeRatio")
}

Expand Down
Loading

0 comments on commit 9793d7b

Please sign in to comment.