There are several ways to draw strokes on the full screen of X Window,
- Using the SHAPE extension, while it's very time consuming to calculate the bitmask when you draw complex curves. Not sure if libxosd works better.
- Using Composite overlay window, looks like a wonderful solution, but it maybe occupied by a compositing manager (like Compiz), so your painting might be corrupted when compiz redrawing a window. While you could still create a "always-on-top" window for compositing, which requires a window manager supports freedesktop's standards, refer to libaosd.
- Creating an off-screen pixmap for root window and painting on that, then using
XCopyArea(3X11)to copy the result image to root with a "full-screen" GC (whoseGCSubwindowModeisIncludeInferiors). If you want some funcy effects, use RENDER extension to create aPicturefor root (with the attributesubwindow_modeasIncludeInferiors), then composite on it. The performance is good, and has no side-effects when working with a compositing manager.
To get the global mouse event, you could use XEVIE, though currently it may report some warnings like "Xlib: sequence lost (...) in reply type 0x6!", when catching pointer events. However it does not support multiple clients. A better option probably is to use RECORD extension. And last, using XGrabPointer(3X11) in some circumstances (like the right button is pressed for a while) to grab the mouse, so that the mouse movement would not affect the running apps on the screen.
P.S., as Alan pointed out in the comments, "You should not rely on XEvIE - it hasn't been maintained in several years, and has been removed by the X.Org community in the upcoming Xorg
server 1.6 release."