diff options
author | Sven Gothel <[email protected]> | 2012-02-27 18:20:37 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-02-27 18:20:37 +0100 |
commit | b7407c39c0d3785f2fc21782d31c439622f0d744 (patch) | |
tree | 5ef1fc876f54e182fa8cdea0226f55783c324a2f /src/nativewindow/native/windows | |
parent | f519190f0cf97eb6b3fda61f4eb8c1f55de43b51 (diff) |
NativeWindow: Relax Xinerama dependency / Rename Windows impl subfolder to common name win32 (same as stub_include)
Utilizing dlopen/dlsym in an efficient way relaxes the platform requirement of having Xinerama available.
This allows using Nokia N9 MeeGo out of the box.
Diffstat (limited to 'src/nativewindow/native/windows')
-rw-r--r-- | src/nativewindow/native/windows/GDImisc.c | 226 | ||||
-rw-r--r-- | src/nativewindow/native/windows/WindowsDWM.c | 95 | ||||
-rw-r--r-- | src/nativewindow/native/windows/WindowsDWM.h | 32 |
3 files changed, 0 insertions, 353 deletions
diff --git a/src/nativewindow/native/windows/GDImisc.c b/src/nativewindow/native/windows/GDImisc.c deleted file mode 100644 index 3ab7f9859..000000000 --- a/src/nativewindow/native/windows/GDImisc.c +++ /dev/null @@ -1,226 +0,0 @@ -#include <jni.h> -#include <stdlib.h> -#include <assert.h> - -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#undef WIN32_LEAN_AND_MEAN - -#include <wingdi.h> -#include <stddef.h> - -#include <gluegen_stdint.h> - -#include <stdio.h> - -#include "NativewindowCommon.h" -#include "jogamp_nativewindow_windows_GDIUtil.h" - -// #define VERBOSE_ON 1 - -#ifdef VERBOSE_ON - #define DBG_PRINT(args...) fprintf(stderr, args); -#else - #define DBG_PRINT(args...) -#endif - -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; -static const char * const ClazzAnyCstrName = "<init>"; -static const char * const ClazzNamePointCstrSignature = "(II)V"; - -static jclass pointClz = NULL; -static jmethodID pointCstr = NULL; - -HINSTANCE GetApplicationHandle() { - return GetModuleHandle(NULL); -} - -/* Java->C glue code: - * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean CreateWindowClass(long hInstance, java.lang.String clazzName, long wndProc) - * C function: BOOL CreateWindowClass(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc); - */ -JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc) -{ - HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; - const TCHAR* clazzName = NULL; - WNDCLASS wc; - jboolean res; - -#ifdef UNICODE - clazzName = NewtCommon_GetNullTerminatedStringChars(env, jClazzName); -#else - clazzName = (*env)->GetStringUTFChars(env, jClazzName, NULL); -#endif - - ZeroMemory( &wc, sizeof( wc ) ); - if( GetClassInfo( hInstance, clazzName, &wc ) ) { - // registered already - res = JNI_TRUE; - } else { - // register now - ZeroMemory( &wc, sizeof( wc ) ); - wc.style = CS_HREDRAW | CS_VREDRAW ; - wc.lpfnWndProc = (WNDPROC) (intptr_t) wndProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = NULL; - wc.hCursor = LoadCursor( NULL, IDC_ARROW); - wc.hbrBackground = NULL; // no background paint - GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = clazzName; - res = ( 0 != RegisterClass( &wc ) ) ? JNI_TRUE : JNI_FALSE ; - } - -#ifdef UNICODE - free((void*) clazzName); -#else - (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); -#endif - - return res; -} - -/* Java->C glue code: - * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean DestroyWindowClass(long hInstance, java.lang.String className) - * C function: BOOL DestroyWindowClass(HANDLE hInstance, LPCSTR className); - */ -JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName) -{ - HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; - const TCHAR* clazzName = NULL; - jboolean res; - -#ifdef UNICODE - clazzName = NewtCommon_GetNullTerminatedStringChars(env, jClazzName); -#else - clazzName = (*env)->GetStringUTFChars(env, jClazzName, NULL); -#endif - - res = ( 0 != UnregisterClass( clazzName, hInstance ) ) ? JNI_TRUE : JNI_FALSE ; - -#ifdef UNICODE - free((void*) clazzName); -#else - (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); -#endif - - return res; -} - - -/* Java->C glue code: - * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height) - * C function: HANDLE CreateDummyWindow0(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height); - */ -JNIEXPORT jlong JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0 - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) -{ - HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; - const TCHAR* wndClassName = NULL; - const TCHAR* wndName = NULL; - DWORD dwExStyle; - DWORD dwStyle; - HWND hWnd; - -#ifdef UNICODE - wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName); - wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName); -#else - wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL); - wndName = (*env)->GetStringUTFChars(env, jWndName, NULL); -#endif - - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - hWnd = CreateWindowEx( dwExStyle, - wndClassName, - wndName, - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - x, y, width, height, - NULL, NULL, hInstance, NULL ); - -#ifdef UNICODE - free((void*) wndClassName); - free((void*) wndName); -#else - (*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName); - (*env)->ReleaseStringUTFChars(env, jWndName, wndName); -#endif - - return (jlong) (intptr_t) hWnd; -} - - -/* - * Class: jogamp_nativewindow_windows_GDIUtil - * Method: initIDs0 - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0 - (JNIEnv *env, jclass clazz) -{ - if(NativewindowCommon_init(env)) { - jclass c = (*env)->FindClass(env, ClazzNamePoint); - if(NULL==c) { - NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't find %s", ClazzNamePoint); - } - pointClz = (jclass)(*env)->NewGlobalRef(env, c); - (*env)->DeleteLocalRef(env, c); - if(NULL==pointClz) { - NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't use %s", ClazzNamePoint); - } - pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature); - if(NULL==pointCstr) { - NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't fetch %s.%s %s", - ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); - } - } - return JNI_TRUE; -} - -LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - return DefWindowProc(hWnd,uMsg,wParam,lParam); -} - -/* - * Class: jogamp_nativewindow_windows_GDIUtil - * Method: getDummyWndProc0 - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_windows_GDIUtil_getDummyWndProc0 - (JNIEnv *env, jclass clazz) -{ - return (jlong) (intptr_t) DummyWndProc; -} - -/* - * Class: jogamp_nativewindow_windows_GDIUtil - * Method: GetRelativeLocation0 - * Signature: (JJII)Ljavax/media/nativewindow/util/Point; - */ -JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLocation0 - (JNIEnv *env, jclass unused, jlong jsrc_win, jlong jdest_win, jint src_x, jint src_y) -{ - HWND src_win = (HWND) (intptr_t) jsrc_win; - HWND dest_win = (HWND) (intptr_t) jdest_win; - POINT dest = { src_x, src_y } ; - int res; - - res = MapWindowPoints(src_win, dest_win, &dest, 1); - - DBG_PRINT("*** WindowsWindow: getRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", - (void*)src_win, src_x, src_y, (void*)dest_win, (int)dest.x, (int)dest.y, res); - - return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest.x, (jint)dest.y); -} - diff --git a/src/nativewindow/native/windows/WindowsDWM.c b/src/nativewindow/native/windows/WindowsDWM.c deleted file mode 100644 index cc9ed6d8c..000000000 --- a/src/nativewindow/native/windows/WindowsDWM.c +++ /dev/null @@ -1,95 +0,0 @@ - -#include "WindowsDWM.h" - -#include <stdlib.h> -#include <stdio.h> - -// #define VERBOSE_ON 1 - -#ifdef VERBOSE_ON - #define DBG_PRINT(args...) fprintf(stderr, args); -#else - #define DBG_PRINT(args...) -#endif - -/* GetProcAddress doesn't exist in A/W variants under desktop Windows */ -#ifndef UNDER_CE -#define GetProcAddressA GetProcAddress -#endif - -typedef HRESULT (WINAPI *DwmEnableCompositionPROCADDR)(UINT uCompositionAction); -typedef HRESULT (WINAPI *DwmIsCompositionEnabledPROCADDR)(BOOL * pfEnabled); -typedef HRESULT (WINAPI *DwmEnableBlurBehindWindowPROCADDR)(HWND hWnd, const DWM_BLURBEHIND* pBlurBehind); -typedef HRESULT (WINAPI *DwmExtendFrameIntoClientAreaPROCADDR)(HWND hwnd, const MARGINS *pMarInset); - -static int _init = 0; // 1: init, 2: has DWM extension -static DwmEnableCompositionPROCADDR _DwmEnableComposition = NULL; -static DwmIsCompositionEnabledPROCADDR _DwmIsCompositionEnabled = NULL; -static DwmEnableBlurBehindWindowPROCADDR _DwmEnableBlurBehindWindow = NULL; -static DwmExtendFrameIntoClientAreaPROCADDR _DwmExtendFrameIntoClientArea = NULL; - -static int initWindowsDWM() { - if(0 == _init) { - _init = 1; - HANDLE shell = LoadLibrary(TEXT("dwmapi.dll")); - if (shell) { - _DwmEnableComposition = (DwmEnableCompositionPROCADDR) GetProcAddressA (shell, "DwmEnableComposition"); - _DwmIsCompositionEnabled = (DwmIsCompositionEnabledPROCADDR) GetProcAddressA (shell, "DwmIsCompositionEnabled"); - _DwmEnableBlurBehindWindow = (DwmEnableBlurBehindWindowPROCADDR) GetProcAddressA (shell, "DwmEnableBlurBehindWindow"); - _DwmExtendFrameIntoClientArea = (DwmExtendFrameIntoClientAreaPROCADDR) GetProcAddressA (shell, "DwmExtendFrameIntoClientArea"); - if(NULL != _DwmEnableComposition && NULL != _DwmIsCompositionEnabled && - NULL != _DwmEnableBlurBehindWindow && NULL != _DwmExtendFrameIntoClientArea) { - _init = 2; - } - } - // FreeLibrary (shell); - DBG_PRINT("DWM - initWindowsDWM: %d - s %p, e %p, c %p\n", _init, shell, _DwmEnableBlurBehindWindow, _DwmExtendFrameIntoClientArea); - } - return _init; -} - -BOOL DwmIsExtensionAvailable() { - return (2 == initWindowsDWM()) ? TRUE : FALSE; -} - -BOOL DwmIsCompositionEnabled( ) { - if(2 == initWindowsDWM()) { - BOOL fEnabled = FALSE; - if( 0 == _DwmIsCompositionEnabled(&fEnabled) ) { - DBG_PRINT("DWM - DwmIsCompositionEnabled: %d\n", fEnabled); - return fEnabled; - } - } - DBG_PRINT("DWM - DwmIsCompositionEnabled failed\n"); - return FALSE; -} - -BOOL DwmEnableComposition( UINT uCompositionAction ) { - if(2 == initWindowsDWM()) { - return 0 == _DwmEnableComposition(uCompositionAction) ? TRUE : FALSE; - } - return FALSE; -} - -BOOL DwmEnableBlurBehindWindow(HWND hwnd, const DWM_BLURBEHIND* pBlurBehind) { - if(2 == initWindowsDWM()) { - _DwmEnableBlurBehindWindow(hwnd, pBlurBehind); - DBG_PRINT("DWM - DwmEnableBlurBehindWindow: hwnd %p, f %d, on %d, %p\n", - (void *)hwnd, - (int) pBlurBehind->dwFlags, - (int) pBlurBehind->fEnable, - (void *)pBlurBehind->hRgnBlur); - return TRUE; - } - DBG_PRINT("DWM - DwmEnableBlurBehindWindow: n/a\n"); - return FALSE; -} - -BOOL DwmExtendFrameIntoClientArea(HWND hwnd, const MARGINS *pMarInset) { - if(2 == initWindowsDWM()) { - _DwmExtendFrameIntoClientArea(hwnd, pMarInset); - return TRUE; - } - return FALSE; -} - diff --git a/src/nativewindow/native/windows/WindowsDWM.h b/src/nativewindow/native/windows/WindowsDWM.h deleted file mode 100644 index 36f82fc94..000000000 --- a/src/nativewindow/native/windows/WindowsDWM.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _WINDOWS_DWM_H_ -#define _WINDOWS_DWM_H_ - - #include <windows.h> - - #define DWM_BB_ENABLE 0x00000001 // fEnable has been specified - #define DWM_EC_DISABLECOMPOSITION 0 - #define DWM_EC_ENABLECOMPOSITION 1 - - typedef struct _DWM_BLURBEHIND - { - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; - } DWM_BLURBEHIND, *PDWM_BLURBEHIND; - - typedef struct _MARGINS - { - int cxLeftWidth; // width of left border that retains its size - int cxRightWidth; // width of right border that retains its size - int cyTopHeight; // height of top border that retains its size - int cyBottomHeight; // height of bottom border that retains its size - } MARGINS, *PMARGINS; - - BOOL DwmIsExtensionAvailable(); - BOOL DwmIsCompositionEnabled(); - BOOL DwmEnableComposition( UINT uCompositionAction ); - BOOL DwmEnableBlurBehindWindow(HWND hwnd, const DWM_BLURBEHIND* pBlurBehind); - BOOL DwmExtendFrameIntoClientArea(HWND hwnd, const MARGINS *pMarInset); - -#endif /* _WINDOWS_DWM_H_ */ |