Skip to content

Commit 2fcabfd

Browse files
authored
Address app review comments + make app more better (#9)
* Add Main Window button to Window menu item * Add make clean * More accurately decide if we should open the settings window * Bump build number to 6 * Exclude main window from Window menu so it can be manually added This is being done to comply with an App Review requirement * Bump build number to 7 * Bump version to 1.1.1 and build number to 9
1 parent 6480ee9 commit 2fcabfd

5 files changed

Lines changed: 37 additions & 33 deletions

File tree

CenterMouse.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@
390390
CODE_SIGN_IDENTITY = "-";
391391
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
392392
CODE_SIGN_STYLE = Automatic;
393-
CURRENT_PROJECT_VERSION = 5;
393+
CURRENT_PROJECT_VERSION = 9;
394394
DEAD_CODE_STRIPPING = YES;
395395
DEVELOPMENT_TEAM = F2J52QJQ9Y;
396396
ENABLE_HARDENED_RUNTIME = YES;
@@ -403,7 +403,7 @@
403403
"$(inherited)",
404404
"@executable_path/../Frameworks",
405405
);
406-
MARKETING_VERSION = 1.1.0;
406+
MARKETING_VERSION = 1.1.1;
407407
PRODUCT_BUNDLE_IDENTIFIER = software.level.CenterMouse;
408408
PRODUCT_NAME = "$(TARGET_NAME)";
409409
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -419,7 +419,7 @@
419419
CODE_SIGN_IDENTITY = "-";
420420
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
421421
CODE_SIGN_STYLE = Automatic;
422-
CURRENT_PROJECT_VERSION = 5;
422+
CURRENT_PROJECT_VERSION = 9;
423423
DEAD_CODE_STRIPPING = YES;
424424
DEVELOPMENT_TEAM = F2J52QJQ9Y;
425425
ENABLE_HARDENED_RUNTIME = YES;
@@ -432,7 +432,7 @@
432432
"$(inherited)",
433433
"@executable_path/../Frameworks",
434434
);
435-
MARKETING_VERSION = 1.1.0;
435+
MARKETING_VERSION = 1.1.1;
436436
PRODUCT_BUNDLE_IDENTIFIER = software.level.CenterMouse;
437437
PRODUCT_NAME = "$(TARGET_NAME)";
438438
SWIFT_EMIT_LOC_STRINGS = YES;

CenterMouse/Resources/Base.lproj/MainMenu.xib

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21701"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
55
</dependencies>
66
<objects>
77
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -329,13 +329,20 @@
329329
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
330330
</connections>
331331
</menuItem>
332-
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
332+
<menuItem isSeparatorItem="YES" id="tCf-wr-CME"/>
333333
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
334334
<modifierMask key="keyEquivalentModifierMask"/>
335335
<connections>
336336
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
337337
</connections>
338338
</menuItem>
339+
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
340+
<menuItem title="CenterMouse" id="nKL-96-cSG">
341+
<modifierMask key="keyEquivalentModifierMask"/>
342+
<connections>
343+
<action selector="windowMenuMainWindowItemActivated:" target="Voe-Tx-rLC" id="IpI-CD-UCE"/>
344+
</connections>
345+
</menuItem>
339346
</items>
340347
</menu>
341348
</menuItem>

CenterMouse/Sources/AppDelegate.swift

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
1010

1111
private var eventMonitor = EventMonitor()
1212

13-
/// Whether or not the app is relaunching after it has been launched and quit before
14-
///
15-
/// We track this to know whether or not to open the Settings window. If this is a
16-
/// fresh relaunch, we _don't_ want to open the Settings window right away.
17-
private var isRelaunch = false
18-
19-
func applicationWillFinishLaunching(_ notification: Notification) {
20-
if Defaults[.firstTimeAppLaunched] {
21-
Defaults[.firstTimeAppLaunched] = false
22-
} else {
23-
isRelaunch = true
24-
}
25-
}
26-
2713
func applicationDidFinishLaunching(_ notification: Notification) {
2814
window = NSWindow(
2915
contentRect: NSZeroRect,
@@ -33,12 +19,25 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
3319
)
3420

3521
window.title = "CenterMouse"
22+
23+
// Excluding this from the Window menu so that it can be manually added.
24+
// This is being done to comply with an App Review requirement.
25+
window.isExcludedFromWindowsMenu = true
26+
3627
window.contentView = NSHostingView(rootView: SettingsView())
3728
windowController = NSWindowController(window: window)
29+
30+
if launchedAsLogInItem == false {
31+
openSettingsWindow()
32+
}
3833
}
3934

40-
func applicationDidBecomeActive(_ notification: Notification) {
41-
openSettingsWindow()
35+
private var launchedAsLogInItem: Bool {
36+
// source: https://stackoverflow.com/a/19890943/4118208
37+
guard let event = NSAppleEventManager.shared().currentAppleEvent else { return false }
38+
return
39+
event.eventID == kAEOpenApplication &&
40+
event.paramDescriptor(forKeyword: keyAEPropData)?.enumCodeValue == keyAELaunchedAsLogInItem
4241
}
4342

4443
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
@@ -50,6 +49,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
5049
openSettingsWindow()
5150
}
5251

52+
@IBAction func windowMenuMainWindowItemActivated(_ sender: NSMenuItem) {
53+
openSettingsWindow()
54+
}
55+
5356
func openSettingsWindow() {
5457
// Works around an annoyance where the app always comes to the foreground when
5558
// being previewed in Xcode's SwiftUI Canvas.
@@ -59,15 +62,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
5962
return
6063
}
6164

62-
// We only need to check whether this is a relaunch the first time this method
63-
// is called (by `applicationDidBecomeActive(_:)`). After that, we'll want to
64-
// open the Settings window whenever this method is called, so we set the value
65-
// to `false`.
66-
guard isRelaunch == false else {
67-
isRelaunch = false
68-
return
69-
}
70-
7165
windowController.window?.center()
7266
windowController.showWindow(self)
7367
NSApp.activate(ignoringOtherApps: true)

CenterMouse/Sources/Settings.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Defaults
44
extension Defaults.Keys {
55
static let hideDockIcon = Key<Bool>("hideDockIcon", default: false)
66
static let monitorSystemEvents = Key<Bool>("monitorSystemEvents", default: true)
7-
static let firstTimeAppLaunched = Key<Bool>("firstTimeAppLaunched", default: true)
87
}
98

109
enum Settings {

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ build:
88
@echo "Building project..."
99
@$(scripts_dir)build.sh
1010
.PHONY: build
11+
12+
clean:
13+
rm -rf $(project_dir)DerivedData
14+
.PHONY: clean

0 commit comments

Comments
 (0)