提交 a787e4e3 编写于 作者: A anthony

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: NDanesh Dadachanji <ddadacha@redhat.com>
上级 b8af9095
......@@ -322,6 +322,8 @@ SUNWprivate_1.1 {
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;
......
......@@ -208,12 +208,19 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
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();
......
......@@ -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 @@ int32_t getNumButtons() {
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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册