discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSWindow frame with GSScaleFactor


From: dr_clow
Subject: Re: NSWindow frame with GSScaleFactor
Date: Sun, 13 Aug 2023 21:57:28 -0500

Confirmed: I went ahead and checked out a copy of lib-gui, made some changes and loaded the library, changed the following in GSWindowDecorationView.m do divide by 2 (which was my scale factor) and the content shifted appropriately. I included the fix below but also did a pull request. 


TEST (NOT FIX)
[self offsets: &l : &r : &t : &b forStyleMask: aStyle];
  aRect.size.width -= (l + r)/2;
  aRect.size.height -= (t + b)/2;
  aRect.origin.x += (l/2);
  aRect.origin.y += (b/2);

It worked (see images below)

I refactored the code the follow and did a pull request. 

FIX: 

 if (0 == (aStyle & NSUnscaledWindowMask))
    {
      // FIXME: This method should probably take a screen parameter
      // rather than assuming the mainScreen

      CGFloat factor = [[NSScreen mainScreen] userSpaceScaleFactor]; 

      aRect.size.width -= (l + r)/factor;
      aRect.size.height -= (t + b)/factor;
      aRect.origin.x += (l/factor);
      aRect.origin.y += (b/factor);
      
      aRect = RectWithSizeScaledByFactor(aRect, 1/factor);
    } else {
  aRect.size.width -= l + (r);
  aRect.size.height -= t + (b);
  aRect.origin.x += (l);
  aRect.origin.y += (b);
    }


Screenshot 2023-08-13 at 9.05.03 PM.pngScreenshot 2023-08-13 at 9.13.13 PM.png

On Aug 13, 2023, at 8:35 PM, dr_clow@me.com wrote:

I am trying to investigate the math issues facing GNUStep layout system when GSScale is set to something non-1. I am trying to account for all the math that layouts the contentView (I have been looking into both GSDecorationView and NSWindow) . Just a couple questions: 

1) In NSWindow.m, line 1122, is there a reason 1 is added? 

_minimumSize = NSMakeSize(_frame.size.width - contentRect.size.width + 1,
                            _frame.size.height - contentRect.size.height + 1);

2) Where is styleoffsets defined? I see on line 793 in GSDisplaySever.m the following

- (void) styleoffsets: (float*) l : (float*) r : (float*) t : (float*) b 
    : (unsigned int) style
{
  [self subclassResponsibility: _cmd];
}

My hunch is that when GSWindowDecoration view calls this  [GSCurrentServer() styleoffsets: l : r : t : b : style]; on line 588, it needs to multiple the results by the scale factor?

Because the content is currently shifted by a combination of the GSFactor and title bar height (which I am changing in the Defaults)  to confirm that these are the factors that is creating the offset. 


reply via email to

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