From 976e47291d052caab4b101d900270a073a3bbb55 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 24 Dec 2011 03:24:29 +0100 Subject: NEWT Screen: Add virtual top-left origin getX()/getY() ; WindowsWindow.c: allow negative coordinates - ScreenImpl: - Use Point & Dimension for holding virtual origin and size - updateScreenSize() -> updateVirtualScreenOriginAndSize() - DimensionImmutable getNativeScreenSizeImpl() -> void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) - WindowImpl setFullscreen(true): Use Screen virtual origin - WindowsWindow.c - For x/y coords use GET_X_LPARAM/GET_Y_LPARAM which casts '(int)(short)' to preserve negative coordinates. - NewtWindow_setVisiblePosSize() allow negative coordinates --- src/newt/native/WindowsWindow.c | 63 ++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) (limited to 'src/newt/native') diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index b763d5cad..97fe6f28d 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -869,7 +869,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; break; @@ -878,7 +878,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; break; @@ -889,7 +889,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; break; @@ -898,7 +898,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; break; @@ -909,7 +909,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; break; @@ -918,7 +918,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; break; @@ -927,7 +927,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, GetModifiers(), - (jint) LOWORD(lParam), (jint) HIWORD(lParam), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 0, (jint) 0); useDefWindowProc = 1; break; @@ -973,8 +973,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, break; case WM_MOVE: - DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, (int)LOWORD(lParam), (int)HIWORD(lParam)); - (*env)->CallVoidMethod(env, window, positionChangedID, JNI_FALSE, (jint)LOWORD(lParam), (jint)HIWORD(lParam)); + DBG_PRINT("*** WindowsWindow: WM_MOVE window %p, %d/%d\n", wnd, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); + (*env)->CallVoidMethod(env, window, positionChangedID, JNI_FALSE, (jint)GET_X_LPARAM(lParam), (jint)GET_Y_LPARAM(lParam)); useDefWindowProc = 1; break; @@ -1039,6 +1039,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMe } while (gotOne && i < 100); } +/* + * Class: jogamp_newt_driver_windows_WindowsScreen + * Method: getOriginX0 + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginX0 + (JNIEnv *env, jobject obj, jint scrn_idx) +{ + if( GetSystemMetrics( SM_CMONITORS) > 1) { + return (jint)GetSystemMetrics(SM_XVIRTUALSCREEN); + } else { + return 0; + } +} + +/* + * Class: jogamp_newt_driver_windows_WindowsScreen + * Method: getOriginY0 + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginY0 + (JNIEnv *env, jobject obj, jint scrn_idx) +{ + if( GetSystemMetrics( SM_CMONITORS ) > 1) { + return (jint)GetSystemMetrics(SM_YVIRTUALSCREEN); + } else { + return 0; + } +} + /* * Class: jogamp_newt_driver_windows_WindowsScreen * Method: getWidthImpl @@ -1047,7 +1077,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMe JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { - return (jint)GetSystemMetrics(SM_CXSCREEN); + if( GetSystemMetrics( SM_CMONITORS) > 1) { + return (jint)GetSystemMetrics(SM_CXVIRTUALSCREEN); + } else { + return (jint)GetSystemMetrics(SM_CXSCREEN); + } } /* @@ -1058,7 +1092,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImp JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getHeightImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { - return (jint)GetSystemMetrics(SM_CYSCREEN); + if( GetSystemMetrics( SM_CMONITORS ) > 1) { + return (jint)GetSystemMetrics(SM_CYVIRTUALSCREEN); + } else { + return (jint)GetSystemMetrics(SM_CYSCREEN); + } } static int NewtScreen_RotationNativeCCW2NewtCCW(JNIEnv *env, int native) { @@ -1310,9 +1348,6 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, } else { flags = SWP_NOACTIVATE | SWP_NOZORDER; } - if(0>x || 0>y) { - flags |= SWP_NOMOVE; - } if(0>=width || 0>=height ) { flags |= SWP_NOSIZE; } -- cgit v1.2.3