XftDraw *image_draw;
};
+static void
+stay_on_top(struct osd_state *osd)
+{
+ /* Heavily inspired by a similar function in libxosd */
+ Window root = DefaultRootWindow(osd->dpy);
+ int format;
+ unsigned long nitems, bytes_after;
+ unsigned char *prop = NULL;
+ Atom type;
+
+ // Gnome-compliant way
+ Atom gnome = XInternAtom(osd->dpy, "_WIN_SUPPORTING_WM_CHECK", False);
+ if (XGetWindowProperty(osd->dpy, root, gnome, 0, 16384, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &prop) == Success &&
+ nitems > 0)
+ {
+ DBG("stay_on_top: Gnome mode\n");
+ // FIXME: check capabilities
+ XClientMessageEvent e;
+ memset(&e, 0, sizeof(e));
+ e.type = ClientMessage;
+ e.window = osd->win;
+ e.message_type = XInternAtom(osd->dpy, "_WIN_LAYER", False);
+ e.format = 32;
+ e.data.l[0] = 6; // WIN_LAYER_ONTOP */
+ XSendEvent(osd->dpy, root, False, SubstructureNotifyMask, (XEvent *) &e);
+ XFree(prop);
+ return;
+ }
+
+ // NetWM-compliant way
+ Atom net_wm = XInternAtom(osd->dpy, "_NET_SUPPORTED", False);
+ if (XGetWindowProperty(osd->dpy, root, net_wm, 0, 16384, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &prop) == Success &&
+ nitems > 0)
+ {
+ DBG("stay_on_top: NetWM mode\n");
+ XEvent e;
+ memset(&e, 0, sizeof(e));
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = XInternAtom(osd->dpy, "_NET_WM_STATE", False);
+ e.xclient.display = osd->dpy;
+ e.xclient.window = osd->win;
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = 1; // _NET_WM_STATE_ADD
+ e.xclient.data.l[1] = XInternAtom(osd->dpy, "_NET_WM_STATE_STAYS_ON_TOP", False);
+ XSendEvent(osd->dpy, root, False, SubstructureRedirectMask, &e);
+ XFree(prop);
+ return;
+ }
+
+ DBG("stay_on_top: WM does not support any known protocol\n");
+}
+
int
main(int argc, char **argv)
{
CWOverrideRedirect,
&win_attr);
XStoreName(osd->dpy, osd->win, "OSD");
+ stay_on_top(osd);
// FIXME: Size
osd->mask_bitmap = XCreatePixmap(osd->dpy, osd->win, osd->screen_width, osd->screen_height, 1);
XSetBackground(osd->dpy, osd->mask_gc, WhitePixel(osd->dpy, osd->screen));
XSetForeground(osd->dpy, osd->mask_gc, BlackPixel(osd->dpy, osd->screen));
- // FIXME: Stay on top
-
XFillRectangle(osd->dpy, osd->image_pixmap, osd->gc, 0, 0, osd->screen_width, osd->screen_height);
XFillRectangle(osd->dpy, osd->mask_bitmap, osd->mask_gc, 0, 0, osd->screen_width, osd->screen_height);