[BUG] Mouse.getX/Y do not account for window motion

Started by dlubarov, July 30, 2012, 07:46:34

Previous topic - Next topic

dlubarov

Since Mouse.getX/Y give the position of the mouse relative to the window, I expected them to produce different results when the location of the mouse or the window changes.

I know this is a corner case, but it came up when I was trying to make an undecorated window draggable. If the user clicks to start dragging at (1, 1), moves the cursor to (2, 2) and holds it down, my window will drift away but Mouse.getX/Y will keep returning (2, 2).

To reproduce:
Display.create();
System.out.printf("before: (%d, %d)\n", Mouse.getX(), Mouse.getY());
Display.setLocation(Display.getX() + 100, Display.getY() + 100);
System.out.printf("after: (%d, %d)\n", Mouse.getX(), Mouse.getY());