From 7d2582d6aa5b8a137f5e679d46a2f02c72719451 Mon Sep 17 00:00:00 2001 From: Amartya Parijat Date: Mon, 3 Jun 2024 13:14:23 +0200 Subject: [PATCH] added OS level API bindings for win32 This commit provides a native API binding for win32 to get the ancestor of the provided window. Contributes to #62 and #127 --- .../Eclipse SWT PI/win32/library/os.c | 14 +++++++++++++- .../Eclipse SWT PI/win32/library/os_stats.h | 3 ++- .../win32/org/eclipse/swt/internal/win32/OS.java | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c index f6c8dbdce79..8e864c9a713 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2022,6 +2022,18 @@ JNIEXPORT jlong JNICALL OS_NATIVE(GetActiveWindow) } #endif +#ifndef NO_GetAncestor +JNIEXPORT jlong JNICALL OS_NATIVE(GetAncestor) + (JNIEnv *env, jclass that, jlong arg0, jint arg1) +{ + jlong rc = 0; + OS_NATIVE_ENTER(env, that, GetAncestor_FUNC); + rc = (jlong)GetAncestor((HWND)arg0, arg1); + OS_NATIVE_EXIT(env, that, GetAncestor_FUNC); + return rc; +} +#endif + #ifndef NO_GetBkColor JNIEXPORT jint JNICALL OS_NATIVE(GetBkColor) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h index 6fbcd0fc91e..7bbf84350a6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -170,6 +170,7 @@ typedef enum { GdiSetBatchLimit_FUNC, GetACP_FUNC, GetActiveWindow_FUNC, + GetAncestor_FUNC, GetBkColor_FUNC, GetCapture_FUNC, GetCaretPos_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index f32d0ea3a8e..f06f943ebd8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -497,6 +497,9 @@ public class OS extends C { public static final int FR_PRIVATE = 0x10; public static final int FSHIFT = 0x4; public static final int FVIRTKEY = 0x1; + public static final int GA_PARENT = 0x1; + public static final int GA_ROOT = 0x2; + public static final int GA_ROOTOWNER = 0x3; public static final int GCP_REORDER = 0x0002; public static final int GCP_GLYPHSHAPE = 0x0010; public static final int GCP_CLASSIN = 0x00080000; @@ -2709,6 +2712,8 @@ public static int HRESULT_FROM_WIN32(int x) { public static final native int GdiSetBatchLimit (int dwLimit); public static final native int GetACP (); public static final native long GetActiveWindow (); +/** @param hWnd cast=(HWND) */ +public static final native long GetAncestor (long hWnd, int gaFlags); /** @param hDC cast=(HDC) */ public static final native int GetBkColor (long hDC); public static final native long GetCapture ();