X11: Added support to _NET_WM_PID and WM_CLIENT_MACHINE atoms SDL-1.2
authorMarco Trevisan (TreviƱo)
Tue, 28 Jun 2011 22:26:47 +0200
branchSDL-1.2
changeset 61696f3e5ccfd585
parent 6158 6f3a2bb301d6
child 6170 044ca54328b4
X11: Added support to _NET_WM_PID and WM_CLIENT_MACHINE atoms

Add support to the _NET_WM_PID atom which is needed by many windows
managers to correctly associate a SDL window to its process and to
related .desktop file and icon for the given host.
src/video/x11/SDL_x11video.c
     1.1 --- a/src/video/x11/SDL_x11video.c	Thu Jan 05 19:19:58 2012 -0500
     1.2 +++ b/src/video/x11/SDL_x11video.c	Tue Jun 28 22:26:47 2011 +0200
     1.3 @@ -417,6 +417,25 @@
     1.4  	}
     1.5      }
     1.6  
     1.7 +	{
     1.8 +		char hostname[256];
     1.9 +
    1.10 +		if (gethostname(hostname, sizeof(hostname)) > -1) {
    1.11 +			hostname[sizeof(hostname)-1] = '\0';
    1.12 +			pid_t pid = getpid();
    1.13 +
    1.14 +			if (pid > 0) {
    1.15 +				Atom _NET_WM_PID = XInternAtom(SDL_Display, "_NET_WM_PID", False);
    1.16 +				Atom WM_CLIENT_MACHINE = XInternAtom(SDL_Display, "WM_CLIENT_MACHINE", False);
    1.17 +				
    1.18 +				XChangeProperty(SDL_Display, WMwindow, _NET_WM_PID, XA_CARDINAL, 32,
    1.19 +				                PropModeReplace, (unsigned char *)&pid, 1);
    1.20 +				XChangeProperty(SDL_Display, WMwindow, WM_CLIENT_MACHINE, XA_STRING, 8,
    1.21 +				                PropModeReplace, hostname, SDL_strlen(hostname));
    1.22 +			}
    1.23 +		}
    1.24 +	}
    1.25 +
    1.26  	/* Setup the communication with the IM server */
    1.27  	/* create_aux_windows may be called several times against the same
    1.28  	   Display.  We should reuse the SDL_IM if one has been opened for