Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #105653
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | [OT] Re: what is "Atom"? |
| Date | 2017-03-09 11:16 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <eicrseFmliiU2@mid.uni-berlin.de> (permalink) |
| References | <o9qrif$rpa$1@dont-email.me> |
T <T@invalid.invalid> wrote:
> I am programming something in Perl6 that uses inline C code.
> What is "Atom" that appears in the following line:
> Atom sseln = XA_PRIMARY;
Note: all this is completely unrelated to Perl, so
it probably would better be discussed in a newsgroup
somewhat more focused on C and Xlib programming.
X11 allow different applications sharing a display to
exchange information (in an arbitrary format) via so-
called "Properties", attached to windows. E.g. the
window manager may attach a property to each of your
windows, which contains the sizes of the window deco-
rations it put around it. If you need that information
(because you want to position the window at a certain
place on the screen, you can retrieve that property
and use that information in the calculation of where
you move the window to.
Each property has a name, a C string. But strings are
rather awkward to exchange between the client and
server, thus a property names can be converted to
unique numbers, called 'Atoms', which then are used
when trying to retrieve the information in a property.
There is a number of predefined Atoms like XA_PRIMARY.
Others can be created by the program, using XInternAtom()
etc. If you do
Display *d; // must be defined somewhere!
Atom a = XInternAtom(d, "_MY_SHINY_NEW_ATOM", False);
'a' will be the number connected to "_MY_SHINY_NEW_ATOM"
(created anew if such an atom does not already exist,
otherwise the already existing one). If you do
Atom a = XInternAtom(d, "_MY_SHINY_NEW_ATOM", True);
'a' will be set to the number if it already has been
created, otherwise it will be 'None'.
If ypu've got an Atom you can create ir change the
associated 'Property' using XChangeProperty().
If you want to find out the window decoration size the
window manager put around your window, you'd do
Atom a = XInternAtom(d, "_NET_FRAME_EXTENTS", True);
if (a == None) {
fprintf(stderr, "Window manager doesn't set _NET_FRAME_EXTENTS\n");
exit(EXIT_FAILURE);
}
A window manager is supposed to set that property, and thus
create such an Atom (but not all do). In the next step you'd
call XGetWindowProperty() with that Atom (plus a bunch of other
arguments, e.g. the Display pointer, the window number, a
pointer to a pointer for returning the address of the data
of the property and several more) to get the information.
Properties can also be used to send an event to a program.
If e.g. program A changes a property of a window created
by program B, that program will receive a PropertyNotify
event (if it asked for receiving such events). So it can
be used to "trigger" some action in program B from A.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
what is "Atom"? T <T@invalid.invalid> - 2017-03-08 22:12 -0800
Re: what is "Atom"? Barry Schwarz <schwarzb@dqel.com> - 2017-03-09 00:49 -0800
Re: what is "Atom"? gordonb.l0t3e@burditt.org (Gordon Burditt) - 2017-03-09 03:40 -0600
[OT] Re: what is "Atom"? jt@toerring.de (Jens Thoms Toerring) - 2017-03-09 11:16 +0000
Re: what is "Atom"? scott@slp53.sl.home (Scott Lurndal) - 2017-03-09 14:51 +0000
Re: what is "Atom"? T <T@invalid.invalid> - 2017-03-09 13:21 -0800
csiph-web