|
From: <ma...@us...> - 2012-07-14 23:29:28
|
Revision: 3782
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3782&view=rev
Author: matzon
Date: 2012-07-14 23:29:21 +0000 (Sat, 14 Jul 2012)
Log Message:
-----------
fixed issue with win32 get x/y returning client-area coords
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-06-29 10:25:36 UTC (rev 3781)
+++ trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java 2012-07-14 23:29:21 UTC (rev 3782)
@@ -52,6 +52,7 @@
final class WindowsDisplay implements DisplayImplementation {
private static final int GAMMA_LENGTH = 256;
+ private static final int WM_WINDOWPOSCHANGED = 0x0047;
private static final int WM_MOVE = 0x0003;
private static final int WM_CANCELMODE = 0x001F;
private static final int WM_MOUSEMOVE = 0x0200;
@@ -1012,15 +1013,22 @@
captureMouse = -1;
}
return 0;
- case WM_MOVE:
- x = (int)(short)(lParam & 0xFFFF);
- y = (int)(short)(lParam >> 16);
- return defWindowProc(hwnd, msg, wParam, lParam);
+ case WM_WINDOWPOSCHANGED:
+ if(getWindowRect(hwnd, rect_buffer)) {
+ rect.copyFromBuffer(rect_buffer);
+ x = rect.top;
+ y = rect.bottom;
+ } else {
+ LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
+ }
+ return defWindowProc(hwnd, msg, wParam, lParam);
default:
return defWindowProc(hwnd, msg, wParam, lParam);
}
}
+ private native boolean getWindowRect(long hwnd, IntBuffer rectBuffer);
+
public int getX() {
return x;
}
Modified: trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c
===================================================================
--- trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2012-06-29 10:25:36 UTC (rev 3781)
+++ trunk/LWJGL/src/native/windows/org_lwjgl_opengl_Display.c 2012-07-14 23:29:21 UTC (rev 3782)
@@ -199,6 +199,18 @@
buffer[1] = point.y;
}
+
+JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getWindowRect(JNIEnv *env, jclass unused, jlong hwnd_int, jobject buffer_handle) {
+ HWND hwnd = (HWND)(INT_PTR)hwnd_int;
+ RECT *buffer = (RECT *)(*env)->GetDirectBufferAddress(env, buffer_handle);
+ jlong size = (*env)->GetDirectBufferCapacity(env, buffer_handle);
+ if (size < 4) {
+ throwFormattedRuntimeException(env, "Buffer size < 4", size);
+ return false;
+ }
+ return GetWindowRect(hwnd, buffer);
+}
+
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getForegroundWindow(JNIEnv *env, jclass unused) {
return (INT_PTR)GetForegroundWindow();
}
@@ -509,4 +521,5 @@
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
return TrackMouseEvent(&tme);
-}
\ No newline at end of file
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|