Hello Guest

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

  • 3 Replies
  • 6732 Views
*

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:

Code: [Select]
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:

Code: [Select]
x=3, y=22
x=6, y=44
x=9, y=66
x=12, y=88
x=15, y=110

*

Offline Matzon

  • *****
  • 2242
Re: [BUG] Mismatch between Display.getX/getY and setLocation
« Reply #1 on: July 12, 2012, 07:41:59 »
Agreed. Calling getX/y and then setLocation with that, intuitively, should not move the window.

*

Offline Matzon

  • *****
  • 2242
Re: [BUG] Mismatch between Display.getX/getY and setLocation
« Reply #2 on: July 14, 2012, 23:33:51 »
should be fixed in nightly ( > #1853)

*

Elviz

Re: [BUG] Mismatch between Display.getX/getY and setLocation
« Reply #3 on: July 16, 2012, 22:48:58 »
Confirmed working in r3782. Thanks!