diff options
| author | Teddy Wing | 2016-12-03 00:22:17 -0500 |
|---|---|---|
| committer | Teddy Wing | 2016-12-03 00:22:17 -0500 |
| commit | 9d91a7c908dc2261f2c3335875323c7088938204 (patch) | |
| tree | e7924a71ba7c0171c6991e1c624247f2d8323b99 /Low Battery Yup.d.xcodeproj/project.pbxproj | |
| parent | 954071bcc651ed5876d8ac0c3e8c253d4470c416 (diff) | |
| download | Low-Battery-Yup-9d91a7c908dc2261f2c3335875323c7088938204.tar.bz2 | |
Click the right spot on all screen sizes
Previously, the point set to be clicked for the low battery alert was
only valid on a 13" 1440x900 screen. This change allows the click
functionality to work on any screen size.
I discovered in 954071bcc651ed5876d8ac0c3e8c253d4470c416 that I couldn't
use a percentage to get the height of the "OK" button.
But, the low battery alert uses `NSWindow`'s `-center` method, so I
thought up a hack to make a fake window, center it, and get the window's
frame dimensions. The fake window I create has the same (close enough)
dimensions as the low battery alert (measured from a screenshot).
I then use those dimensions to figure out where to click so that I'm
clicking in the right place on the "OK" button.
We also add a check to reinitialise the dimensions and reset the current
window if the main window has changed from what we thought it was. This
should allow the app to still work if you launch it from one display and
later plug in another as your main display where the low battery warning
will now appear.
We need to subtract the frame's Y coordinate from the screen height
because the frame origin uses standard bottom-left origin coordinates,
while `CGDisplayMoveCursorToPoint` uses top-left origin coordinates.
Diffstat (limited to 'Low Battery Yup.d.xcodeproj/project.pbxproj')
| -rw-r--r-- | Low Battery Yup.d.xcodeproj/project.pbxproj | 6 |
1 files changed, 6 insertions, 0 deletions
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; }; |
