[Nottingham] beginners guide to how X works

Godfrey Nix godfrey at gnnix.co.uk
Sat May 5 08:04:40 BST 2007

On Sat, 2007-05-05 at 01:42 +0100, Cam wrote:
> Godfrey
> > What I DO want to get my little head round is the way in which mouse and
> > keyboard input is passed to the correct program, how 'mouse over' events
> > know when the mouse is over the object and whether there is any way in
> > which a program can find out what windows exist on a display.
> You didn't mention what sort of level you wanted to approach this from.
20 years of programming experience - fortran, delphi, C, perl, php .....

> If you are a curious C programmer you could search for 'xlib reference' 
> or similar (it takes me back a bit!). Basically you make a call to 
> 'open' the display which returns a handle, then you can create windows 
> and perform operations on them. You then read events in a loop. The 
> events can be key presses, mouse actions, window crossing events and so on.
> Hardly anyone programs at that level though, it's much more productive 
> to use a widget toolkit which adds buttons, text fields and so on. You 
> can use the popular widget libraries from C, C++ or even interpreted 
> languages like Perl and Ruby. Even at a high level you still get to open 
> the display, create widgets then go into an event loop.
I DON'T want to draw any windows myself. That is the whole point of the
question. If I wanted to draw windows, then I would use java or Qt,
whatever. As I said, what I DO want is to gain control of other
processes' windows so that I can enter text and do mouse clicks on them
- as if a person was operating the mouse/keyboard but actually done by
my program.

I have a starting point now, as Martin told me about xwininfo. If anyone
can help me further, that would be great.

Godfrey Nix <godfrey at gnnix.co.uk>

More information about the Nottingham mailing list