Updating ITKit with additions to support Haven development.
[ITKit.git] / ITPivotWindowEffect.m
old mode 100755 (executable)
new mode 100644 (file)
index 400d931..0d01e1f
 {
     int hPos = [_window horizontalPosition];
     int vPos = [_window verticalPosition];
 {
     int hPos = [_window horizontalPosition];
     int vPos = [_window verticalPosition];
+       NSRect winFrame = [_window frame];
 
     if ( (hPos == ITWindowPositionCenter) || (vPos == ITWindowPositionMiddle) ) {
     
         CGAffineTransform transform;
         NSPoint translation;
         
 
     if ( (hPos == ITWindowPositionCenter) || (vPos == ITWindowPositionMiddle) ) {
     
         CGAffineTransform transform;
         NSPoint translation;
         
-        translation.x = ( -([_window frame].origin.x) ) ;
-        translation.y = -( [[_window screen] frame].size.height - [_window frame].origin.y - [_window frame].size.height );
+        translation.x = -winFrame.origin.x;
+        translation.y = winFrame.origin.y + winFrame.size.height - [[NSScreen mainScreen] frame].size.height;
 
         transform = CGAffineTransformMakeTranslation( translation.x, translation.y );
         
 
         transform = CGAffineTransformMakeTranslation( translation.x, translation.y );
         
                               (CGSWindowID)[_window windowNumber],
                               transform);
     } else {
                               (CGSWindowID)[_window windowNumber],
                               transform);
     } else {
-        
         float  degAngle;
         float  degAngle;
-        NSRect windowFrame = [_window frame];
-        NSRect screenFrame = [[_window screen] frame];
-        float  translateX = 0;
-        float  translateY = 0;
         CGAffineTransform transform;
         
         if ( vPos == ITWindowPositionBottom ) {
         CGAffineTransform transform;
         
         if ( vPos == ITWindowPositionBottom ) {
         }
         
         degAngle  = (angle * (pi / 180));
         }
         
         degAngle  = (angle * (pi / 180));
-        transform = CGAffineTransformMakeRotation(degAngle);
-        
-        if ( vPos == ITWindowPositionBottom ) {
-            transform.ty = ( windowFrame.size.height + windowFrame.origin.y);
-            translateY   = -(screenFrame.size.height);
+               transform = CGAffineTransformMakeRotation(degAngle);
+               
+               if ( vPos == ITWindowPositionBottom ) {
+            transform.ty = winFrame.size.height;
         } else if ( vPos == ITWindowPositionTop ) {
         } else if ( vPos == ITWindowPositionTop ) {
-            transform.ty = -( screenFrame.size.height - windowFrame.origin.y - windowFrame.size.height );
-            translateY   = 0;
+                       transform.ty = 0;
         }
         
         if ( hPos == ITWindowPositionLeft ) {
         }
         
         if ( hPos == ITWindowPositionLeft ) {
-            transform.tx = -( windowFrame.origin.x );
-            translateX   = 0;
+            transform.tx = 0;
         } else if ( hPos == ITWindowPositionRight ) {
         } else if ( hPos == ITWindowPositionRight ) {
-            transform.tx = ( screenFrame.size.width - windowFrame.origin.x );
-            translateX   = -(screenFrame.size.width);
+                       transform.tx = winFrame.size.width;
         }
         }
-        
+               
+               transform = CGAffineTransformTranslate(transform, -winFrame.origin.x - transform.tx, winFrame.origin.y + winFrame.size.height - [[NSScreen mainScreen] frame].size.height - transform.ty);
         CGSSetWindowTransform([NSApp contextID],
                               (CGSWindowID)[_window windowNumber],
         CGSSetWindowTransform([NSApp contextID],
                               (CGSWindowID)[_window windowNumber],
-                              CGAffineTransformTranslate( transform,
-                                                          translateX,
-                                                          translateY ) );
+                                                         transform );
     }
 }
 
     }
 }