diff --git a/Mouse Fix Helper/Remap/MouseInputReceiver.m b/Mouse Fix Helper/Remap/MouseInputReceiver.m
index 7b8b9b248..2bfc8e5d0 100644
--- a/Mouse Fix Helper/Remap/MouseInputReceiver.m
+++ b/Mouse Fix Helper/Remap/MouseInputReceiver.m
@@ -236,7 +236,7 @@ static void Handle_DeviceMatchingCallbackHID (void *context, IOReturn result, vo
_relevantDevicesAreAttached = TRUE;
[MomentumScroll decide];
NSLog(@"MomentumScroll.isEnabled: %hhd", MomentumScroll.isEnabled);
- NSLog(@"MomentumScroll.isRunning: %hhd", MomentumScroll.isRunning);
+ NSLog(@"MomentumScroll.hasStarted: %hhd", MomentumScroll.hasStarted);
diff --git a/Mouse Fix Helper/Scroll/ScrollControl.m b/Mouse Fix Helper/Scroll/ScrollControl.m
index 5cccae73e..be4163bfa 100644
--- a/Mouse Fix Helper/Scroll/ScrollControl.m
+++ b/Mouse Fix Helper/Scroll/ScrollControl.m
@@ -190,6 +190,15 @@ static CGEventRef eventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEv
scrollPhase != 0) { // adding scrollphase here is untested
return event;
}
+
+ // Check if scrolling direction changed
+
+ [ScrollUtility updateScrollDirectionDidChange:scrollDeltaAxis1];
+
+ if (ScrollUtility.scrollDirectionDidChange) {
+ [ScrollUtility resetConsecutiveTicksAndSwipes];
+ }
+
// Create a copy, because the original event will become invalid and unusable in the new thread.
CGEventRef eventCopy = [ScrollUtility createScrollEventWithValuesFromEvent:event];
@@ -198,14 +207,7 @@ static CGEventRef eventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEv
// With multithreading enabled, scrolling sometimes - seemingly at random - stops working entirely. So the tap still works but sending events doesn't.
// - Switching to an app that doesn't have smothscroll enabled seems to fix it. -> Somethings in my code must be breaking
dispatch_async(_scrollQueue, ^{
-
- // Check if scrolling direction changed
-
- [ScrollUtility updateScrollDirectionDidChange:scrollDeltaAxis1];
-
- if (ScrollUtility.scrollDirectionDidChange) {
- [ScrollUtility resetConsecutiveTicksAndSwipes];
- }
+
// Set application overrides
@@ -219,15 +221,23 @@ static CGEventRef eventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEv
}
if (ScrollUtility.mouseDidMove || ScrollUtility.frontMostAppDidChange) {
// set app overrides
- [ConfigFileInterface_HelperApp updateInternalParameters_Force:NO];
+ BOOL configChanged = [ConfigFileInterface_HelperApp updateInternalParameters_Force:NO]; // TODO: `updateInternalParameters_Force:` should (probably) reset stuff itself, if it changes anything. This whole [SmoothScroll stop] stuff is kinda messy
+ if (configChanged) {
+ [SmoothScroll stop]; // Not sure if useful
+ [RoughScroll stop]; // Not sure if useful
+ }
}
}
// Process event
if (_isSmoothEnabled) {
+ [SmoothScroll start]; // Not sure if useful
+ [RoughScroll stop]; // Not sure if useful
[SmoothScroll handleInput:eventCopy info:NULL];
} else {
+ [SmoothScroll stop]; // Not sure if useful
+ [RoughScroll stop]; // Not sure if useful
[RoughScroll handleInput:eventCopy info:NULL];
}
CFRelease(eventCopy);
diff --git a/Mouse Fix Helper/Scroll/ScrollUtility.m b/Mouse Fix Helper/Scroll/ScrollUtility.m
index a21d67b16..b21d116d0 100644
--- a/Mouse Fix Helper/Scroll/ScrollUtility.m
+++ b/Mouse Fix Helper/Scroll/ScrollUtility.m
@@ -181,7 +181,7 @@ + (BOOL)scrollDirectionDidChange {
static long long _previousScrollValue;
/// Checks whether the sign of input number is different from when this function was last called. Writes result into `_frontMostAppDidChange`.
+ (void)updateScrollDirectionDidChange:(long long)thisScrollValue {
- BOOL _scrollDirectionDidChange = NO;
+ _scrollDirectionDidChange = NO;
if (![ScrollUtility sameSign:thisScrollValue and:_previousScrollValue]) {
_scrollDirectionDidChange = YES;
}
diff --git a/Mouse Fix Helper/Scroll/SmoothScroll.h b/Mouse Fix Helper/Scroll/SmoothScroll.h
index f0e9dc9ac..f91aca03b 100644
--- a/Mouse Fix Helper/Scroll/SmoothScroll.h
+++ b/Mouse Fix Helper/Scroll/SmoothScroll.h
@@ -18,7 +18,7 @@
+ (void)start;
+ (void)stop;
-+ (BOOL)isRunning;
++ (BOOL)hasStarted;
+ (BOOL)isScrolling;
+ (void)handleInput:(CGEventRef _Nonnull)event info:(NSDictionary * _Nullable)info;
diff --git a/Mouse Fix Helper/Scroll/SmoothScroll.m b/Mouse Fix Helper/Scroll/SmoothScroll.m
index 61c551210..ec0a342b1 100644
--- a/Mouse Fix Helper/Scroll/SmoothScroll.m
+++ b/Mouse Fix Helper/Scroll/SmoothScroll.m
@@ -92,27 +92,28 @@ + (void)configureWithParameters:(NSDictionary *)params {
+ (BOOL)isScrolling {
return _isScrolling;
}
-static BOOL _isRunning;
-+ (BOOL)isRunning {
- return _isRunning;
+static BOOL _hasStarted;
++ (BOOL)hasStarted {
+ return _hasStarted;
}
+ (void)start {
-
- if (_isRunning) {
+ if (_hasStarted) {
return;
}
NSLog(@"SmoothScroll started");
- _isRunning = YES;
+ _hasStarted = YES;
[SmoothScroll resetDynamicGlobals];
CGDisplayRemoveReconfigurationCallback(Handle_displayReconfiguration, NULL); // don't know if necesssary
CGDisplayRegisterReconfigurationCallback(Handle_displayReconfiguration, NULL);
}
+ (void)stop {
-
+ if (!_hasStarted) {
+ return;
+ }
NSLog(@"SmoothScroll stopped");
- _isRunning = NO;
+ _hasStarted = NO;
_isScrolling = NO;
CVDisplayLinkStop(_displayLink);
CGDisplayRemoveReconfigurationCallback(Handle_displayReconfiguration, NULL);
@@ -122,22 +123,12 @@ + (void)stop {
+ (void)handleInput:(CGEventRef)event info:(NSDictionary * _Nullable)info {
- long long scrollDeltaAxis1 = CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1);
+// NSLog(@"CONSECCC: %d", ScrollUtility.consecutiveScrollTickCounter);
+// NSLog(@"DLINK ON???: %d", CVDisplayLinkIsRunning(_displayLink));
+// NSLog(@"DLINK PHASEEE: %d", _displayLinkPhase);
+// NSLog(@"STARTEDD??: %d", _hasStarted);
- // Stuff you wanna do on the first tick of each series of consecutive scroll ticks.
- if (ScrollUtility.consecutiveScrollTickCounter == 0) {
- if (ScrollUtility.mouseDidMove) {
- // set diplaylink to the display that is actally being scrolled - not sure if this is necessary, because having the displaylink at 30fps on a 30fps display looks just as horrible as having the display link on 60fps, if not worse
- @try {
- setDisplayLinkToDisplayUnderMousePointer(event);
- } @catch (NSException *e) {
- NSLog(@"Error while trying to set display link to display under mouse pointer: %@", [e reason]);
- }
- }
- if (CVDisplayLinkIsRunning(_displayLink) == FALSE) {
- CVDisplayLinkStart(_displayLink);
- }
- }
+ long long scrollDeltaAxis1 = CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1);
// Update global vars
@@ -176,11 +167,26 @@ + (void)handleInput:(CGEventRef)event info:(NSDictionary * _Nullable)info {
if (ScrollUtility.consecutiveScrollSwipeCounter > ScrollControl.fastScrollThreshold_inSwipes) {
_pxScrollBuffer = _pxScrollBuffer * pow(ScrollControl.fastScrollExponentialBase, (int32_t)ScrollUtility.consecutiveScrollSwipeCounter - ScrollControl.fastScrollThreshold_inSwipes);
}
+
+ // Start displaylink and stuff
+ if (ScrollUtility.consecutiveScrollTickCounter == 0) {
+ if (ScrollUtility.mouseDidMove) {
+ // set diplaylink to the display that is actally being scrolled - not sure if this is necessary, because having the displaylink at 30fps on a 30fps display looks just as horrible as having the display link on 60fps, if not worse
+ @try {
+ setDisplayLinkToDisplayUnderMousePointer(event);
+ } @catch (NSException *e) {
+ NSLog(@"Error while trying to set display link to display under mouse pointer: %@", [e reason]);
+ }
+ }
+ if (CVDisplayLinkIsRunning(_displayLink) == FALSE) {
+ CVDisplayLinkStart(_displayLink);
+ }
+ }
}
static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) {
-
+// NSLog(@"DPL");
double msSinceLastFrame = CVDisplayLinkGetActualOutputVideoRefreshPeriod(_displayLink) * 1000;
if (msSinceLastFrame != 16.674562) {
@@ -348,9 +354,7 @@ static void setDisplayLinkToDisplayUnderMousePointer(CGEventRef event) {
NSException *e = [NSException exceptionWithName:NSInternalInconsistencyException reason:@"there are 0 diplays under the mouse pointer" userInfo:NULL];
@throw e;
}
-
free(newDisplaysUnderMousePointer);
-
}
@end
diff --git a/Mouse Fix/SupportFiles/Info.plist b/Mouse Fix/SupportFiles/Info.plist
index 5e38b5be2..fd33884aa 100644
--- a/Mouse Fix/SupportFiles/Info.plist
+++ b/Mouse Fix/SupportFiles/Info.plist
@@ -17,7 +17,7 @@
CFBundleShortVersionString
0.9.2 Beta 2
CFBundleVersion
- 1403
+ 1404
NSHumanReadableCopyright
Copyright © 2019 Noah Nuebling (MIT License)
NSMainNibFile
@@ -30,5 +30,7 @@
NSPrincipalClass
PrefPaneDelegate
+ NSRequiresAquaSystemAppearance
+