Improve size in a number of pathological cases.
[enjoyable.git] / TargetToggleMouseScope.m
1 //
2 // TargetToggleMouseScope.m
3 // Enjoy
4 //
5 // Created by Yifeng Huang on 7/28/12.
6 //
7
8 #import "TargetToggleMouseScope.h"
9
10 #import "ApplicationController.h"
11 #import "JoystickController.h"
12
13 @implementation TargetToggleMouseScope
14
15 + (NSString *)serializationCode {
16 return @"mtoggle";
17 }
18
19 - (NSDictionary *)serialize {
20 return @{ @"type": @"mtoggle" };
21 }
22
23 + (Target *)targetDeserialize:(NSDictionary *)serialization
24 withConfigs:(NSArray *)configs {
25 TargetToggleMouseScope *target = [[TargetToggleMouseScope alloc] init];
26 return target;
27 }
28 - (void)trigger {
29 // FIXME: It's hacky to get at the controller this way, but it's
30 // also hacky to pass it. Shouldn't need to do either.
31 ApplicationController *ac = [NSApplication sharedApplication].delegate;
32 JoystickController *jc = ac.jsController;
33 [jc setFrontWindowOnly: ![jc frontWindowOnly]];
34 printf("Front window only: %d\n", [jc frontWindowOnly]);
35 }
36
37 @end