From 2c0a0981f7e1376064abd981c79c65c9d1b57410 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Thu, 1 Dec 2011 16:43:55 +0100
Subject: Move manual GDI utils to GDIUtil ; Minor cleanup.

RegisteredClassFactory: Reference the factories itself instead of the RegisteredClass.
                        This enables the shutdown hook to clear the factories state,
                        which is required for proper recreation.
---
 make/build-nativewindow.xml                        |  1 +
 make/config/nativewindow/win32-CustomJavaCode.java | 58 ----------------------
 make/config/nativewindow/win32-lib.cfg             |  4 +-
 make/stub_includes/win32/wingdi.h                  |  2 +
 4 files changed, 4 insertions(+), 61 deletions(-)

(limited to 'make')

diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml
index 3a3c7852e..57647ef65 100644
--- a/make/build-nativewindow.xml
+++ b/make/build-nativewindow.xml
@@ -735,6 +735,7 @@
 
     <target name="c.build.nativewindow.windowlib.windows" if="isWindows">
       <javah destdir="${src.generated.c}/Windows" classpath="${javah.classpath}" class="jogamp.nativewindow.windows.GDI" />
+      <javah destdir="${src.generated.c}/Windows" classpath="${javah.classpath}" class="jogamp.nativewindow.windows.GDIUtil" />
 
       <c.build c.compiler.src.files="c.src.files.windows"
                output.lib.name="nativewindow_win32"
diff --git a/make/config/nativewindow/win32-CustomJavaCode.java b/make/config/nativewindow/win32-CustomJavaCode.java
index e14e4d14c..5c484c2fe 100644
--- a/make/config/nativewindow/win32-CustomJavaCode.java
+++ b/make/config/nativewindow/win32-CustomJavaCode.java
@@ -1,60 +1,2 @@
   
-  private static final boolean DEBUG = Debug.debug("GDI");
-
-  private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ;
-  private static RegisteredClassFactory dummyWindowClassFactory;
-  private static boolean isInit = false;
-
-  private static native boolean initIDs0();
-  private static native long getDummyWndProc0();
-
-  public static synchronized void initSingleton(boolean firstX11ActionOnProcess) {
-    if(!isInit) {
-        NWJNILibLoader.loadNativeWindow("win32");
-        
-        if( !initIDs0() ) {
-            throw new NativeWindowException("GDI: Could not initialized native stub");
-        }
-
-        if(DEBUG) {
-            System.out.println("GDI.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess);
-        }
-
-        dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0());
-        isInit = true;
-    }
-  }
-
-  public static boolean requiresToolkitLock() { return false; }
-
-  private static RegisteredClass dummyWindowClass = null;
-  private static Object dummyWindowSync = new Object();
-
-  public static long CreateDummyWindow(int x, int y, int width, int height) {
-      synchronized(dummyWindowSync) {
-          dummyWindowClass = dummyWindowClassFactory.getSharedClass();
-          return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height);
-      }
-  }
-
-  public static boolean DestroyDummyWindow(long hwnd) {
-      boolean res;
-      synchronized(dummyWindowSync) {
-          if( null == dummyWindowClass ) {
-              throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null");
-          }
-          res = DestroyWindow(hwnd);
-          dummyWindowClassFactory.releaseSharedClass();
-      }
-      return res;
-  }
-
-  public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) {
-      return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y);
-  }
-  private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y);
-
-  public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc);
-  public static native boolean DestroyWindowClass(long hInstance, String className);
-  static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height);
 
diff --git a/make/config/nativewindow/win32-lib.cfg b/make/config/nativewindow/win32-lib.cfg
index b8ff42473..26c744a80 100644
--- a/make/config/nativewindow/win32-lib.cfg
+++ b/make/config/nativewindow/win32-lib.cfg
@@ -36,7 +36,5 @@ CustomCCode #include <gluegen_stddef.h>
 CustomCCode #include <wingdi.h>
 CustomCCode #include "WindowsDWM.h"
 
-CustomCCode extern HINSTANCE   GetApplicationHandle();
-
-IncludeAs CustomJavaCode GDI win32-CustomJavaCode.java
+CustomCCode extern HINSTANCE GetApplicationHandle();
 
diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h
index 23ac428ca..b02512cfd 100644
--- a/make/stub_includes/win32/wingdi.h
+++ b/make/stub_includes/win32/wingdi.h
@@ -195,6 +195,8 @@ WINUSERAPI HWND WINAPI WindowFromDC(HDC hDC); // avail in >= Win2k
 WINUSERAPI BOOL WINAPI GetClientRect(HWND hwnd, LPRECT lpRect);
 WINUSERAPI BOOL WINAPI DestroyWindow(HWND hWnd);
 WINUSERAPI DWORD WINAPI GetObjectType(HGDIOBJ h);
+WINUSERAPI BOOL WINAPI IsWindowVisible(HWND hWnd);
+WINUSERAPI BOOL WINAPI IsWindow(HWND hWnd);
 
 WINUSERAPI HANDLE WINAPI GetCurrentProcess(void);
 WINUSERAPI BOOL WINAPI GetProcessAffinityMask(HANDLE hProcess,PDWORD_PTR lpProcessAffinityMask,PDWORD_PTR lpSystemAffinityMask);
-- 
cgit v1.2.3