Skip to content

Commit

Permalink
X11: Added support to _NET_WM_PID and WM_CLIENT_MACHINE atoms
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
3v1n0 committed Jun 28, 2011
1 parent 79d0d58 commit 252bbb8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -417,6 +417,25 @@ static void create_aux_windows(_THIS)
}
}

{
char hostname[256];

if (gethostname(hostname, sizeof(hostname)) > -1) {
hostname[sizeof(hostname)-1] = '\0';
pid_t pid = getpid();

if (pid > 0) {
Atom _NET_WM_PID = XInternAtom(SDL_Display, "_NET_WM_PID", False);
Atom WM_CLIENT_MACHINE = XInternAtom(SDL_Display, "WM_CLIENT_MACHINE", False);

XChangeProperty(SDL_Display, WMwindow, _NET_WM_PID, XA_CARDINAL, 32,
PropModeReplace, (unsigned char *)&pid, 1);
XChangeProperty(SDL_Display, WMwindow, WM_CLIENT_MACHINE, XA_STRING, 8,
PropModeReplace, hostname, SDL_strlen(hostname));
}
}
}

/* Setup the communication with the IM server */
/* create_aux_windows may be called several times against the same
Display. We should reuse the SDL_IM if one has been opened for
Expand Down

0 comments on commit 252bbb8

Please sign in to comment.