First Revision (from Archive)
[~jspiros/WindowBlur.git] / WindowBlurSIMBL.m
1 //
2 //  WindowBlurSIMBL.m
3 //  WindowBlur
4 //
5 //  Created by Joseph Spiros on 5/12/09.
6 //  Copyright 2009 __MyCompanyName__. All rights reserved.
7 //
8
9 #import "WindowBlurSIMBL.h"
10 #import "WindowBlurWindowHack.h"
11 #import <objc/objc-class.h>
12
13 void MethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel)
14 {
15     Method orig_method = nil, alt_method = nil;
16         
17     // First, look for the methods
18     orig_method = class_getInstanceMethod(aClass, orig_sel);
19     alt_method = class_getInstanceMethod(aClass, alt_sel);
20         
21     // If both are found, swizzle them
22     if ((orig_method != nil) && (alt_method != nil))
23         {
24         char *temp1;
25         IMP temp2;
26                 
27         temp1 = orig_method->method_types;
28         orig_method->method_types = alt_method->method_types;
29         alt_method->method_types = temp1;
30                 
31         temp2 = orig_method->method_imp;
32         orig_method->method_imp = alt_method->method_imp;
33         alt_method->method_imp = temp2;
34         }
35 }
36
37 @implementation WindowBlurSIMBL
38
39 + (void)load {
40         [WindowBlurWindowHack poseAsClass:[NSWindow class]];
41 }
42
43 @end