[FIXED] Mismatch between Display.getX/getY and setLocation

Started by Elviz, July 12, 2012, 01:11:30

Previous topic - Next topic

Elviz

Based on the thread about the new Display.getX/getY API and the Javadoc, it is my understanding that these two methods are supposed to return the coordinates of the actual window when in windowed mode.

However, the values reported by LWJGL (r3779) on Windows XP give the location of the client area instead, thus excluding trim such as the window border and title bar. As a consequence, calling Display.setLocation with those coordinates will move the window to a different location.

Test case:

import org.lwjgl.opengl.*;

public class WindowLocationTest {
  public static void main(String[] args) {
    try {
      Display.setDisplayMode(new DisplayMode(640, 480));
      Display.setLocation(0, 0);
      Display.create();
      
      for (int i = 0; i < 5; i++) {
        int x = Display.getX();
        int y = Display.getY();
        
        System.out.println("x=" + x + ", y=" + y);
        
        Display.setLocation(x, y);
      }
      
      Display.destroy();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}


Output on my machine:

x=3, y=22
x=6, y=44
x=9, y=66
x=12, y=88
x=15, y=110

Matzon

Agreed. Calling getX/y and then setLocation with that, intuitively, should not move the window.

Matzon


Elviz