[Nottingham] beginners guide to how X works

Cam camilo at mesias.co.uk
Sun May 6 09:39:21 BST 2007


Godfrey

> 20 years of programming experience - fortran, delphi, C, perl, php .....

[...]

> 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.

What you want to do sounds fairly esoteric - I would have thought Xlib 
would be the ideal way to do it. If anyone knows of a higher level 
toolkit that give access to low level stuff I'd be interested.

Have a look at these links from the Xlib reference manual:

Moving the pointer:
http://cs.wwc.edu/~davija/XLIB/12-04.html#P855_29580

Finding out about windows:
http://cs.wwc.edu/~davija/XLIB/04-01.html#P21_325
(bear in mind a window isn't just the thing you drag around, there can 
be lots of rectangular areas that are treated as windows)

Event types & structures:
http://cs.wwc.edu/~davija/XLIB/10-01.html#P31_711
http://cs.wwc.edu/~davija/XLIB/10-02.html#P88_2772

Sending events to other applications:
http://cs.wwc.edu/~davija/XLIB/11-09.html#P653_17584

If you want some skeleton code that handles opening the Display and 
running an event loop then the best place to look IMHO is the X sources. 
They include the X server and drivers which you can ignore in this case, 
but also all the X utilities like xauth, xwininfo, xdpyinfo, xev, xset, 
xlsatoms. They would be an ideal starting point.

If you are digging further then the sources for one of the more 
lightweight window managers will give you plenty of ideas about 
manipulating windows - things like finding the title of a window etc. In 
case you want to do things like 'raise the window called 'Mozilla' and 
click on (400,320) inside that window.

Have a good bank holiday!

-Cam



-- 

                                                                      <--
camilo at mesias.co.uk



More information about the Nottingham mailing list