diff options
author | Teddy Wing | 2016-12-03 00:34:01 -0500 |
---|---|---|
committer | Teddy Wing | 2016-12-03 00:34:01 -0500 |
commit | 8fefa257b812f887270e6f38cc13df9e80471476 (patch) | |
tree | 0efcc32a04973272d617b9e9058a6eeb45560201 | |
parent | 422d83d7572feb648f8dff966d36588e97cf4beb (diff) | |
parent | 7ffa846dff745feaccdc34d0d4caf72850bcd55d (diff) | |
download | Low-Battery-Yup-8fefa257b812f887270e6f38cc13df9e80471476.tar.bz2 |
Merge branch 'mouse-location-should-be-right-on-all-screen-sizes'
-rw-r--r-- | Low Battery Yup d/FakeAlert.h | 18 | ||||
-rw-r--r-- | Low Battery Yup d/FakeAlert.m | 29 | ||||
-rw-r--r-- | Low Battery Yup d/Mouse.h | 4 | ||||
-rw-r--r-- | Low Battery Yup d/Mouse.m | 18 | ||||
-rw-r--r-- | Low Battery Yup.d.xcodeproj/project.pbxproj | 6 |
5 files changed, 72 insertions, 3 deletions
diff --git a/Low Battery Yup d/FakeAlert.h b/Low Battery Yup d/FakeAlert.h new file mode 100644 index 0000000..b51ee77 --- /dev/null +++ b/Low Battery Yup d/FakeAlert.h @@ -0,0 +1,18 @@ +// +// FakeAlert.h +// Low Battery Yup.d +// +// Created by TW on 12/2/16. +// Copyright (c) 2016 TW. All rights reserved. +// + +#import <Foundation/Foundation.h> + +#define LOW_BATTERY_ALERT_WIDTH 475 +#define LOW_BATTERY_ALERT_HEIGHT 141 + +@interface FakeAlert : NSObject + +- (NSRect)frame; + +@end diff --git a/Low Battery Yup d/FakeAlert.m b/Low Battery Yup d/FakeAlert.m new file mode 100644 index 0000000..ef504a6 --- /dev/null +++ b/Low Battery Yup d/FakeAlert.m @@ -0,0 +1,29 @@ +// +// FakeAlert.m +// Low Battery Yup.d +// +// Created by TW on 12/2/16. +// Copyright (c) 2016 TW. All rights reserved. +// + +#import "FakeAlert.h" + +@implementation FakeAlert + +- (NSRect)frame +{ + NSWindow *window = [[NSWindow alloc] + initWithContentRect:NSMakeRect(0, 0, LOW_BATTERY_ALERT_WIDTH, LOW_BATTERY_ALERT_HEIGHT) + styleMask:NSTitledWindowMask + backing:NSBackingStoreBuffered + defer:YES]; + [window center]; + + NSRect frame = [window frame]; + + [window release]; + + return frame; +} + +@end diff --git a/Low Battery Yup d/Mouse.h b/Low Battery Yup d/Mouse.h index e15a212..f8a6732 100644 --- a/Low Battery Yup d/Mouse.h +++ b/Low Battery Yup d/Mouse.h @@ -7,10 +7,14 @@ // #import <Foundation/Foundation.h> +#import "FakeAlert.h" @interface Mouse : NSObject { CGDirectDisplayID _current_display; CGPoint _cursor_position; + + FakeAlert *_fake_alert; + NSRect _fake_alert_frame; } - (void)moveToPoint:(CGPoint)point; diff --git a/Low Battery Yup d/Mouse.m b/Low Battery Yup d/Mouse.m index 9bade59..103909d 100644 --- a/Low Battery Yup d/Mouse.m +++ b/Low Battery Yup d/Mouse.m @@ -16,10 +16,18 @@ if (self) { _current_display = CGMainDisplayID(); _cursor_position = CGPointMake(0, 0); + _fake_alert = [[FakeAlert alloc] init]; + _fake_alert_frame = [_fake_alert frame]; } return self; } +- (void)dealloc +{ + [_fake_alert release]; + [super dealloc]; +} + - (void)moveToPoint:(CGPoint)point { _cursor_position = point; @@ -28,13 +36,17 @@ - (void)moveToLowBatteryOK { + if (_current_display != CGMainDisplayID()) { + _current_display = CGMainDisplayID(); + _fake_alert_frame = [_fake_alert frame]; + } + CGPoint point; - size_t width = CGDisplayPixelsWide(_current_display); size_t height = CGDisplayPixelsHigh(_current_display); - point.x = width / 2 + 182; - point.y = height / 2 - 116; + point.x = _fake_alert_frame.origin.x + 420; + point.y = height - _fake_alert_frame.origin.y - 30; [self moveToPoint:point]; } diff --git a/Low Battery Yup.d.xcodeproj/project.pbxproj b/Low Battery Yup.d.xcodeproj/project.pbxproj index da19448..1e54a44 100644 --- a/Low Battery Yup.d.xcodeproj/project.pbxproj +++ b/Low Battery Yup.d.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ D131EB381DF1E8AB00504A74 /* com.teddywing.Low-Battery-Yup.StartAtLogin.plist in Resources */ = {isa = PBXBuildFile; fileRef = D131EB371DF1E8AB00504A74 /* com.teddywing.Low-Battery-Yup.StartAtLogin.plist */; }; D131EB4B1DF203CD00504A74 /* Low Battery Yup.d.app in Resources */ = {isa = PBXBuildFile; fileRef = D18C949E1DDC33CF00E03F87 /* Low Battery Yup.d.app */; }; D15D90B71DF0465E001700CD /* ShortcutView.m in Sources */ = {isa = PBXBuildFile; fileRef = D15D90B61DF0465E001700CD /* ShortcutView.m */; }; + D18378A11DF280E6005C5676 /* FakeAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = D18378A01DF280E6005C5676 /* FakeAlert.m */; }; D1871D071DE094AB00B8030D /* DDHotKeyTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D1871D061DE094AB00B8030D /* DDHotKeyTextField.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; D1871D081DE094C200B8030D /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = D1A37AF01DE001770022434D /* DDHotKeyUtilities.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; D1871D091DE0955E00B8030D /* DDHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = D123F5A71DDF9D2400A27B7A /* DDHotKeyCenter.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; @@ -72,6 +73,8 @@ D131EB371DF1E8AB00504A74 /* com.teddywing.Low-Battery-Yup.StartAtLogin.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "com.teddywing.Low-Battery-Yup.StartAtLogin.plist"; sourceTree = "<group>"; }; D15D90B51DF0465E001700CD /* ShortcutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShortcutView.h; sourceTree = "<group>"; }; D15D90B61DF0465E001700CD /* ShortcutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShortcutView.m; sourceTree = "<group>"; }; + D183789F1DF280E6005C5676 /* FakeAlert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FakeAlert.h; sourceTree = "<group>"; }; + D18378A01DF280E6005C5676 /* FakeAlert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FakeAlert.m; sourceTree = "<group>"; }; D1871D051DE094AB00B8030D /* DDHotKeyTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DDHotKeyTextField.h; path = DDHotKey/DDHotKeyTextField.h; sourceTree = "<group>"; }; D1871D061DE094AB00B8030D /* DDHotKeyTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyTextField.m; path = DDHotKey/DDHotKeyTextField.m; sourceTree = "<group>"; }; D18C949E1DDC33CF00E03F87 /* Low Battery Yup.d.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Low Battery Yup.d.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -189,6 +192,8 @@ children = ( D18C94B41DDC33CF00E03F87 /* AppDelegate.h */, D18C94B51DDC33CF00E03F87 /* AppDelegate.m */, + D183789F1DF280E6005C5676 /* FakeAlert.h */, + D18378A01DF280E6005C5676 /* FakeAlert.m */, D18C94C31DDC355400E03F87 /* Mouse.h */, D18C94C41DDC355400E03F87 /* Mouse.m */, D18C94A91DDC33CF00E03F87 /* Supporting Files */, @@ -385,6 +390,7 @@ D18C94C51DDC355400E03F87 /* Mouse.m in Sources */, D123F5A81DDF9D2400A27B7A /* DDHotKeyCenter.m in Sources */, D1A37AF11DE001770022434D /* DDHotKeyUtilities.m in Sources */, + D18378A11DF280E6005C5676 /* FakeAlert.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |