bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #17377] Various frame related methods in NSWindow return wrong resu


From: Quentin Mathé
Subject: [bug #17377] Various frame related methods in NSWindow return wrong results
Date: Wed, 9 Aug 2006 22:17:43 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.5) Gecko/20060731 Ubuntu/dapper-security Firefox/1.5.0.5

Follow-up Comment #3, bug #17377 (project gnustep):

I think I have found where the bug is located at least when backend
decorations are used.

In GSWindowDecorationView.m, there are the two following methods called by
their NSWindow counterparts.

+ (NSRect) contentRectForFrameRect: (NSRect)aRect
                         styleMask: (unsigned int)aStyle
{
  float t, b, l, r;

  [self offsets: &l : &r : &t : &b
   forStyleMask: aStyle];
  aRect.size.width -= l + r;
  aRect.size.height -= t + b;
  aRect.origin.x += l;
  aRect.origin.y += b;
  return aRect;
}

+ (NSRect) frameRectForContentRect: (NSRect)aRect
                         styleMask: (unsigned int)aStyle
{
  float t, b, l, r;

  [self offsets: &l : &r : &t : &b
   forStyleMask: aStyle];
  aRect.size.width += l + r;
  aRect.size.height += t + b;
  aRect.origin.x -= l;
  aRect.origin.y -= b;
  return aRect;
}

As we can see above, the important method is -offset::::forStyleMask:

In GSBackendWindowDecorationView (code pasted below), this method
-offset::::forStyleMask: is overriden with a dummy implementation instead of
calling the method similarly named in -back. 
This is curious, but the next method -screenOffsets::::forStyleMask: seems to
be precisely doing this. 


@implementation GSBackendWindowDecorationView

+(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b
   forStyleMask: (unsigned int)style
{
  *l = *r = *t = *b = 0.0;
}

+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b
   forStyleMask: (unsigned int)style
{
  [GSCurrentServer() styleoffsets: l : r : t : b : style];
}

+(NSRect) windowFrameRectForFrameRect: (NSRect)aRect
                            styleMask: (unsigned int)aStyle
{
  float l, r, t, b;
  [self offsets: &l : &r : &t : &b forStyleMask: aStyle];
  aRect.size.width -= l + r;
  aRect.size.height -= t + b;
  return aRect;
}

/*
Returns the content rect for a given window frame.
*/
+(NSRect) contentRectForWindowFrameRect: (NSRect)aRect
                              styleMask: (unsigned int)aStyle
{
  return aRect;
}

@end

I have to state that I don't understand the purpose of all these 'screen'
prefixed methods in GSWindowDecorationView.m. 
Finally other methods like windowFrameRectForFrameRect:styleMask:,
-contentRectForWindowFrameRect:styleMask:, -screenRectForFrameRect:styleMask:
etc. makes no sense at first sight. 
Any ideas ?

For example, -frameRectForContentRect:styleMask: is identical to
-screenRectForFrameRect:styleMask:... Well not exactly since the latter looks
like the correct method to use when backend decorations are turned on if you
want to compute the window frame rect from its content view rect (the normal
role of the former).

+ (NSRect) frameRectForContentRect: (NSRect)aRect
                         styleMask: (unsigned int)aStyle
{
  float t, b, l, r;

  [self offsets: &l : &r : &t : &b
   forStyleMask: aStyle];
  aRect.size.width += l + r;
  aRect.size.height += t + b;
  aRect.origin.x -= l;
  aRect.origin.y -= b;
  return aRect;
}

+ (NSRect) screenRectForFrameRect: (NSRect)aRect
                        styleMask: (unsigned int)aStyle
{
  float t, b, l, r;

  [self screenOffsets: &l : &r : &t : &b
         forStyleMask: aStyle];
  aRect.size.width += l + r;
  aRect.size.height += t + b;
  aRect.origin.x -= l;
  aRect.origin.y -= b;
  return aRect;
}

I think there are perhaps similar issues in GSStandardDecorationView leading
to incorrect window border/titlebar size computation.

Quentin.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=17377>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]