JDK-6357489 : GraphicsEnvironment.getMaximumWindowBounds() does not work correctly on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2005-12-01
  • Updated: 2011-01-19
  • Resolved: 2005-12-06
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
SuSE 9.2:
Linux io 2.6.8-24.11-smp #1 SMP Fri Jan 14 13:01:26 UTC 2005 i686 i686 i386 GNU/Linux

or

RHEL3:
Linux dio.tomosw.bruker.de 2.4.21-27.0.2.EL #1 Wed Jan 12 23:46:37 EST
2005 i686 i686 i386 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
SuSE 9,2:
kde-config --version
Qt: 3.3.3
KDE: 3.3.0
kde-config: 1.0

or

RHEL3:
GNOME 2.2.2

A DESCRIPTION OF THE PROBLEM :
The method java.awt.GraphicsEnvironment.getMaximumWindowBounds() does not consider the task bar of KDE or GNOME as documented. Running the attached small program on a Windows machine gives the size of the desktop without the task bar which is correct. On a linux system the test program always returns the size of the root window without taking the task bar into account.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test program which prints the rectangle returned from java.awt.GraphicsEnvironment.getMaximumWindowBounds().

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It is expected that the rectangle returned from java.awt.GraphicsEnvironment.getMaximumWindowBounds() gives the size of the desktop without the task bar.
ACTUAL -
The rectangle returned from java.awt.GraphicsEnvironment.getMaximumWindowBounds() does not take the size of the task bar into account.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;

public class MaxWindowBounds {
    public static void main(String[] args) {
        MaxWindowBounds mwb = new MaxWindowBounds();
        JFrame frame = mwb.createFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

    public MaxWindowBounds() {
    }

    public JFrame createFrame() {
        JFrame frame = new JFrame("MaxWindowBounds");
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        Rectangle bounds = env.getMaximumWindowBounds();
        System.out.println("bounds = "+bounds);
        return frame;
    }
}
---------- END SOURCE ----------

Comments
EVALUATION SunGraphicsEnvironment.getUsableBounds() obtain screen insets via Toolkit.getScreenInsets(gc) and they are zero on Linux for M/XToolkits both. There is a WToolkit routine to get insets on Windows by SystemParametersInfo but on XToolkit/MToolkit getScreenInsets() always return zeroes. This might be considered as an intentional implemetation for MToolkit but on XAWT it would be reasonable to know correct screen size. Xlib seems doesn't support this functionality but we should consider properties for particular WM as well. My version of _NET specification seems doesn't contain anything about it.
05-12-2005