Win32: Fix Mouse.setCursorLocation()
This commit is contained in:
parent
019a1418c6
commit
fdcf050747
|
@ -110,18 +110,8 @@ void closeWindow(HWND *hwnd, HDC *hdc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated) {
|
||||||
* Create a window with the specified title, position, size, and
|
DWORD exstyle, windowflags;
|
||||||
* fullscreen attribute. The window will have DirectInput associated
|
|
||||||
* with it.
|
|
||||||
*
|
|
||||||
* Returns true for success, or false for failure
|
|
||||||
*/
|
|
||||||
HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated)
|
|
||||||
{
|
|
||||||
RECT clientSize;
|
|
||||||
int exstyle, windowflags;
|
|
||||||
HWND new_hwnd;
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
exstyle = WS_EX_APPWINDOW | WS_EX_TOPMOST;
|
exstyle = WS_EX_APPWINDOW | WS_EX_TOPMOST;
|
||||||
windowflags = WS_POPUP;
|
windowflags = WS_POPUP;
|
||||||
|
@ -133,6 +123,24 @@ HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height
|
||||||
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
||||||
}
|
}
|
||||||
windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
||||||
|
*windowflags_return = windowflags;
|
||||||
|
*exstyle_return = exstyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a window with the specified title, position, size, and
|
||||||
|
* fullscreen attribute. The window will have DirectInput associated
|
||||||
|
* with it.
|
||||||
|
*
|
||||||
|
* Returns true for success, or false for failure
|
||||||
|
*/
|
||||||
|
HWND createWindow(LPCTSTR window_class_name, int x, int y, int width, int height, bool fullscreen, bool undecorated)
|
||||||
|
{
|
||||||
|
RECT clientSize;
|
||||||
|
DWORD exstyle, windowflags;
|
||||||
|
HWND new_hwnd;
|
||||||
|
|
||||||
|
getWindowFlags(&windowflags, &exstyle, fullscreen, indecorated);
|
||||||
|
|
||||||
// If we're not a fullscreen window, adjust the height to account for the
|
// If we're not a fullscreen window, adjust the height to account for the
|
||||||
// height of the title bar (unless undecorated)
|
// height of the title bar (unless undecorated)
|
||||||
|
|
|
@ -79,6 +79,11 @@ extern void closeWindow(HWND *hwnd, HDC *hdc);
|
||||||
*/
|
*/
|
||||||
extern HWND createDummyWindow(int x, int y);
|
extern HWND createDummyWindow(int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return appropriate window and extended style flags from the given fullscreen and undecorated property
|
||||||
|
*/
|
||||||
|
extern void getWindowFlags(DWORD *windowflags_return, DWORD *exstyle_return, bool fullscreen, bool undecorated);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a window with the specified position, size, and
|
* Create a window with the specified position, size, and
|
||||||
* fullscreen attribute. The window will have DirectInput associated
|
* fullscreen attribute. The window will have DirectInput associated
|
||||||
|
|
|
@ -354,14 +354,36 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_pollMouse(JNIEnv * env
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setCursorPosition
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setCursorPosition
|
||||||
(JNIEnv * env, jobject self, jint x, jint y) {
|
(JNIEnv * env, jobject self, jint x, jint y) {
|
||||||
|
DWORD windowflags, exstyle;
|
||||||
int transformed_x, transformed_y;
|
int transformed_x, transformed_y;
|
||||||
RECT window_rect;
|
RECT window_rect;
|
||||||
|
RECT client_rect;
|
||||||
|
RECT adjusted_client_rect;
|
||||||
|
|
||||||
|
int left_border_width;
|
||||||
|
int bottom_border_width;
|
||||||
|
|
||||||
|
getWindowFlags(&windowflags, &extyle, isFullscreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"));
|
||||||
|
if (!GetClientRect(getCurrentHWND(), &client_rect)) {
|
||||||
|
printfDebugJava(env, "GetClientRect failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
adjusted_client_rect = client_rect;
|
||||||
|
if (!AdjustWindowRectEx(&adjusted_client_rect, windowflags, FALSE, exstyle)) {
|
||||||
|
printfDebugJava(env, "AdjustWindowRectEx failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!GetWindowRect(getCurrentHWND(), &window_rect)) {
|
if (!GetWindowRect(getCurrentHWND(), &window_rect)) {
|
||||||
printfDebugJava(env, "GetWindowRect failed");
|
printfDebugJava(env, "GetWindowRect failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
transformed_x = window_rect.left + x;
|
left_border_width = -adjusted_client_rect.left;
|
||||||
transformed_y = window_rect.bottom - y;
|
bottom_border_width = adjusted_client_rect.bottom - client_rect.bottom;
|
||||||
|
|
||||||
|
transformed_x = window_rect.left + left_border_width + x;
|
||||||
|
transformed_y = window_rect.bottom - bottom_border_width - y;
|
||||||
if (!SetCursorPos(transformed_x, transformed_y))
|
if (!SetCursorPos(transformed_x, transformed_y))
|
||||||
printfDebugJava(env, "SetCursorPos failed");
|
printfDebugJava(env, "SetCursorPos failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,24 +371,14 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_init(JNIEnv *env, j
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_reshape(JNIEnv *env, jobject self, jint x, jint y, jint width, jint height) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_reshape(JNIEnv *env, jobject self, jint x, jint y, jint width, jint height) {
|
||||||
int exstyle, windowflags;
|
DWORD exstyle, windowflags;
|
||||||
RECT clientSize;
|
RECT clientSize;
|
||||||
|
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFullScreen) {
|
getWindowFlags(&windowflags, &exstyle, isFullscreen, getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated"));
|
||||||
exstyle = WS_EX_APPWINDOW | WS_EX_TOPMOST;
|
|
||||||
windowflags = WS_POPUP;
|
|
||||||
} else if (getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated")) {
|
|
||||||
exstyle = WS_EX_APPWINDOW;
|
|
||||||
windowflags = WS_POPUP;
|
|
||||||
} else {
|
|
||||||
exstyle = WS_EX_APPWINDOW;
|
|
||||||
windowflags = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
|
|
||||||
}
|
|
||||||
windowflags = windowflags | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
|
|
||||||
|
|
||||||
// If we're not a fullscreen window, adjust the height to account for the
|
// If we're not a fullscreen window, adjust the height to account for the
|
||||||
// height of the title bar:
|
// height of the title bar:
|
||||||
|
|
Loading…
Reference in New Issue