Frame shrinkage bug
Marko Rauhamaa
kaffe@rufus.w3.org
Fri, 21 Aug 1998 00:56:58 -0700
In X, the Frame objects shrink by 20 pixels vertically and by 8 pixels
horizontally from the preferred size. That, of course, causes the
contained components to be cramped into a smaller space and the results
are unusable.
For example, consider this small application:
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame {
class QuitCloser extends WindowAdapter {
public void windowClosing(WindowEvent event) { System.exit(0); }
}
public Test() {
setLayout(new BorderLayout());
add("North",new Button("Button"));
add("South",new Button("Button"));
addWindowListener(new QuitCloser());
}
public static void main(String[] args) {
Test window = new Test();
window.setTitle("Test");
window.pack();
window.setVisible(true);
}
}
It is supposed to have two buttons touching each other. Instead, it
produces two overlapping buttons. (Try it!)
I tried to locate the cause for the weird behavior in the kaffe awt
code. The immediate reason seems to be this: createWindow() (in
libraries/clib/awt/X/wnd.c) modifies the size of a frame by subtracting
X->titleBarHeight, X->bottomBarHeight and 2 * X->borderWidth from the
window bounds. The values of those variables are set in the initializer
of the Toolkit class (libraries/javalib/java/awt/Toolkit.java) with the
function wndSetFrameOffsets() to default values, which are
Defaults.TitleBarHeight = 20, Defaults.FrameBorderWidth = 4 and
Defaults.BottomBarHeight = 0.
I can't say I quite understand the rationale behind this shrinkage
mechanism since the frame decorations are _outside_ the frame window
(and depend totally on the window manager). The awt code seems to try to
reserve some hardcoded amount of space within the frame window for the
decorations.
Marko
Kaffe 1.0-b1
Red Hat Linux 4.2
--
Marko Rauhamaa mailto:marko.rauhamaa@iki.fi http://www.iki.fi/pacujo/
Suomenkielinen esperantokurssi http://www.iki.fi/pacujo/esperanto/kurssi/
Free Esperanto Course http://www.iki.fi/pacujo/esperanto/course/