Applied James DeLisle's patch adding EWMH _NET_WM_PID support.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1626 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
jtsiomb 2013-08-28 14:33:07 +00:00
parent 925f7446b7
commit 855c10d908
3 changed files with 72 additions and 26 deletions

View File

@ -216,8 +216,12 @@ void fgPlatformInitialize( const char* displayName )
/* Create the state and full screen atoms */ /* Create the state and full screen atoms */
fgDisplay.pDisplay.State = None; fgDisplay.pDisplay.State = None;
fgDisplay.pDisplay.StateFullScreen = None; fgDisplay.pDisplay.StateFullScreen = None;
fgDisplay.pDisplay.NetWMPid = None;
fgDisplay.pDisplay.ClientMachine = None;
if (fghNetWMSupported()) fgDisplay.pDisplay.NetWMSupported = fghNetWMSupported();
if (fgDisplay.pDisplay.NetWMSupported)
{ {
const Atom supported = fghGetAtom("_NET_SUPPORTED"); const Atom supported = fghGetAtom("_NET_SUPPORTED");
const Atom state = fghGetAtom("_NET_WM_STATE"); const Atom state = fghGetAtom("_NET_WM_STATE");
@ -236,6 +240,9 @@ void fgPlatformInitialize( const char* displayName )
fgDisplay.pDisplay.StateFullScreen = full_screen; fgDisplay.pDisplay.StateFullScreen = full_screen;
} }
} }
fgDisplay.pDisplay.NetWMPid = fghGetAtom("_NET_WM_PID");
fgDisplay.pDisplay.ClientMachine = fghGetAtom("WM_CLIENT_MACHINE");
} }
/* Get start time */ /* Get start time */

View File

@ -60,6 +60,9 @@ struct tagSFG_PlatformDisplay
Atom DeleteWindow; /* The window deletion atom */ Atom DeleteWindow; /* The window deletion atom */
Atom State; /* The state atom */ Atom State; /* The state atom */
Atom StateFullScreen; /* The full screen atom */ Atom StateFullScreen; /* The full screen atom */
int NetWMSupported; /* Flag for EWMH Window Managers */
Atom NetWMPid; /* The _NET_WM_PID atom */
Atom ClientMachine; /* The client machine name atom */
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H #ifdef HAVE_X11_EXTENSIONS_XRANDR_H
int prev_xsz, prev_ysz; int prev_xsz, prev_ysz;

View File

@ -29,7 +29,8 @@
#define FREEGLUT_BUILDING_LIB #define FREEGLUT_BUILDING_LIB
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include <limits.h> /* LONG_MAX */ #include <limits.h> /* LONG_MAX */
#include <unistd.h> /* usleep */ #include <unistd.h> /* usleep, gethostname, getpid */
#include <sys/types.h> /* pid_t */
#include "../fg_internal.h" #include "../fg_internal.h"
#ifdef EGL_VERSION_1_0 #ifdef EGL_VERSION_1_0
@ -340,6 +341,41 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
XSetWMProtocols( fgDisplay.pDisplay.Display, window->Window.Handle, XSetWMProtocols( fgDisplay.pDisplay.Display, window->Window.Handle,
&fgDisplay.pDisplay.DeleteWindow, 1 ); &fgDisplay.pDisplay.DeleteWindow, 1 );
if (fgDisplay.pDisplay.NetWMSupported
&& fgDisplay.pDisplay.NetWMPid != None
&& fgDisplay.pDisplay.ClientMachine != None)
{
char hostname[HOST_NAME_MAX];
pid_t pid = getpid();
if (pid > 0 && gethostname(hostname, sizeof(hostname)) > -1)
{
hostname[sizeof(hostname) - 1] = '\0';
XChangeProperty(
fgDisplay.pDisplay.Display,
window->Window.Handle,
fgDisplay.pDisplay.NetWMPid,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *) &pid,
1
);
XChangeProperty(
fgDisplay.pDisplay.Display,
window->Window.Handle,
fgDisplay.pDisplay.ClientMachine,
XA_STRING,
8,
PropModeReplace,
(unsigned char *) hostname,
strlen(hostname)
);
}
}
#ifdef EGL_VERSION_1_0 #ifdef EGL_VERSION_1_0
fghPlatformOpenWindowEGL(window); fghPlatformOpenWindowEGL(window);
#else #else