I don’t really know. XOSD is an old demonstration code, maybe it doesn’t work anymore with KDE or gnome.
The basic idea of XOSD is to tell the windows manager to move the window in the “Always-On-Top” layer.
The atom hint that comes back often in code is XA_NET_WM_STATE_ABOVE or _NET_WM_STATE_ABOVE and XA_NET_WM_STATE_STAYS_ON_TOP
For example, here’s the mplayer implementation (should be more recent, but the code is harder to understand):
static int vo_wm_detect(void)
{
int i;
int wm = 0;
unsigned long nitems;
Atom *args = NULL;
if (WinID >= 0)
return 0;
// -- supports layers
if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports layers.\n");
for (i = 0; i < nitems; i++)
{
if (args[i] == XA_WIN_LAYER)
{
wm |= vo_wm_LAYER;
metacity_hack |= 1;
} else
// metacity is the only manager I know which reports support only for _WIN_LAYER
// hint in _WIN_PROTOCOLS (what's more support for it is broken)
metacity_hack |= 2;
}
XFree(args);
if (wm && (metacity_hack == 1))
{
// metacity reports that it supports layers, but it is not really truth :-)
wm ^= vo_wm_LAYER;
mp_msg(MSGT_VO, MSGL_V,
"[x11] Using workaround for Metacity bugs.\n");
}
}
// --- netwm
if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V, "[x11] Detected wm supports NetWM.\n");
for (i = 0; i < nitems; i++)
wm |= net_wm_support_state_test(args[i]);
XFree(args);
#if 0
// ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support
// (in their implementation it only changes internal state of window, nothing more!!!)
if (wm & vo_wm_FULLSCREEN)
{
if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems))
{
mp_msg(MSGT_VO, MSGL_V,
"[x11] Detected wm is a broken OpenBox.\n");
wm ^= vo_wm_FULLSCREEN;
}
XFree(args);
}
#endif
}
if (wm == 0)
mp_msg(MSGT_VO, MSGL_V, "[x11] Unknown wm type...\n");
return wm;
}
static void init_atoms(void)
{
XA_INIT(_NET_SUPPORTED);
XA_INIT(_NET_WM_STATE);
XA_INIT(_NET_WM_STATE_FULLSCREEN);
XA_INIT(_NET_WM_STATE_ABOVE);
XA_INIT(_NET_WM_STATE_STAYS_ON_TOP);
XA_INIT(_NET_WM_STATE_BELOW);
XA_INIT(_NET_WM_PID);
XA_INIT(_WIN_PROTOCOLS);
XA_INIT(_WIN_LAYER);
XA_INIT(_WIN_HINTS);
XA_INIT(_BLACKBOX_PID);
}
static int vo_x11_get_gnome_layer(Display * mDisplay, Window win)
{
Atom type;
int format;
unsigned long nitems;
unsigned long bytesafter;
unsigned short *args = NULL;
if (XGetWindowProperty(mDisplay, win, XA_WIN_LAYER, 0, 16384,
False, AnyPropertyType, &type, &format, &nitems,
&bytesafter,
(unsigned char **) &args) == Success
&& nitems > 0 && args)
{
mp_msg(MSGT_VO, MSGL_V, "[x11] original window layer is %d.\n",
*args);
return *args;
}
return WIN_LAYER_NORMAL;
}
void vo_x11_setlayer(Display * mDisplay, Window vo_window, int layer)
{
if (WinID >= 0)
return;
if (vo_fs_type & vo_wm_LAYER)
{
XClientMessageEvent xev;
if (!orig_layer)
orig_layer = vo_x11_get_gnome_layer(mDisplay, vo_window);
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.display = mDisplay;
xev.window = vo_window;
xev.message_type = XA_WIN_LAYER;
xev.format = 32;
xev.data.l[0] = layer ? fs_layer : orig_layer; // if not fullscreen, stay on default layer
xev.data.l[1] = CurrentTime;
mp_msg(MSGT_VO, MSGL_V,
"[x11] Layered style stay on top (layer %d).\n",
xev.data.l[0]);
XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask,
(XEvent *) & xev);
} else if (vo_fs_type & vo_wm_NETWM)
{
XClientMessageEvent xev;
char *state;
memset(&xev, 0, sizeof(xev));
xev.type = ClientMessage;
xev.message_type = XA_NET_WM_STATE;
xev.display = mDisplay;
xev.window = vo_window;
xev.format = 32;
xev.data.l[0] = layer;
if (vo_fs_type & vo_wm_STAYS_ON_TOP)
xev.data.l[1] = XA_NET_WM_STATE_STAYS_ON_TOP;
else if (vo_fs_type & vo_wm_ABOVE)
xev.data.l[1] = XA_NET_WM_STATE_ABOVE;
else if (vo_fs_type & vo_wm_FULLSCREEN)
xev.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
else if (vo_fs_type & vo_wm_BELOW)
// This is not fallback. We can safely assume that situation where
// only NETWM_STATE_BELOW is supported and others not, doesn't exist.
xev.data.l[1] = XA_NET_WM_STATE_BELOW;
XSendEvent(mDisplay, mRootWin, False, SubstructureRedirectMask,
(XEvent *) & xev);
state = XGetAtomName(mDisplay, xev.data.l[1]);
mp_msg(MSGT_VO, MSGL_V,
"[x11] NET style stay on top (layer %d). Using state %s.\n",
layer, state);
XFree(state);
}
}
From there: http://www.google.fr/codesearch/p?hl=fr#RGCD84x9Jg0/trunk/mplayer/libvo/x11_common.c&q=WM_STATE_ABOVE&sa=N&cd=5&ct=rc