Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix-mojave-reset-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jun 29, 2018
2 parents 4a9a3bf + d86d13a commit ba836c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
32 changes: 25 additions & 7 deletions Aware.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0940;
ORGANIZATIONNAME = "Joshua Peek";
TargetAttributes = {
036EBD141C1408C200121D0B = {
CreatedOnToolsVersion = 7.1.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 0940;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 1;
Expand All @@ -158,7 +158,7 @@
};
03F9E2251C24CAD3001DBE86 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0940;
TestTargetID = 036EBD141C1408C200121D0B;
};
};
Expand Down Expand Up @@ -251,14 +251,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -297,14 +305,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -338,7 +354,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = com.awaremac.Aware;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -354,7 +370,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.awaremac.Aware;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -367,7 +383,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.awaremac.AwareTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Aware.app/Contents/MacOS/Aware";
};
name = Debug;
Expand All @@ -382,7 +399,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.awaremac.AwareTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Aware.app/Contents/MacOS/Aware";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Aware.xcodeproj/xcshareddata/xcschemes/Aware.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
17 changes: 10 additions & 7 deletions Aware/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// defined in <CoreGraphics/CGEventTypes.h>
let AnyInputEventType = CGEventType(rawValue: UInt32.max)!

let statusItem = NSStatusBar.system().statusItem(withLength: NSVariableStatusItemLength)
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
@IBOutlet weak var menu: NSMenu! {
didSet {
statusItem.menu = menu
Expand All @@ -46,9 +46,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
updateButton()
let _ = Timer.scheduledTimer(buttonRefreshRate, userInfo: nil, repeats: true) { _ in self.updateButton() }

let notificationCenter = NSWorkspace.shared().notificationCenter
notificationCenter.addObserver(forName: NSNotification.Name.NSWorkspaceWillSleep, object: nil, queue: nil) { _ in self.resetTimer() }
notificationCenter.addObserver(forName: NSNotification.Name.NSWorkspaceDidWake, object: nil, queue: nil) { _ in self.resetTimer() }
let notificationCenter = NSWorkspace.shared.notificationCenter
notificationCenter.addObserver(forName: NSWorkspace.willSleepNotification, object: nil, queue: nil) { _ in self.resetTimer() }
notificationCenter.addObserver(forName: NSWorkspace.didWakeNotification, object: nil, queue: nil) { _ in self.resetTimer() }
}

func resetTimer() {
Expand Down Expand Up @@ -83,12 +83,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {

if (idle) {
statusItem.button!.attributedTitle = updateAttributedString(statusItem.button!.attributedTitle, [
NSForegroundColorAttributeName: NSColor.controlTextColor.withAlphaComponent(0.1)
NSAttributedStringKey.foregroundColor: NSColor.controlTextColor.withAlphaComponent(0.1)
])

// On next mouse event, immediately update button
if mouseEventMonitor == nil {
mouseEventMonitor = NSEvent.addGlobalMonitorForEvents(matching: [.mouseMoved, .leftMouseDown], handler: onMouseEvent)
mouseEventMonitor = NSEvent.addGlobalMonitorForEvents(matching: [
NSEvent.EventTypeMask.mouseMoved,
NSEvent.EventTypeMask.leftMouseDown
], handler: onMouseEvent)
}
}
}
Expand All @@ -105,7 +108,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return userActivityEventTypes.map { CGEventSource.secondsSinceLastEventType(.combinedSessionState, eventType: $0) }.min()!
}

func updateAttributedString(_ attributedString: NSAttributedString, _ attributes: [String: AnyObject]) -> NSAttributedString {
func updateAttributedString(_ attributedString: NSAttributedString, _ attributes: [NSAttributedStringKey: Any]) -> NSAttributedString {
let str = NSMutableAttributedString(attributedString: attributedString)
str.addAttributes(attributes, range: NSMakeRange(0, str.length))
return str
Expand Down

0 comments on commit ba836c8

Please sign in to comment.