# HG changeset patch # User anthony # Date 1321013871 -10800 # Node ID 0f3aedc26c21007650ffe11a3bbde37e780c32d8 # Parent 6ba07a297b142e7b94967db3d9d2c2acd104eb0e 7103610: _NET_WM_PID and WM_CLIENT_MACHINE are not set Summary: Set the properties to all top-level windows Reviewed-by: anthony Contributed-by: Danesh Dadachanji diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers --- a/make/sun/xawt/mapfile-vers +++ b/make/sun/xawt/mapfile-vers @@ -322,6 +322,8 @@ Java_sun_awt_X11_XlibWrapper_XSynchronize; Java_java_awt_FileDialog_initIDs; Java_sun_awt_X11_XWindow_initIDs; + Java_sun_awt_X11_XWindowPeer_getLocalHostname; + Java_sun_awt_X11_XWindowPeer_getJvmPID; Java_sun_java2d_opengl_OGLContext_getOGLIdString; Java_sun_java2d_opengl_OGLMaskFill_maskFill; diff --git a/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/src/solaris/classes/sun/awt/X11/XWindowPeer.java --- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java +++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java @@ -208,12 +208,19 @@ return name; } + private static native String getLocalHostname(); + private static native int getJvmPID(); + void postInit(XCreateWindowParams params) { super.postInit(params); // Init WM_PROTOCOLS atom initWMProtocols(); + // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM + XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname()); + XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID()); + // Set WM_TRANSIENT_FOR and group_leader Window t_window = (Window)target; Window owner = t_window.getOwner(); diff --git a/src/solaris/native/sun/xawt/XToolkit.c b/src/solaris/native/sun/xawt/XToolkit.c --- a/src/solaris/native/sun/xawt/XToolkit.c +++ b/src/solaris/native/sun/xawt/XToolkit.c @@ -47,6 +47,8 @@ #include "java_awt_TrayIcon.h" #include +#include + uint32_t awt_NumLockMask = 0; Boolean awt_ModLockIsShiftLock = False; @@ -1087,3 +1089,38 @@ return local_num_buttons; } + +/* + * Class: sun_awt_X11_XWindowPeer + * Method: getJvmPID + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_awt_X11_XWindowPeer_getJvmPID +(JNIEnv *env, jclass cls) +{ + /* Return the JVM's PID. */ + return getpid(); +} + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 1024 /* Overestimated */ +#endif + +/* + * Class: sun_awt_X11_XWindowPeer + * Method: getLocalHostname + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_sun_awt_X11_XWindowPeer_getLocalHostname +(JNIEnv *env, jclass cls) +{ + /* Return the machine's FQDN. */ + char hostname[HOST_NAME_MAX + 1]; + if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) { + hostname[HOST_NAME_MAX] = '\0'; + jstring res = (*env)->NewStringUTF(env, hostname); + return res; + } + + return (jstring)NULL; +}