summaryrefslogtreecommitdiff
path: root/apple_remote/source/MultiClickRemoteBehavior.m
diff options
context:
space:
mode:
authorAlexander Wilms <f.alexander.wilms@gmail.com>2014-02-25 17:23:41 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-02-25 16:26:29 +0000
commitb2afdb85c30c27c7fce96f206aeb115cb2a193ab (patch)
treecf28c4a65fb75f04b42e298507162d5da9ae783d /apple_remote/source/MultiClickRemoteBehavior.m
parent27c3b8bca22353dfdcf4c248539a727522fc4e76 (diff)
Remove visual noise from apple_remote
Change-Id: I12bec42cb699d8cbcfab2eb4d2f8ad8f5ed83b78 Reviewed-on: https://gerrit.libreoffice.org/8229 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'apple_remote/source/MultiClickRemoteBehavior.m')
-rw-r--r--apple_remote/source/MultiClickRemoteBehavior.m58
1 files changed, 29 insertions, 29 deletions
diff --git a/apple_remote/source/MultiClickRemoteBehavior.m b/apple_remote/source/MultiClickRemoteBehavior.m
index 1d624a76284d..0972a5ae99d6 100644
--- a/apple_remote/source/MultiClickRemoteBehavior.m
+++ b/apple_remote/source/MultiClickRemoteBehavior.m
@@ -3,13 +3,13 @@
* MultiClickRemoteBehavior.m
* RemoteControlWrapper
*
- * Created by Martin Kahr on 11.03.06 under a MIT-style license.
+ * Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
- * Code modified and adapted to OpenOffice.org
+ * Code modified and adapted to OpenOffice.org
* by Eric Bachard on 11.08.2008 under the same License
*
- * Permission is hereby granted, free of charge, to any person obtaining a
+ * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -21,7 +21,7 @@
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
@@ -45,12 +45,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// Delegates are not retained!
// http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html
-// Delegating objects do not (and should not) retain their delegates.
+// Delegating objects do not (and should not) retain their delegates.
// However, clients of delegating objects (applications, usually) are responsible for ensuring that their delegates are around
// to receive delegation messages. To do this, they may have to retain the delegate.
- (void) setDelegate: (id) _delegate {
if ( _delegate && ( [_delegate respondsToSelector:@selector(remoteButton:pressedDown:clickCount:)] == NO )) return; // return what ?
-
+
delegate = _delegate;
}
- (id) delegate {
@@ -66,8 +66,8 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
- (BOOL) simulatesHoldForButtonIdentifier: (RemoteControlEventIdentifier) identifier remoteControl: (RemoteControl*) remoteControl {
// we do that check only for the normal button identifiers as we would check for hold support for hold events instead
- if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
-
+ if (identifier > (1 << EVENT_TO_HOLD_EVENT_OFFSET)) return NO;
+
return [self simulateHoldEvent] && [remoteControl sendsEventForButtonIdentifier: (identifier << EVENT_TO_HOLD_EVENT_OFFSET)]==NO;
}
@@ -110,32 +110,32 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
}
- (void) executeClickCountEvent: (NSArray*) values {
- RemoteControlEventIdentifier event = [[values objectAtIndex: 0] unsignedIntValue];
+ RemoteControlEventIdentifier event = [[values objectAtIndex: 0] unsignedIntValue];
NSTimeInterval eventTimePoint = [[values objectAtIndex: 1] doubleValue];
-
+
BOOL finishedClicking = NO;
- int finalClickCount = eventClickCount;
-
+ int finalClickCount = eventClickCount;
+
@synchronized(self) {
finishedClicking = (event != lastClickCountEvent || eventTimePoint == lastClickCountEventTime);
if (finishedClicking) {
- eventClickCount = 0;
+ eventClickCount = 0;
lastClickCountEvent = 0;
lastClickCountEventTime = 0;
}
}
-
- if (finishedClicking) {
- [delegate remoteButton:event pressedDown: YES clickCount:finalClickCount];
+
+ if (finishedClicking) {
+ [delegate remoteButton:event pressedDown: YES clickCount:finalClickCount];
// trigger a button release event, too
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow:0.1]];
[delegate remoteButton:event pressedDown: NO clickCount:finalClickCount];
}
}
-- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
+- (void) sendRemoteButtonEvent: (RemoteControlEventIdentifier) event pressedDown: (BOOL) pressedDown remoteControl: (RemoteControl*) remoteControl {
if (!delegate) return;
-
+
BOOL clickCountingForEvent = ([self clickCountEnabledButtons] & event) == event;
if ([self simulatesHoldForButtonIdentifier: event remoteControl: remoteControl] && lastClickCountEvent==0) {
@@ -143,7 +143,7 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
// wait to see if it is a hold
lastHoldEvent = event;
lastHoldEventTime = [NSDate timeIntervalSinceReferenceDate];
- [self performSelector:@selector(sendSimulatedHoldEvent:)
+ [self performSelector:@selector(sendSimulatedHoldEvent:)
withObject:[NSNumber numberWithDouble:lastHoldEventTime]
afterDelay:HOLD_RECOGNITION_TIME_INTERVAL];
return;
@@ -161,31 +161,31 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
RemoteControlEventIdentifier previousEvent = lastHoldEvent;
@synchronized(self) {
lastHoldEvent = 0;
- }
-
+ }
+
// in case click counting is enabled we have to setup the state for that, too
if (clickCountingForEvent) {
lastClickCountEvent = previousEvent;
lastClickCountEventTime = lastHoldEventTime;
NSNumber* eventNumber;
- NSNumber* timeNumber;
+ NSNumber* timeNumber;
eventClickCount = 1;
timeNumber = [NSNumber numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber numberWithUnsignedInt:previousEvent];
NSTimeInterval diffTime = maxClickTimeDifference-([NSDate timeIntervalSinceReferenceDate]-lastHoldEventTime);
- [self performSelector: @selector(executeClickCountEvent:)
+ [self performSelector: @selector(executeClickCountEvent:)
withObject: [NSArray arrayWithObjects:eventNumber, timeNumber, nil]
- afterDelay: diffTime];
+ afterDelay: diffTime];
// we do not return here because we are still in the press-release event
// that will be consumed below
} else {
// trigger the pressed down event that we consumed first
- [delegate remoteButton:event pressedDown: YES clickCount:1];
+ [delegate remoteButton:event pressedDown: YES clickCount:1];
}
- }
+ }
}
}
-
+
if (clickCountingForEvent) {
if (pressedDown == NO) return;
@@ -202,12 +202,12 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL = 0.4;
timeNumber = [NSNumber numberWithDouble:lastClickCountEventTime];
eventNumber= [NSNumber numberWithUnsignedInt:event];
}
- [self performSelector: @selector(executeClickCountEvent:)
+ [self performSelector: @selector(executeClickCountEvent:)
withObject: [NSArray arrayWithObjects:eventNumber, timeNumber, nil]
afterDelay: maxClickTimeDifference];
} else {
[delegate remoteButton:event pressedDown: pressedDown clickCount:1];
- }
+ }
}