LWJGL Forum

Archive => Resolved Bugs/RFE => Topic started by: Elviz on July 12, 2012, 01:11:30

Title: [FIXED] Mismatch between Display.getX/getY and setLocation
Post by: Elviz on July 12, 2012, 01:11:30
Based on the thread about the new Display.getX/getY API (http://lwjgl.org/forum/index.php/topic,4294.0.html) 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
Title: Re: [BUG] Mismatch between Display.getX/getY and setLocation
Post by: Matzon on July 12, 2012, 07:41:59
Agreed. Calling getX/y and then setLocation with that, intuitively, should not move the window.
Title: Re: [BUG] Mismatch between Display.getX/getY and setLocation
Post by: Matzon on July 14, 2012, 23:33:51
should be fixed in nightly ( > #1853)
Title: Re: [BUG] Mismatch between Display.getX/getY and setLocation
Post by: Elviz on July 16, 2012, 22:48:58
Confirmed working in r3782. Thanks!