Skip to content
Browse files

Cosmetics.

  • Loading branch information...
1 parent 8bb8c7b commit e1114c57b239da506ae7a9adfee25977550c436c @pdherbemont pdherbemont committed
Showing with 65 additions and 60 deletions.
  1. +65 −60 Sources/VLCApplication.m
View
125 Sources/VLCApplication.m
@@ -24,6 +24,7 @@
#import "VLCApplication.h"
#import "VLCStyledVideoWindowController.h"
#import "VLCMediaDocument.h"
+#import "VLCDocumentController.h"
#import <IOKit/hidsystem/ev_keymap.h> /* for the media key support */
/*****************************************************************************
@@ -71,66 +72,6 @@ - (void)dealloc
[super dealloc];
}
-- (void)applicationDidBecomeActiveOrInactive:(NSNotification *)notification
-{
- BOOL hasResignedActive = [[notification name] isEqualToString:@"NSApplicationWillResignActiveNotification"];
- if ((hasResignedActive && !_isActiveInBackground ) || !_hasMediaKeySupport)
- _isActive = NO;
- else
- _isActive = YES;
-}
-
-- (void)coreChangedMediaKeySupportSetting:(NSNotification *)notification
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- _isActive = _hasMediaKeySupport = [defaults boolForKey:@"ControlWithMediaKeys"];
- _isActiveInBackground = [defaults boolForKey:@"ControlWithMediaKeysInBackground"];
- if ([defaults boolForKey:@"ControlWithHIDRemote"])
- [_remote startListening:self];
- else
- [_remote stopListening:self];
-}
-
-
-- (void)sendEvent:(NSEvent*)event
-{
- if (_isActive) {
- if ([event type] == NSSystemDefined && [event subtype] == 8) {
- int keyCode = ([event data1] & 0xFFFF0000) >> 16;
- int keyFlags = [event data1] & 0x0000FFFF;
- int keyState = ((keyFlags & 0xFF00) >> 8) == 0xA;
- int keyRepeat = keyFlags & 0x1;
-
- VLCMediaPlayer *mediaPlayer = [[[[NSDocumentController sharedDocumentController] currentDocument] mediaListPlayer] mediaPlayer];
-
- if (keyCode == NX_KEYTYPE_PLAY && keyState == 0 && [mediaPlayer canPause])
- [mediaPlayer pause];
-
- if (keyCode == NX_KEYTYPE_FAST && !_hasJustJumped) {
- if (keyRepeat == 1) {
- [mediaPlayer shortJumpForward];
- _hasJustJumped = YES;
- [self performSelector:@selector(resetJump) withObject:nil afterDelay:0.25];
- }
- }
-
- if (keyCode == NX_KEYTYPE_REWIND && !_hasJustJumped) {
- if (keyRepeat == 1) {
- [mediaPlayer shortJumpBackward];
- _hasJustJumped = YES;
- [self performSelector:@selector(resetJump) withObject:nil afterDelay:0.25];
- }
- }
- }
- }
- [super sendEvent:event];
-}
-
-- (void)resetJump
-{
- _hasJustJumped = NO;
-}
-
#pragma mark -
#pragma mark Apple Remote Control
@@ -208,6 +149,70 @@ - (void) appleRemoteButton:(AppleRemoteEventIdentifier)buttonIdentifier pressedD
NSBeep();
}
+- (void)applicationDidBecomeActiveOrInactive:(NSNotification *)notification
+{
+ BOOL hasResignedActive = [[notification name] isEqualToString:@"NSApplicationWillResignActiveNotification"];
+ if ((hasResignedActive && !_isActiveInBackground ) || !_hasMediaKeySupport)
+ _isActive = NO;
+ else
+ _isActive = YES;
+}
+
+- (void)coreChangedMediaKeySupportSetting:(NSNotification *)notification
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ _isActive = _hasMediaKeySupport = [defaults boolForKey:@"ControlWithMediaKeys"];
+ _isActiveInBackground = [defaults boolForKey:@"ControlWithMediaKeysInBackground"];
+ if ([defaults boolForKey:@"ControlWithHIDRemote"])
+ [_remote startListening:self];
+ else
+ [_remote stopListening:self];
+}
+
+
+- (void)sendEvent:(NSEvent*)event
+{
+ if (_isActive) {
+ if ([event type] == NSSystemDefined && [event subtype] == 8) {
+ int keyCode = ([event data1] & 0xFFFF0000) >> 16;
+ int keyFlags = [event data1] & 0x0000FFFF;
+ int keyState = ((keyFlags & 0xFF00) >> 8) == 0xA;
+ int keyRepeat = keyFlags & 0x1;
+
+ VLCMediaPlayer *mediaPlayer = [[[[NSDocumentController sharedDocumentController] currentDocument] mediaListPlayer] mediaPlayer];
+
+ if (keyCode == NX_KEYTYPE_PLAY && keyState == 0 && [mediaPlayer canPause])
+ [mediaPlayer pause];
+
+ if (keyCode == NX_KEYTYPE_FAST && !_hasJustJumped) {
+ if (keyRepeat == 1) {
+ [mediaPlayer shortJumpForward];
+ _hasJustJumped = YES;
+ [self performSelector:@selector(resetJump) withObject:nil afterDelay:0.25];
+ }
+ }
+
+ if (keyCode == NX_KEYTYPE_REWIND && !_hasJustJumped) {
+ if (keyRepeat == 1) {
+ [mediaPlayer shortJumpBackward];
+ _hasJustJumped = YES;
+ [self performSelector:@selector(resetJump) withObject:nil afterDelay:0.25];
+ }
+ }
+ }
+ }
+ [super sendEvent:event];
+}
+
+- (void)resetJump
+{
+ _hasJustJumped = NO;
+}
+
+#pragma mark -
+#pragma mark IB Action
+
+
- (IBAction)reportBug:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://trac.videolan.org"]];

0 comments on commit e1114c5

Please sign in to comment.
Something went wrong with that request. Please try again.