[haiku-development] SetZoomLimits

  • From: Sean Healy <jalopeura@xxxxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Mon, 3 Sep 2018 14:59:02 +0000

I installed hrev52302 on Friday (over hrev51446 from Sep 2017), and a  
regression test on one of my personal projects is now failing. Simplified  
version follows:

window->SetZoomLimits(100,100);
window->Zoom();
bounds = window->Bounds();
if (bounds->Width() == 100 && bounds->Height() == 100) {
// etc.

The bounds are 0,0,99,99 but they used to be 0,0,100,100.

I tried it with 101,101, and it works as expected.

It looks like the culprit is a change from Oct 2017 (b1b8467; github  
doesn't make it easy to see the hrev tags), which was intended to make  
Zoom respect the Deskbar. Specifically, these two lines:

    zoomArea.InsetBy(0, roundf((zoomArea.Height() - maxZoomHeight) / 2));

and

    zoomArea.InsetBy(roundf((zoomArea.Width() - maxZoomWidth) / 2), 0);

But the rounding was already there; this change just changes the first  
term in the subtraction from the whole screen to the screen minus the  
Deskbar area.

So this potential for a one-pixel difference was always there, and I was  
just lucky before.

My question is, is this a bug (albeit a very minor one)? Should the zoom  
rectangle be adjusted when the rounding has shaved off a pixel? If so, I  
can create a ticket and upload a patch. Otherwise, I'll adjust my test to  
take a potential one-pixel difference into account.

Other related posts: