diff android/dw.cpp @ 2532:457c91634881

Added dw_window_compare() to check if two window handles refer to the same object. Most platforms just compare the pointer or handle, but Android uses IsSameObject().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 11 May 2021 05:00:07 +0000
parents f45ebd96ebe5
children 7c863a3a125f
line wrap: on
line diff
--- a/android/dw.cpp	Tue May 11 00:51:20 2021 +0000
+++ b/android/dw.cpp	Tue May 11 05:00:07 2021 +0000
@@ -3574,7 +3574,7 @@
         jmethodID pixmapBitBlt = env->GetMethodID(clazz, "pixmapBitBlt",
                                                   "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIILorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)I");
         // Call the method on the object
-        retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp->bitmap, xdest, ydest, width, height, src, srcp->bitmap, xsrc, ysrc, srcwidth, srcheight);
+        retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp ? destp->bitmap : NULL, xdest, ydest, width, height, src, srcp ? srcp->bitmap : NULL, xsrc, ysrc, srcwidth, srcheight);
     }
     return retval;
 }
@@ -4794,6 +4794,27 @@
 }
 
 /*
+ * Compare two window handles.
+ * Parameters:
+ *       window1: First window handle to compare.
+ *       window2: Second window handle to compare.
+ * Returns:
+ *       TRUE if the windows are the same object, FALSE if not.
+ */
+int API dw_window_compare(HWND window1, HWND window2)
+{
+    JNIEnv *env;
+    void *retval = nullptr;
+
+    if(window1 && window2 && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        if(env->IsSameObject(window1, window2))
+            return TRUE;
+    }
+    return FALSE;
+}
+
+/*
  * Add a callback to a timer event.
  * Parameters:
  *       interval: Milliseconds to delay between calls.