A program that opens a X11 window, without Xlib [anchor]
This was a curiousity of mine. I wanted to look into the actual X protocol, and write my own socket communication that would result in something tangible.
The end result was a program that opens a window, and draws a cosine wave.
Aswell as not using Xlib, I also don't use any libc. So my kernel syscalls are written in assembly.
I'm used to NASM, but I decided to try out FASM for this. It is disappointing that it doesn't have debug support. But outside of that, I didn't notice many differences, because the assembly code I wrote is quite simple.
I did enjoy discovering how to get the environ data that is passed to processes on Linux, passed onto the C code. I couldn't find any mention of this online, but it's available 24 bytes above the stack pointer, when the program executes _start.
One thing that shook me a little about writing directly to the X server socket, is that it wasn't much more complicated than using Xlib, but more that Xlib doesn't take the most obvious route to the solution, but rather has some opinions of its own. It feels like opinions being plastered on previous opinions, etc.
This has only been written for x64 Linux. But I've tried to push it onto people running that, in the communites I'm a part of, and I've been very happy about the portability of the code!
Download here - x11_window.tar.bz2