i3 - improved tiling WM


render_con: fix height rounding in aspect ratio computation

Patch status: merged

Patch by Clément Bœsch

Long description:

With a 484x292 window and proportion of 488x294, new_height is
291.590164 after the loop, causing a rounding issue leading to a window
of 484x291.

---
To reproduce the bug:
  wget http://lucy.pkh.me/youtube-free.webm
  mplayer youtube-free.webm

If you don't use vo sdl but xv/vdpau/gl/... the window will be 484x291
instead of 484x292. This is particularly visible with this video since
the scaling of the window will blur some of the characters of the video.

Here is a preview:
  http://b.pkh.me/ffplay.png FAIL
  http://b.pkh.me/mpv.png FAIL

While the problem looks indeed related to a rounding issue, I'm not sure
this fix is the proper solution.

Note: I'm sorry I wasn't able to run the testsuite (failing to install
X11::XCB because of missing pthread-stubs package or something) so I
hope everything is OK.

To apply this patch, use:
curl http://cr.i3wm.org/patch/147/raw.patch | git am

b/src/render.c

36
@@ -184,10 +184,10 @@ void render_con(Con *con, bool render_fullscreen) {
37
                     new_width--;
38
             }
39
             /* Center the window */
40
-            inset->y += ceil(inset->height / 2) - floor(new_height / 2);
41
+            inset->y += ceil(inset->height / 2) - floor((new_height + .5) / 2);
42
             inset->x += ceil(inset->width / 2) - floor(new_width / 2);
43
 
44
-            inset->height = new_height;
45
+            inset->height = new_height + .5;
46
             inset->width = new_width;
47
         }
48