--- gui/Source/NSView.m	2004-10-18 08:48:15.000000000 +0700
+++ gui-fixview/Source/NSView.m	2005-03-12 05:45:19.041343664 +0700
@@ -268,11 +268,9 @@
   _bounds.origin = NSZeroPoint;		// Set bounds rectangle
   _bounds.size = _frame.size;
 
-  _frameMatrix = [NSAffineTransform new];	// Map fromsuperview to frame
   _boundsMatrix = [NSAffineTransform new];	// Map fromsuperview to bounds
   _matrixToWindow = [NSAffineTransform new];	// Map to window coordinates
   _matrixFromWindow = [NSAffineTransform new];	// Map from window coordinates
-  [_frameMatrix setFrameOrigin: _frame.origin];
 
   _sub_views = [NSMutableArray new];
   _tracking_rects = [NSMutableArray new];
@@ -399,7 +397,7 @@
 
   RELEASE(_matrixToWindow);
   RELEASE(_matrixFromWindow);
-  RELEASE(_frameMatrix);
+  TEST_RELEASE(_frameMatrix);
   RELEASE(_boundsMatrix);
   TEST_RELEASE(_sub_views);
   TEST_RELEASE(_tracking_rects);
@@ -881,11 +879,6 @@
   _bounds.size = frameRect.size;
   
 
-  if (changedOrigin)
-    {
-      [_frameMatrix setFrameOrigin: _frame.origin];
-    }
-
   if (changedSize && _is_rotated_or_scaled_from_base)
     {
       [self _updateBoundsMatrix];
@@ -913,7 +906,6 @@
       (*invalidateImp)(self, invalidateSel);
     }
   _frame.origin = newOrigin;
-  [_frameMatrix setFrameOrigin: _frame.origin];
 
   if (_post_frame_changes)
     {
@@ -965,10 +957,17 @@
 
 - (void) setFrameRotation: (float)angle
 {
+  /* no frame matrix, create one since it is needed for rotation */
+  if (_frameMatrix == nil)
+  {
+	  _frameMatrix = [NSAffineTransform new];	// Map fromsuperview to frame
+  }
+
   if (_coordinates_valid)
     {
       (*invalidateImp)(self, invalidateSel);
     }
+
   [_frameMatrix setFrameRotation: angle];
   _is_rotated_from_base = _is_rotated_or_scaled_from_base = YES;
 
@@ -1910,10 +1909,14 @@
 		  NSRect	subviewFrame = subview->_frame;
 		  BOOL		intersectCalculated = NO;
 
-		  if ([subview->_frameMatrix isRotated])
+		  if (subview->_frameMatrix) // assume rotation
 		    {
-		      [subview->_frameMatrix boundingRectFor: subviewFrame
-						     result: &subviewFrame];
+				NSRect r;
+				r.origin = NSZeroPoint;
+				r.size = subviewFrame.size;
+		      [subview->_frameMatrix boundingRectFor: r
+											  result: &r];
+			  subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
 		    }
 
 		  /*
@@ -2039,9 +2042,15 @@
 	      NSRect	isect;
 	      BOOL	intersectCalculated = NO;
 
-	      if ([subview->_frameMatrix isRotated] == YES)
-		[subview->_frameMatrix boundingRectFor: subviewFrame
-					       result: &subviewFrame];
+	      if (subview->_frameMatrix != nil)
+		  {
+			  NSRect r;
+			  r.origin = NSZeroPoint;
+			  r.size = subviewFrame.size;
+		      [subview->_frameMatrix boundingRectFor: r
+											  result: &r];
+			  subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
+		  }
 
 	      /*
 	       * Having drawn ourself into the rect, we must make sure that
@@ -2643,10 +2652,23 @@
   As a special case, always assume that it's a hit if our _super_view is nil,
   ie. if we're the top-level view in a window.
   */
-  if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
-    return nil;
 
-  p = [self convertPoint: aPoint fromView: _super_view];
+  if (_is_rotated_or_scaled_from_base)
+  {
+	  p = [self convertPoint: aPoint fromView: _super_view];
+	  if (!NSPointInRect (p, _bounds))
+	  {
+		  return nil;
+	  }
+  }
+  else if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
+  {
+	  return nil;
+  }
+  else
+  {
+	  p = [self convertPoint: aPoint fromView: _super_view];
+  }
 
   if (_rFlags.has_subviews)
     {
@@ -3794,7 +3816,7 @@
   [super initWithCoder: aDecoder];
 
   // initialize these here, since they're needed in either case.
-  _frameMatrix = [NSAffineTransform new];     // Map fromsuperview to frame
+  //_frameMatrix = [NSAffineTransform new];     // Map fromsuperview to frame
   _boundsMatrix = [NSAffineTransform new];    // Map fromsuperview to bounds
   _matrixToWindow = [NSAffineTransform new];  // Map to window coordinates
   _matrixFromWindow = [NSAffineTransform new];// Map from window coordinates
@@ -3808,7 +3830,7 @@
       if ([aDecoder containsValueForKey: @"NSFrame"])
 	{
 	  _frame = [aDecoder decodeRectForKey: @"NSFrame"];
-	  [_frameMatrix setFrameOrigin: _frame.origin];
+//	  [_frameMatrix setFrameOrigin: _frame.origin];
 	}
       self = [self initWithFrame: _frame];
       
@@ -3854,7 +3876,7 @@
       
       _bounds.origin = NSZeroPoint;
       _bounds.size = _frame.size;
-      [_frameMatrix setFrameOrigin: _frame.origin];
+//      [_frameMatrix setFrameOrigin: _frame.origin];
       
       rect = [aDecoder decodeRect];
       [self setBounds: rect];
@@ -3990,7 +4012,12 @@
 
 - (float) frameRotation
 {
+	if (_frameMatrix != nil)
+	{
   return [_frameMatrix rotationAngle];
+	}
+
+	return 0.0;
 }
 
 - (BOOL) postsFrameChangedNotifications
@@ -4205,7 +4232,23 @@
 	  NSAffineTransform	*pMatrix = [_super_view _matrixToWindow];
 
 	  [_matrixToWindow takeMatrixFromTransform: pMatrix];
+
+
+	  /* prepend translation */
+	  NSAffineTransform *tMatrix = _matrixToWindow;
+	  tMatrix->matrix.tX = NSMinX(_frame) * tMatrix->matrix.m11 +
+						   NSMinY(_frame) * tMatrix->matrix.m21 +
+						   tMatrix->matrix.tX;
+	  tMatrix->matrix.tY = NSMinX(_frame) * tMatrix->matrix.m12 +
+						   NSMinY(_frame) * tMatrix->matrix.m22 +
+						   tMatrix->matrix.tY;
+
+	  /* prepend rotation */
+	  if (_frameMatrix != nil)
+	  {
 	  (*preImp)(_matrixToWindow, preSel, _frameMatrix);
+	  }
+
 	  if (_rFlags.flipped_view != wasFlipped)
 	    {
 	      /*
