changeset 4686:f614bcada2a9

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 <ddadacha@redhat.com>
author anthony
date Fri, 11 Nov 2011 15:17:51 +0300
parents 16327765859c
children c0f3f1558a94
files make/sun/xawt/mapfile-vers src/solaris/classes/sun/awt/X11/XWindowPeer.java src/solaris/native/sun/xawt/XToolkit.c
diffstat 3 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/make/sun/xawt/mapfile-vers	Thu Nov 10 17:37:29 2011 +0400
+++ b/make/sun/xawt/mapfile-vers	Fri Nov 11 15:17:51 2011 +0300
@@ -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;
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu Nov 10 17:37:29 2011 +0400
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Fri Nov 11 15:17:51 2011 +0300
@@ -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();
--- a/src/solaris/native/sun/xawt/XToolkit.c	Thu Nov 10 17:37:29 2011 +0400
+++ b/src/solaris/native/sun/xawt/XToolkit.c	Fri Nov 11 15:17:51 2011 +0300
@@ -47,6 +47,8 @@
 #include "java_awt_TrayIcon.h"
 #include <X11/extensions/XTest.h>
 
+#include <unistd.h>
+
 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;
+}