aboutsummaryrefslogtreecommitdiffstats
path: root/Low Battery Yup d/Mouse.h
diff options
context:
space:
mode:
authorTeddy Wing2016-12-03 00:22:17 -0500
committerTeddy Wing2016-12-03 00:22:17 -0500
commit9d91a7c908dc2261f2c3335875323c7088938204 (patch)
treee7924a71ba7c0171c6991e1c624247f2d8323b99 /Low Battery Yup d/Mouse.h
parent954071bcc651ed5876d8ac0c3e8c253d4470c416 (diff)
downloadLow-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/Mouse.h')
-rw-r--r--Low Battery Yup d/Mouse.h4
1 files changed, 4 insertions, 0 deletions
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;