X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fbackend%2FSwingSessionInfo.java;h=2f74d7012130e0eeda1f44c4721396d645493b35;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=6d1c644fd5498ad571031fbe8830a8a81985288b;hpb=a2855f1dd3ca42b61ac4c47a18e2253ea32dd56e;p=fanfix.git diff --git a/src/jexer/backend/SwingSessionInfo.java b/src/jexer/backend/SwingSessionInfo.java index 6d1c644..2f74d70 100644 --- a/src/jexer/backend/SwingSessionInfo.java +++ b/src/jexer/backend/SwingSessionInfo.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -179,6 +179,14 @@ public class SwingSessionInfo implements SessionInfo { Insets insets = swing.getInsets(); int width = swing.getWidth() - insets.left - insets.right; int height = swing.getHeight() - insets.top - insets.bottom; + // In theory, if Java reported pixel-perfect dimensions, the + // expressions above would precisely line up with the requested + // window size from SwingComponent.setDimensions(). In practice, + // there appears to be a small difference. Add half a text cell in + // both directions before the division to hopefully reach the same + // result as setDimensions() was supposed to give us. + width += (textWidth / 2); + height += (textHeight / 2); windowWidth = width / textWidth; windowHeight = height / textHeight; @@ -187,7 +195,6 @@ public class SwingSessionInfo implements SessionInfo { swing.getWidth(), swing.getHeight(), windowWidth, windowHeight); */ - } // ------------------------------------------------------------------------