After researching for a little a while, I decided to answer the question myself.
The the X11 manual at sbin.com is a very good one and contains detailed explanation and examples.
I also found the folks at #xcb irc challel at irc.freenode.com very cooperative and knowledgeable. They suggested me to read code written in X11 like xscreensaver and others. That should get me started.