diff options
Diffstat (limited to 'xlib-tutorial/index.html')
| -rw-r--r-- | xlib-tutorial/index.html | 116 |
1 files changed, 0 insertions, 116 deletions
diff --git a/xlib-tutorial/index.html b/xlib-tutorial/index.html deleted file mode 100644 index 5e57eaf..0000000 --- a/xlib-tutorial/index.html +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | <HTML> | ||
| 2 | <HEAD> | ||
| 3 | <TITLE>Xlib programming: a short tutorial</TITLE> | ||
| 4 | </HEAD> | ||
| 5 | |||
| 6 | <BODY> | ||
| 7 | |||
| 8 | <H1>Xlib programming: a short tutorial</H1> | ||
| 9 | |||
| 10 | I haven't found anything very satisfying on the Web as an Xlib | ||
| 11 | tutorial. Many of them are too much Motif-oriented for my | ||
| 12 | taste. Furthermore, I answer questions about X programming almost | ||
| 13 | daily, so I've started to put together some small coursewares. | ||
| 14 | |||
| 15 | <H4>Important note:</H4> the example programs are written in C++, but | ||
| 16 | this is mainly for the ability to declare variables anywhere. | ||
| 17 | |||
| 18 | <HR> | ||
| 19 | |||
| 20 | Let's begin with a short story: the eternal story of the newbie at | ||
| 21 | Xlib writing his/her first program. | ||
| 22 | |||
| 23 | <P> | ||
| 24 | |||
| 25 | <I> | ||
| 26 | "Ok, I've to open a connection to the X server (whatever this means), | ||
| 27 | with XOpenDisplay, then create a window with XCreateWindow, then draw | ||
| 28 | a line with XDrawLine. Then, the program sleeps for ten seconds so I | ||
| 29 | can see the result. Sounds easy." | ||
| 30 | </I> | ||
| 31 | |||
| 32 | <P> | ||
| 33 | |||
| 34 | The poor newbie writes the program. And nothing happens. He then | ||
| 35 | calls his wizard friend. | ||
| 36 | |||
| 37 | <P> | ||
| 38 | |||
| 39 | <I> | ||
| 40 | -"Did you perform an XFlush after you've done everything ?<BR> | ||
| 41 | - No, why ?<BR> | ||
| 42 | - The requests stay in the client," </I>wizard doubletalk, thinks the | ||
| 43 | poor newbie<I>, " if you | ||
| 44 | don't." | ||
| 45 | </I> | ||
| 46 | |||
| 47 | <P> | ||
| 48 | |||
| 49 | The poor newbie changes the program. And nothing happens. He then | ||
| 50 | calls his wizard friend. | ||
| 51 | |||
| 52 | <P> | ||
| 53 | |||
| 54 | <I> | ||
| 55 | -"Did you map your window ?<BR> | ||
| 56 | - Did I do what ???<BR> | ||
| 57 | - Creating a window doesn't make it appear on the screen. You've to | ||
| 58 | map it with XMapWindow first. | ||
| 59 | </I> | ||
| 60 | |||
| 61 | <P> | ||
| 62 | |||
| 63 | The poor newbie changes the program. The window appears with nothing | ||
| 64 | in it (<A HREF="prog-1.cc">like this</A>). The poor newbie then calls | ||
| 65 | his wizard friend. | ||
| 66 | |||
| 67 | <P> | ||
| 68 | |||
| 69 | <I> | ||
| 70 | -"Did you wait for a MapNotify before drawing your line ?" </I>(more wizard doubletalk)<I><BR> | ||
| 71 | - "No, why ?</BR> | ||
| 72 | - X has a stateless drawing model, the content of the window may be lost | ||
| 73 | when the window isn't on the screen." </I>(overflow, why can't these | ||
| 74 | wizard guys speak just like you and me ?)<I> "You've to wait for a MapNotify | ||
| 75 | before drawing." | ||
| 76 | </I> | ||
| 77 | |||
| 78 | <P> | ||
| 79 | |||
| 80 | The poor newbie changes the program. Things are getting more and more | ||
| 81 | complex. Not as easy as it first seemed. A loop gets the events until a | ||
| 82 | MapNotify. The window appears with nothing | ||
| 83 | in it. The poor newbie then calls his wizard friend. | ||
| 84 | |||
| 85 | <P> | ||
| 86 | |||
| 87 | <I> | ||
| 88 | -"I got it, did you select the StructureNotifyMask on your window ?<BR> | ||
| 89 | - ???<BR> | ||
| 90 | - Just do it, and everything'll be fine. | ||
| 91 | </I> | ||
| 92 | |||
| 93 | <P> | ||
| 94 | |||
| 95 | The poor newbie fixes the program. And the miracle happens ! A line in the | ||
| 96 | window. Until now, the program looks like <A HREF="prog-2.cc">this</A> | ||
| 97 | (it is actually slighty more complex than the dialog may let you think). | ||
| 98 | |||
| 99 | <P> | ||
| 100 | |||
| 101 | Now you've learned at least 2 things: | ||
| 102 | |||
| 103 | <UL> | ||
| 104 | <LI> How to draw a line in a window with X. | ||
| 105 | <LI> Why some may need an X tutorial. | ||
| 106 | </UL> | ||
| 107 | |||
| 108 | Now, if you want to learn more and get a deeper understanding of the | ||
| 109 | program, go to <A HREF="2nd-program-anatomy.html">next lesson</A>. | ||
| 110 | |||
| 111 | <H4><A HREF="/gui/x/">More about X</A>.</H4> | ||
| 112 | |||
| 113 | |||
| 114 | <HR><ADDRESS><A HREF="http://tronche.com/">Christophe Tronche</A>, <A HREF="mailto:ch.tronche@computer.org">ch.tronche@computer.org</A></ADDRESS> | ||
| 115 | </BODY> | ||
| 116 | </HTML> | ||
