<s>
The	O
X	B-Device
Window	I-Device
System	I-Device
core	I-Device
protocol	I-Device
is	O
the	O
base	O
protocol	O
of	O
the	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
,	O
which	O
is	O
a	O
networked	B-Architecture
windowing	B-Application
system	I-Application
for	O
bitmap	O
displays	O
used	O
to	O
build	O
graphical	B-Application
user	I-Application
interfaces	I-Application
on	O
Unix	B-Application
,	O
Unix-like	B-Operating_System
,	O
and	O
other	O
operating	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
The	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
is	O
based	O
on	O
a	O
client	B-Operating_System
–	I-Operating_System
server	I-Operating_System
model	I-Operating_System
:	O
a	O
single	O
server	B-Application
controls	O
the	O
input/output	B-General_Concept
hardware	O
,	O
such	O
as	O
the	O
screen	B-Device
,	O
the	O
keyboard	B-Device
,	O
and	O
the	O
mouse	B-Device
;	O
all	O
application	O
programs	O
act	O
as	O
clients	B-Protocol
,	O
interacting	O
with	O
the	O
user	O
and	O
with	O
the	O
other	O
clients	B-Protocol
via	O
the	O
server	B-Application
.	O
</s>
<s>
This	O
interaction	O
is	O
regulated	O
by	O
the	O
X	B-Device
Window	I-Device
System	I-Device
core	I-Device
protocol	I-Device
.	O
</s>
<s>
Other	O
protocols	O
related	O
to	O
the	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
exist	O
,	O
both	O
built	O
at	O
the	O
top	O
of	O
the	O
X	B-Device
Window	I-Device
System	I-Device
core	I-Device
protocol	I-Device
or	O
as	O
separate	O
protocols	O
.	O
</s>
<s>
In	O
the	O
X	B-Device
Window	I-Device
System	I-Device
core	I-Device
protocol	I-Device
,	O
only	O
four	O
kinds	O
of	O
packets	O
are	O
sent	O
,	O
asynchronously	O
,	O
over	O
the	O
network	O
:	O
requests	O
,	O
replies	O
,	O
events	O
,	O
and	O
errors	O
.	O
</s>
<s>
Requests	O
are	O
sent	O
by	O
a	O
client	B-Protocol
to	O
the	O
server	B-Application
to	O
ask	O
it	O
to	O
perform	O
some	O
operation	O
(	O
for	O
example	O
,	O
create	O
a	O
new	O
window	O
)	O
and	O
to	O
send	O
back	O
data	O
it	O
holds	O
.	O
</s>
<s>
Replies	O
are	O
sent	O
by	O
the	O
server	B-Application
to	O
provide	O
such	O
data	O
.	O
</s>
<s>
Events	O
are	O
sent	O
by	O
the	O
server	B-Application
to	O
notify	O
clients	B-Protocol
of	O
user	O
activity	O
or	O
other	O
occurrences	O
they	O
are	O
interested	O
in	O
.	O
</s>
<s>
Errors	O
are	O
packets	O
sent	O
by	O
the	O
server	B-Application
to	O
notify	O
a	O
client	B-Protocol
of	O
errors	O
occurred	O
during	O
processing	O
of	O
its	O
requests	O
.	O
</s>
<s>
X	B-Operating_System
originated	O
at	O
MIT	O
in	O
1984	O
(	O
its	O
release	O
X11	B-Operating_System
appeared	O
in	O
September	O
1987	O
)	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
the	O
core	O
protocol	O
does	O
not	O
specify	O
the	O
interaction	O
between	O
clients	B-Protocol
and	O
between	O
a	O
client	B-Protocol
and	O
the	O
user	O
.	O
</s>
<s>
These	O
interactions	O
are	O
the	O
subject	O
of	O
separate	O
specifications	O
,	O
such	O
as	O
the	O
ICCCM	B-Operating_System
and	O
the	O
freedesktop.org	B-Application
specifications	O
,	O
and	O
are	O
typically	O
enforced	O
automatically	O
by	O
using	O
a	O
given	O
widget	B-Library
set	I-Library
.	O
</s>
<s>
Communication	O
between	O
server	B-Application
and	O
clients	B-Protocol
is	O
done	O
by	O
exchanging	O
packets	O
over	O
a	O
channel	O
.	O
</s>
<s>
The	O
connection	O
is	O
established	O
by	O
the	O
client	B-Protocol
(	O
how	O
the	O
client	B-Protocol
is	O
started	O
is	O
not	O
specified	O
in	O
the	O
protocol	O
)	O
.	O
</s>
<s>
The	O
client	B-Protocol
also	O
sends	O
the	O
first	O
packet	O
,	O
containing	O
the	O
byte	B-Application
order	O
to	O
be	O
used	O
and	O
information	O
about	O
the	O
version	O
of	O
the	O
protocol	O
and	O
the	O
kind	O
of	O
authentication	O
the	O
client	B-Protocol
expects	O
the	O
server	B-Application
to	O
use	O
.	O
</s>
<s>
The	O
server	B-Application
answers	O
by	O
sending	O
back	O
a	O
packet	O
stating	O
the	O
acceptance	O
or	O
refusal	O
of	O
the	O
connection	O
,	O
or	O
with	O
a	O
request	O
for	O
a	O
further	O
authentication	O
.	O
</s>
<s>
If	O
the	O
connection	O
is	O
accepted	O
,	O
the	O
acceptance	O
packet	O
contains	O
data	O
for	O
the	O
client	B-Protocol
to	O
use	O
in	O
the	O
subsequent	O
interaction	O
with	O
the	O
server	B-Application
.	O
</s>
<s>
After	O
connection	O
is	O
established	O
,	O
four	O
types	O
of	O
packets	O
are	O
exchanged	O
between	O
client	B-Protocol
and	O
server	B-Application
over	O
the	O
channel	O
:	O
</s>
<s>
Request	O
:	O
The	O
client	B-Protocol
requests	O
information	O
from	O
the	O
server	B-Application
or	O
requests	O
it	O
to	O
perform	O
an	O
action	O
.	O
</s>
<s>
Reply	O
:	O
The	O
server	B-Application
responds	O
to	O
a	O
request	O
.	O
</s>
<s>
Event	O
:	O
The	O
server	B-Application
informs	O
the	O
client	B-Protocol
of	O
an	O
event	O
,	O
such	O
as	O
keyboard	B-Device
or	O
mouse	B-Device
input	I-Device
,	O
a	O
window	O
being	O
moved	O
,	O
resized	O
or	O
exposed	O
,	O
etc	O
.	O
</s>
<s>
Error	O
:	O
The	O
server	B-Application
sends	O
an	O
error	O
packet	O
if	O
a	O
request	O
is	O
invalid	O
.	O
</s>
<s>
Request	O
and	O
reply	O
packets	O
have	O
varying	O
length	O
,	O
while	O
event	O
and	O
error	O
packets	O
have	O
a	O
fixed	O
length	O
of	O
32	O
bytes	B-Application
.	O
</s>
<s>
Request	O
packets	O
are	O
numbered	O
sequentially	O
by	O
the	O
server	B-Application
as	O
soon	O
as	O
it	O
receives	O
them	O
:	O
the	O
first	O
request	O
from	O
a	O
client	B-Protocol
is	O
numbered	O
1	O
,	O
the	O
second	O
2	O
,	O
etc	O
.	O
</s>
<s>
They	O
are	O
also	O
included	O
in	O
event	O
packets	O
to	O
indicate	O
the	O
sequential	O
number	O
of	O
the	O
request	O
that	O
the	O
server	B-Application
is	O
currently	O
processing	O
or	O
has	O
just	O
finished	O
processing	O
.	O
</s>
<s>
What	O
is	O
usually	O
called	O
a	O
window	O
in	O
most	O
graphical	B-Application
user	I-Application
interfaces	I-Application
is	O
called	O
a	O
top-level	O
window	O
in	O
the	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
request	O
the	O
creation	O
of	O
a	O
window	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
the	O
windows	O
created	O
by	O
clients	B-Protocol
are	O
arranged	O
in	O
a	O
tree	O
(	O
a	O
hierarchy	O
)	O
.	O
</s>
<s>
The	O
root	O
of	O
this	O
tree	O
is	O
the	O
root	B-Device
window	I-Device
,	O
which	O
is	O
a	O
special	O
window	O
created	O
automatically	O
by	O
the	O
server	B-Application
at	O
startup	O
.	O
</s>
<s>
All	O
other	O
windows	O
are	O
directly	O
or	O
indirectly	O
subwindows	O
of	O
the	O
root	B-Device
window	I-Device
.	O
</s>
<s>
The	O
top-level	O
windows	O
are	O
the	O
direct	O
subwindows	O
of	O
the	O
root	B-Device
window	I-Device
.	O
</s>
<s>
Visibly	O
,	O
the	O
root	B-Device
window	I-Device
is	O
as	O
large	O
as	O
the	O
virtual	O
desktop	O
,	O
and	O
lies	O
behind	O
all	O
other	O
windows	O
.	O
</s>
<s>
In	O
particular	O
,	O
content	O
is	O
lost	O
if	O
the	O
X	B-Operating_System
server	B-Application
is	O
not	O
maintaining	O
a	O
backing	O
store	O
of	O
the	O
window	O
content	O
.	O
</s>
<s>
The	O
client	B-Protocol
can	O
request	O
backing	O
store	O
for	O
a	O
window	O
to	O
be	O
maintained	O
,	O
but	O
there	O
is	O
no	O
obligation	O
for	O
the	O
server	B-Application
to	O
do	O
so	O
.	O
</s>
<s>
Therefore	O
,	O
clients	B-Protocol
cannot	O
assume	O
that	O
backing	O
store	O
is	O
maintained	O
.	O
</s>
<s>
If	O
a	O
visible	O
part	O
of	O
a	O
window	O
has	O
an	O
unspecified	O
content	O
,	O
an	O
event	O
is	O
sent	O
to	O
notify	O
the	O
client	B-Protocol
that	O
the	O
window	O
content	O
has	O
to	O
be	O
drawn	O
again	O
.	O
</s>
<s>
The	O
protocol	O
includes	O
requests	O
for	O
a	O
client	B-Protocol
to	O
inspect	O
and	O
change	O
the	O
attributes	O
of	O
a	O
window	O
.	O
</s>
<s>
InputOutput	O
windows	O
can	O
be	O
shown	O
on	O
the	O
screen	B-Device
and	O
are	O
used	O
for	O
drawing	O
.	O
</s>
<s>
InputOnly	O
windows	O
are	O
never	O
shown	O
on	O
the	O
screen	B-Device
and	O
are	O
used	O
only	O
to	O
receive	O
input	O
.	O
</s>
<s>
The	O
decorative	O
frame	O
and	O
title	O
bar	O
(	O
possibly	O
including	O
buttons	O
)	O
that	O
is	O
usually	O
seen	O
around	O
windows	O
are	O
created	O
by	O
the	O
window	B-Application
manager	I-Application
,	O
not	O
by	O
the	O
client	B-Protocol
that	O
creates	O
the	O
window	O
.	O
</s>
<s>
The	O
window	B-Application
manager	I-Application
also	O
handles	O
input	O
related	O
to	O
these	O
elements	O
,	O
such	O
as	O
resizing	O
the	O
window	O
when	O
the	O
user	O
clicks	O
and	O
drags	O
the	O
window	O
frame	O
.	O
</s>
<s>
Clients	B-Protocol
usually	O
operate	O
on	O
the	O
window	O
they	O
created	O
disregarding	O
the	O
changes	O
operated	O
by	O
the	O
window	B-Application
manager	I-Application
.	O
</s>
<s>
A	O
change	O
it	O
has	O
to	O
take	O
into	O
account	O
is	O
that	O
re-parenting	B-Device
window	I-Device
managers	I-Device
,	O
which	O
almost	O
all	O
modern	O
window	B-Application
managers	I-Application
are	O
,	O
change	O
the	O
parent	O
of	O
top-level	O
windows	O
to	O
a	O
window	O
that	O
is	O
not	O
the	O
root	O
.	O
</s>
<s>
From	O
the	O
point	O
of	O
view	O
of	O
the	O
core	O
protocol	O
,	O
the	O
window	B-Application
manager	I-Application
is	O
a	O
client	B-Protocol
,	O
not	O
different	O
from	O
the	O
other	O
applications	O
.	O
</s>
<s>
Data	O
about	O
a	O
window	O
can	O
be	O
obtained	O
by	O
running	O
the	O
xwininfo	O
program	B-Application
.	O
</s>
<s>
Passing	O
it	O
the	O
-tree	O
command-line	B-Application
argument	O
,	O
this	O
program	B-Application
shows	O
the	O
tree	O
of	O
subwindows	O
of	O
a	O
window	O
,	O
along	O
with	O
their	O
identifiers	O
and	O
geometry	O
data	O
.	O
</s>
<s>
Unlike	O
windows	O
,	O
pixmaps	O
are	O
not	O
automatically	O
shown	O
on	O
the	O
screen	B-Device
.	O
</s>
<s>
Windows	O
and	O
pixmaps	O
are	O
collectively	O
named	O
drawables	O
,	O
and	O
their	O
content	O
data	O
resides	O
on	O
the	O
server	B-Application
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
however	O
request	O
the	O
content	O
of	O
a	O
drawable	O
to	O
be	O
transferred	O
from	O
the	O
server	B-Application
to	O
the	O
client	B-Protocol
or	O
vice	O
versa	O
.	O
</s>
<s>
The	O
client	B-Protocol
can	O
request	O
a	O
number	O
of	O
graphic	O
operations	O
,	O
such	O
as	O
clearing	O
an	O
area	O
,	O
copying	O
an	O
area	O
into	O
another	O
,	O
drawing	O
points	O
,	O
lines	O
,	O
rectangles	O
,	O
and	O
text	O
.	O
</s>
<s>
Most	O
requests	O
for	O
graphic	O
operations	O
include	O
a	O
graphic	B-Device
context	I-Device
,	O
which	O
is	O
a	O
structure	O
that	O
contains	O
the	O
parameters	O
of	O
the	O
graphic	O
operations	O
.	O
</s>
<s>
A	O
graphic	B-Device
context	I-Device
includes	O
the	O
foreground	O
color	O
,	O
the	O
background	O
color	O
,	O
the	O
font	O
of	O
text	O
,	O
and	O
other	O
graphic	O
parameters	O
.	O
</s>
<s>
When	O
requesting	O
a	O
graphic	O
operation	O
,	O
the	O
client	B-Protocol
includes	O
a	O
graphic	B-Device
context	I-Device
.	O
</s>
<s>
Not	O
all	O
parameters	O
of	O
the	O
graphic	B-Device
context	I-Device
affect	O
the	O
operation	O
:	O
for	O
example	O
,	O
the	O
font	O
does	O
not	O
affect	O
drawing	O
a	O
line	O
.	O
</s>
<s>
The	O
core	O
protocol	O
specifies	O
the	O
use	O
of	O
server-side	O
fonts	O
.	O
</s>
<s>
Such	O
fonts	O
are	O
stored	O
as	O
files	O
,	O
and	O
the	O
server	B-Application
accesses	O
them	O
either	O
directly	O
via	O
the	O
local	O
filesystem	B-Application
or	O
via	O
the	O
network	O
from	O
another	O
program	B-Application
called	O
font	O
server	B-Application
.	O
</s>
<s>
Clients	B-Protocol
can	O
request	O
the	O
list	O
of	O
fonts	O
available	O
to	O
the	O
server	B-Application
and	O
can	O
request	O
a	O
font	O
to	O
be	O
loaded	O
(	O
if	O
not	O
already	O
)	O
or	O
unloaded	O
(	O
if	O
not	O
used	O
by	O
other	O
clients	B-Protocol
)	O
by	O
the	O
server	B-Application
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
request	O
general	O
information	O
about	O
a	O
font	O
(	O
for	O
example	O
,	O
the	O
font	O
ascent	O
)	O
and	O
the	O
space	O
a	O
specific	O
string	O
takes	O
when	O
drawn	O
with	O
a	O
specific	O
font	O
.	O
</s>
<s>
The	O
names	O
of	O
the	O
fonts	O
are	O
arbitrary	O
strings	O
at	O
the	O
level	O
of	O
the	O
X	B-Device
Window	I-Device
core	I-Device
protocol	I-Device
.	O
</s>
<s>
The	O
X	B-Application
logical	I-Application
font	I-Application
description	I-Application
conventions	O
specify	O
how	O
fonts	O
should	O
be	O
named	O
according	O
to	O
their	O
attributes	O
.	O
</s>
<s>
The	O
xlsfonts	O
program	B-Application
prints	O
the	O
list	O
of	O
fonts	O
stored	O
in	O
the	O
server	B-Application
.	O
</s>
<s>
The	O
xfontsel	O
program	B-Application
shows	O
the	O
glyphs	O
of	O
fonts	O
,	O
and	O
allows	O
the	O
user	O
to	O
select	O
the	O
name	O
of	O
a	O
font	O
for	O
pasting	O
it	O
in	O
another	O
window	O
.	O
</s>
<s>
The	O
use	O
of	O
server-side	O
fonts	O
is	O
currently	O
considered	O
deprecated	O
in	O
favour	O
of	O
client-side	B-Operating_System
fonts	O
.	O
</s>
<s>
Such	O
fonts	O
are	O
rendered	O
by	O
the	O
client	B-Protocol
,	O
not	O
by	O
the	O
server	B-Application
,	O
with	O
the	O
support	O
of	O
the	O
Xft	B-Application
or	O
cairo	B-Language
libraries	O
and	O
the	O
XRender	B-Device
extension	O
.	O
</s>
<s>
No	O
specification	O
on	O
client-side	B-Operating_System
fonts	O
is	O
given	O
in	O
the	O
core	O
protocol	O
.	O
</s>
<s>
are	O
stored	O
in	O
the	O
server	B-Application
.	O
</s>
<s>
The	O
client	B-Protocol
knows	O
identifiers	O
of	O
these	O
objects	O
—	O
integers	O
it	O
uses	O
as	O
names	O
for	O
them	O
when	O
interacting	O
with	O
the	O
server	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
client	B-Protocol
wishes	O
a	O
window	O
to	O
be	O
created	O
,	O
it	O
requests	O
the	O
server	B-Application
to	O
create	O
a	O
window	O
with	O
a	O
given	O
identifier	O
.	O
</s>
<s>
The	O
identifier	O
can	O
be	O
later	O
used	O
by	O
the	O
client	B-Protocol
to	O
request	O
,	O
for	O
example	O
,	O
a	O
string	O
to	O
be	O
drawn	O
in	O
the	O
window	O
.	O
</s>
<s>
The	O
following	O
objects	O
reside	O
in	O
the	O
server	B-Application
and	O
are	O
known	O
by	O
the	O
client	B-Protocol
via	O
a	O
numerical	O
identifier	O
:	O
</s>
<s>
When	O
a	O
client	B-Protocol
requests	O
the	O
creation	O
of	O
one	O
such	O
resource	O
,	O
it	O
also	O
specifies	O
an	O
identifier	O
for	O
it	O
.	O
</s>
<s>
For	O
example	O
,	O
for	O
creating	O
a	O
new	O
window	O
,	O
the	O
client	B-Protocol
specifies	O
both	O
the	O
attributes	O
of	O
the	O
window	O
(	O
parent	O
,	O
width	O
,	O
height	O
,	O
etc	O
.	O
)	O
</s>
<s>
Every	O
client	B-Protocol
has	O
its	O
own	O
set	O
of	O
identifiers	O
it	O
can	O
use	O
for	O
creating	O
new	O
resources	O
.	O
</s>
<s>
This	O
set	O
is	O
specified	O
by	O
the	O
server	B-Application
as	O
two	O
integers	O
included	O
in	O
the	O
acceptance	O
packet	O
(	O
the	O
packet	O
it	O
sends	O
to	O
the	O
client	B-Protocol
to	O
inform	O
it	O
that	O
the	O
connection	O
is	O
accepted	O
)	O
.	O
</s>
<s>
Clients	B-Protocol
choose	O
identifiers	O
that	O
are	O
in	O
this	O
set	O
in	O
such	O
a	O
way	O
they	O
do	O
not	O
clash	B-Application
:	O
two	O
objects	O
among	O
windows	O
,	O
pixmaps	O
,	O
fonts	O
,	O
colormaps	O
,	O
and	O
graphic	B-Device
contexts	I-Device
cannot	O
have	O
the	O
same	O
identifier	O
.	O
</s>
<s>
Once	O
a	O
resource	O
has	O
been	O
created	O
,	O
its	O
identifier	O
is	O
used	O
by	O
the	O
client	B-Protocol
to	O
request	O
operations	O
about	O
it	O
to	O
the	O
server	B-Application
.	O
</s>
<s>
Some	O
operations	O
affect	O
the	O
given	O
resource	O
(	O
for	O
example	O
,	O
requests	O
to	O
move	O
windows	O
)	O
;	O
others	O
ask	O
for	O
resource	O
data	O
stored	O
from	O
the	O
server	B-Application
(	O
for	O
example	O
,	O
requests	O
for	O
the	O
attributes	O
of	O
windows	O
)	O
.	O
</s>
<s>
Identifiers	O
are	O
unique	O
to	O
the	O
server	B-Application
,	O
not	O
only	O
to	O
the	O
client	B-Protocol
;	O
for	O
example	O
,	O
no	O
two	O
windows	O
have	O
the	O
same	O
identifier	O
,	O
even	O
if	O
created	O
by	O
two	O
different	O
clients	B-Protocol
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
access	O
any	O
object	O
given	O
its	O
identifier	O
.	O
</s>
<s>
In	O
particular	O
,	O
it	O
can	O
also	O
access	O
resources	O
created	O
by	O
any	O
other	O
client	B-Protocol
,	O
even	O
if	O
their	O
identifiers	O
are	O
outside	O
the	O
set	O
of	O
identifiers	O
it	O
can	O
create	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
two	O
clients	B-Protocol
connected	O
to	O
the	O
same	O
server	B-Application
can	O
use	O
the	O
same	O
identifier	O
to	O
refer	O
to	O
the	O
same	O
resource	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
client	B-Protocol
creates	O
a	O
window	O
of	O
identifier	O
0x1e00021	O
and	O
passes	O
this	O
number	O
0x1e00021	O
to	O
another	O
application	O
(	O
via	O
any	O
available	O
means	O
,	O
for	O
example	O
by	O
storing	O
this	O
number	O
in	O
a	O
file	B-Operating_System
that	O
is	O
also	O
accessible	O
to	O
the	O
other	O
application	O
)	O
,	O
this	O
other	O
application	O
is	O
able	O
to	O
operate	O
on	O
the	O
very	O
same	O
window	O
.	O
</s>
<s>
This	O
possibility	O
is	O
for	O
example	O
exploited	O
by	O
the	O
X	B-Operating_System
Window	I-Operating_System
version	O
of	O
Ghostview	B-Language
:	O
this	O
program	B-Application
creates	O
a	O
subwindow	O
,	O
storing	O
its	O
identifier	O
in	O
an	O
environment	O
variable	O
,	O
and	O
calls	O
Ghostscript	B-Language
;	O
this	O
program	B-Application
draws	O
the	O
content	O
of	O
the	O
PostScript	B-Language
file	B-Operating_System
to	O
show	O
in	O
this	O
window	O
.	O
</s>
<s>
Resources	O
are	O
normally	O
destroyed	O
when	O
the	O
client	B-Protocol
that	O
created	O
them	O
closes	O
the	O
connection	O
with	O
the	O
server	B-Application
.	O
</s>
<s>
However	O
,	O
before	O
closing	O
connection	O
,	O
a	O
client	B-Protocol
can	O
request	O
the	O
server	B-Application
not	O
to	O
destroy	O
them	O
.	O
</s>
<s>
Events	O
are	O
packets	O
sent	O
by	O
the	O
server	B-Application
to	O
a	O
client	B-Protocol
to	O
communicate	O
that	O
something	O
the	O
client	B-Protocol
may	O
be	O
interested	O
in	O
has	O
happened	O
.	O
</s>
<s>
For	O
example	O
,	O
an	O
event	O
is	O
sent	O
when	O
the	O
user	O
presses	O
a	O
key	O
or	O
clicks	O
a	O
mouse	B-Device
button	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
the	O
user	O
clicks	O
when	O
the	O
pointer	B-Device
is	O
in	O
a	O
window	O
,	O
the	O
event	O
will	O
be	O
relative	O
to	O
that	O
window	O
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
request	O
the	O
server	B-Application
to	O
send	O
an	O
event	O
to	O
another	O
client	B-Protocol
;	O
this	O
is	O
used	O
for	O
communication	O
between	O
clients	B-Protocol
.	O
</s>
<s>
Such	O
an	O
event	O
is	O
for	O
example	O
generated	O
when	O
a	O
client	B-Protocol
requests	O
the	O
text	O
that	O
is	O
currently	O
selected	O
:	O
this	O
event	O
is	O
sent	O
to	O
the	O
client	B-Protocol
that	O
is	O
currently	O
handling	O
the	O
window	O
that	O
holds	O
the	O
selection	B-Device
.	O
</s>
<s>
The	O
content	O
of	O
a	O
window	O
may	O
be	O
destroyed	O
in	O
some	O
conditions	O
,	O
for	O
example	O
,	O
if	O
the	O
window	O
is	O
covered	O
and	O
the	O
server	B-Application
is	O
not	O
maintaining	O
a	O
backing	O
store	O
.	O
</s>
<s>
The	O
server	B-Application
generates	O
an	O
Expose	O
event	O
to	O
notify	O
the	O
client	B-Protocol
that	O
a	O
part	O
of	O
the	O
window	O
has	O
to	O
be	O
drawn	O
.	O
</s>
<s>
Most	O
kinds	O
of	O
events	O
are	O
sent	O
only	O
if	O
the	O
client	B-Protocol
previously	O
stated	O
an	O
interest	O
in	O
them	O
.	O
</s>
<s>
This	O
is	O
because	O
clients	B-Protocol
may	O
only	O
be	O
interested	O
in	O
some	O
kind	O
of	O
events	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
client	B-Protocol
may	O
be	O
interested	O
in	O
keyboard-related	O
events	O
but	O
not	O
in	O
mouse-related	O
events	O
.	O
</s>
<s>
Some	O
kinds	O
of	O
events	O
are	O
however	O
sent	O
to	O
clients	B-Protocol
even	O
if	O
they	O
have	O
not	O
specifically	O
requested	O
them	O
.	O
</s>
<s>
Clients	B-Protocol
specify	O
which	O
kinds	O
of	O
events	O
they	O
want	O
to	O
be	O
sent	O
by	O
setting	O
an	O
attribute	O
of	O
a	O
window	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
order	O
to	O
redraw	O
a	O
window	O
when	O
its	O
content	O
has	O
been	O
destroyed	O
,	O
a	O
client	B-Protocol
must	O
receive	O
the	O
Expose	O
events	O
,	O
which	O
inform	O
it	O
that	O
the	O
window	O
needs	O
to	O
be	O
drawn	O
again	O
.	O
</s>
<s>
The	O
client	B-Protocol
will	O
however	O
be	O
sent	O
Expose	O
events	O
only	O
if	O
the	O
client	B-Protocol
has	O
previously	O
stated	O
its	O
interest	O
in	O
these	O
events	O
,	O
which	O
is	O
done	O
by	O
appropriately	O
setting	O
the	O
event	O
mask	O
attribute	O
of	O
the	O
window	O
.	O
</s>
<s>
Different	O
clients	B-Protocol
can	O
request	O
events	O
on	O
the	O
same	O
window	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
client	B-Protocol
may	O
request	O
only	O
keyboard	B-Device
events	O
on	O
a	O
window	O
while	O
another	O
client	B-Protocol
requests	O
only	O
mouse	B-Device
events	O
on	O
the	O
same	O
window	O
.	O
</s>
<s>
This	O
is	O
possible	O
because	O
the	O
server	B-Application
,	O
for	O
each	O
window	O
,	O
maintains	O
a	O
separate	O
event	O
mask	O
for	O
each	O
client	B-Protocol
.	O
</s>
<s>
However	O
,	O
there	O
are	O
some	O
kinds	O
of	O
events	O
that	O
can	O
only	O
be	O
selected	O
by	O
one	O
client	B-Protocol
at	O
time	O
for	O
each	O
window	O
.	O
</s>
<s>
In	O
particular	O
,	O
these	O
events	O
report	O
mouse	B-Device
button	O
clicks	O
and	O
some	O
changes	O
related	O
to	O
window	B-Application
management	I-Application
.	O
</s>
<s>
The	O
xev	O
program	B-Application
shows	O
the	O
events	O
relative	O
to	O
a	O
window	O
.	O
</s>
<s>
The	O
following	O
is	O
a	O
possible	O
example	O
of	O
interaction	O
between	O
a	O
server	B-Application
and	O
a	O
program	B-Application
that	O
creates	O
a	O
window	O
with	O
a	O
black	O
box	O
in	O
it	O
and	O
exits	O
on	O
a	O
keypress	O
.	O
</s>
<s>
In	O
this	O
example	O
,	O
the	O
server	B-Application
does	O
not	O
send	O
any	O
reply	O
because	O
the	O
client	B-Protocol
requests	O
do	O
not	O
generate	O
replies	O
.	O
</s>
<s>
The	O
client	B-Protocol
opens	O
the	O
connection	O
with	O
the	O
server	B-Application
and	O
sends	O
the	O
initial	O
packet	O
specifying	O
the	O
byte	B-Application
order	O
it	O
is	O
using	O
.	O
</s>
<s>
The	O
server	B-Application
accepts	O
the	O
connection	O
(	O
no	O
authorization	O
is	O
involved	O
in	O
this	O
example	O
)	O
by	O
sending	O
an	O
appropriate	O
packet	O
,	O
which	O
contains	O
other	O
information	O
such	O
as	O
the	O
identifier	O
of	O
the	O
root	B-Device
window	I-Device
(	O
e.g.	O
,	O
0x0000002b	O
)	O
and	O
which	O
identifiers	O
the	O
client	B-Protocol
can	O
create	O
.	O
</s>
<s>
The	O
client	B-Protocol
requests	O
the	O
server	B-Application
to	O
create	O
a	O
top-level	O
window	O
(	O
that	O
is	O
,	O
it	O
specifies	O
the	O
parent	O
to	O
be	O
the	O
root	B-Device
window	I-Device
0x0000002b	O
)	O
with	O
identifier	O
0x00200001	O
,	O
size	O
200x200	O
,	O
position	O
(	O
10	O
,	O
10	O
)	O
,	O
etc	O
.	O
</s>
<s>
The	O
client	B-Protocol
requests	O
a	O
change	O
in	O
the	O
attributes	O
of	O
the	O
window	O
0x00200001	O
,	O
specifying	O
it	O
is	O
interested	O
in	O
receiving	O
Expose	O
and	O
KeyPress	O
events	O
.	O
</s>
<s>
A	O
pixelvalue	O
x	B-Operating_System
represents	O
the	O
color	O
contained	O
in	O
the	O
x-th	O
row	O
of	O
the	O
table	O
.	O
</s>
<s>
If	O
the	O
client	B-Protocol
can	O
change	O
the	O
entries	O
in	O
the	O
colormap	O
,	O
this	O
representation	O
is	O
identified	O
by	O
the	O
PseudoColor	O
visual	O
class	O
.	O
</s>
<s>
The	O
visual	O
class	O
StaticColor	O
is	O
similar	O
,	O
but	O
the	O
client	B-Protocol
cannot	O
change	O
the	O
entries	O
in	O
the	O
colormap	O
.	O
</s>
<s>
The	O
visual	O
classes	O
using	O
this	O
representation	O
are	O
the	O
DirectColor	O
and	O
TrueColor	O
ones	O
,	O
differing	O
on	O
whether	O
the	O
client	B-Protocol
can	O
change	O
colormaps	O
or	O
not	O
.	O
</s>
<s>
Each	O
server	B-Application
has	O
a	O
fixed	O
set	O
of	O
visualtypes	O
,	O
each	O
one	O
associated	O
with	O
a	O
numerical	O
identifier	O
.	O
</s>
<s>
When	O
the	O
connection	O
from	O
a	O
client	B-Protocol
is	O
accepted	O
,	O
the	O
acceptance	O
packet	O
sent	O
by	O
the	O
server	B-Application
contains	O
a	O
sequence	O
of	O
blocks	O
,	O
each	O
one	O
containing	O
information	O
about	O
a	O
single	O
screen	B-Device
.	O
</s>
<s>
For	O
each	O
screen	B-Device
,	O
the	O
relative	O
block	O
contains	O
a	O
list	O
of	O
other	O
blocks	O
,	O
each	O
one	O
relative	O
to	O
a	O
specific	O
color	O
depth	O
that	O
is	O
supported	O
by	O
the	O
screen	B-Device
.	O
</s>
<s>
As	O
a	O
result	O
,	O
each	O
screen	B-Device
is	O
associated	O
a	O
number	O
of	O
possible	O
depths	O
,	O
and	O
each	O
depth	O
of	O
each	O
screen	B-Device
is	O
associated	O
a	O
number	O
of	O
possible	O
visual	O
types	O
.	O
</s>
<s>
The	O
client	B-Protocol
stores	O
this	O
information	O
,	O
as	O
it	O
cannot	O
request	O
it	O
afterwards	O
.	O
</s>
<s>
Moreover	O
,	O
clients	B-Protocol
cannot	O
change	O
or	O
create	O
new	O
visual	O
types	O
.	O
</s>
<s>
Colormaps	O
are	O
used	O
regardless	O
of	O
whether	O
the	O
hardware	O
controlling	O
the	O
screen	B-Device
(	O
e.g.	O
,	O
a	O
graphic	B-Device
card	I-Device
)	O
uses	O
a	O
palette	B-Data_Structure
,	O
which	O
is	O
a	O
table	O
that	O
is	O
also	O
used	O
for	O
representing	O
colors	O
.	O
</s>
<s>
Servers	O
use	O
colormaps	O
even	O
if	O
the	O
hardware	O
is	O
not	O
using	O
a	O
palette	B-Data_Structure
.	O
</s>
<s>
Whenever	O
the	O
hardware	O
uses	O
palettes	B-Data_Structure
,	O
only	O
a	O
limited	O
number	O
of	O
colormaps	O
can	O
be	O
installed	O
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
request	O
the	O
server	B-Application
to	O
install	O
a	O
colormap	O
.	O
</s>
<s>
The	O
creation	O
of	O
colormaps	O
is	O
regulated	O
by	O
the	O
ICCCM	B-Operating_System
convention	O
.	O
</s>
<s>
Standard	O
colormaps	O
are	O
regulated	O
by	O
the	O
ICCCM	B-Operating_System
and	O
by	O
the	O
Xlib	B-Language
specification	O
.	O
</s>
<s>
A	O
part	O
of	O
the	O
X	B-Operating_System
colour	O
system	O
is	O
the	O
X	B-Operating_System
Color	O
Management	O
System	O
(	O
xcms	O
)	O
.	O
</s>
<s>
This	O
system	O
was	O
introduced	O
with	O
X11R6	B-Operating_System
Release	O
5	O
in	O
1991	O
.	O
</s>
<s>
This	O
system	O
consists	O
of	O
several	O
additional	O
features	O
in	O
xlib	B-Language
,	O
found	O
in	O
the	O
Xcms*	O
series	O
of	O
functions	O
.	O
</s>
<s>
The	O
system	O
consists	O
of	O
the	O
xlib	B-Language
Xcms*	O
functions	O
and	O
as	O
well	O
the	O
X	B-Operating_System
Device	O
Color	O
Characterization	O
Convention	O
(	O
XDCCC	O
)	O
which	O
describes	O
how	O
to	O
convert	O
the	O
various	O
device	O
independent	O
colour	O
systems	O
into	O
device	O
dependent	O
RGB	O
colour	O
systems	O
.	O
</s>
<s>
The	O
fixed	O
size	O
of	O
atoms	O
was	O
exploited	O
by	O
specifying	O
a	O
fixed	O
size	O
for	O
events	O
,	O
namely	O
32	O
bytes	B-Application
:	O
fixed-size	O
packets	O
can	O
contain	O
atoms	O
,	O
while	O
they	O
cannot	O
contain	O
long	O
strings	O
.	O
</s>
<s>
Precisely	O
,	O
atoms	O
are	O
identifiers	O
of	O
strings	O
stored	O
in	O
the	O
server	B-Application
.	O
</s>
<s>
First	O
,	O
the	O
identifiers	O
of	O
atoms	O
are	O
chosen	O
by	O
the	O
server	B-Application
,	O
not	O
by	O
the	O
client	B-Protocol
.	O
</s>
<s>
In	O
other	O
words	O
,	O
when	O
a	O
client	B-Protocol
requests	O
the	O
creation	O
of	O
a	O
new	O
atom	O
,	O
it	O
only	O
sends	O
the	O
server	B-Application
the	O
string	O
to	O
be	O
stored	O
,	O
not	O
its	O
identifier	O
;	O
this	O
identifier	O
is	O
chosen	O
by	O
the	O
server	B-Application
and	O
sent	O
back	O
as	O
a	O
reply	O
to	O
the	O
client	B-Protocol
.	O
</s>
<s>
The	O
second	O
important	O
difference	O
between	O
resources	O
and	O
atoms	O
is	O
that	O
atoms	O
are	O
not	O
associated	O
with	O
clients	B-Protocol
.	O
</s>
<s>
Once	O
created	O
,	O
an	O
atom	O
survives	O
until	O
the	O
server	B-Application
quits	O
or	O
resets	O
(	O
this	O
is	O
not	O
the	O
default	O
behavior	O
of	O
resources	O
)	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
the	O
name	O
of	O
an	O
atom	O
is	O
commonly	O
used	O
to	O
indicate	O
the	O
atom	O
:	O
“	O
the	O
atom	O
ABCD	O
”	O
means	O
,	O
more	O
precisely	O
,	O
“	O
the	O
atom	O
whose	O
associated	O
string	O
is	O
ABCD.	O
”	O
or	O
“	O
the	O
atom	O
whose	O
name	O
is	O
ABCD.	O
”	O
A	O
client	B-Protocol
can	O
request	O
the	O
creation	O
of	O
a	O
new	O
atom	O
and	O
can	O
request	O
for	O
the	O
atom	O
(	O
the	O
identifier	O
)	O
of	O
a	O
given	O
string	O
.	O
</s>
<s>
Some	O
atoms	O
are	O
predefined	O
(	O
created	O
by	O
the	O
server	B-Application
with	O
given	O
identifier	O
and	O
string	O
)	O
.	O
</s>
<s>
Atoms	O
are	O
used	O
for	O
a	O
number	O
of	O
purposes	O
,	O
mostly	O
related	O
to	O
communication	O
between	O
different	O
clients	B-Protocol
connected	O
to	O
the	O
same	O
server	B-Application
.	O
</s>
<s>
The	O
list	O
of	O
all	O
atoms	O
residing	O
in	O
a	O
server	B-Application
can	O
be	O
printed	O
out	O
using	O
the	O
program	B-Application
xlsatoms	O
.	O
</s>
<s>
In	O
particular	O
,	O
this	O
program	B-Application
prints	O
each	O
atom	O
(	O
the	O
identifier	O
,	O
that	O
is	O
,	O
a	O
number	O
)	O
with	O
its	O
name	O
(	O
its	O
associated	O
string	O
)	O
.	O
</s>
<s>
Every	O
window	O
has	O
a	O
predefined	O
set	O
of	O
attributes	O
and	O
a	O
set	O
of	O
properties	O
,	O
all	O
stored	O
in	O
the	O
server	B-Application
and	O
accessible	O
to	O
the	O
clients	B-Protocol
via	O
appropriate	O
requests	O
.	O
</s>
<s>
Unlike	O
attributes	O
,	O
properties	O
have	O
no	O
meaning	O
at	O
the	O
level	O
of	O
the	O
X	B-Device
Window	I-Device
core	I-Device
protocol	I-Device
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
store	O
arbitrary	O
data	O
in	O
a	O
property	O
of	O
a	O
window	O
.	O
</s>
<s>
Properties	O
are	O
similar	O
to	O
variables	O
in	O
imperative	B-Application
programming	I-Application
languages	I-Application
,	O
in	O
that	O
a	O
client	B-Protocol
can	O
create	O
a	O
new	O
property	O
with	O
a	O
given	O
name	O
and	O
type	O
and	O
store	O
a	O
value	O
in	O
it	O
.	O
</s>
<s>
The	O
name	O
,	O
type	O
,	O
and	O
value	O
of	O
a	O
property	O
are	O
strings	O
;	O
more	O
precisely	O
,	O
they	O
are	O
atoms	O
,	O
that	O
is	O
,	O
strings	O
stored	O
in	O
the	O
server	B-Application
and	O
accessible	O
to	O
the	O
clients	B-Protocol
via	O
identifiers	O
.	O
</s>
<s>
A	O
client	B-Protocol
application	I-Protocol
can	O
access	O
a	O
given	O
property	O
by	O
using	O
the	O
identifier	O
of	O
the	O
atom	O
containing	O
the	O
name	O
of	O
the	O
property	O
.	O
</s>
<s>
Properties	O
are	O
mostly	O
used	O
for	O
inter-client	O
communication	O
.	O
</s>
<s>
Window	B-Application
managers	I-Application
typically	O
read	O
this	O
property	O
to	O
display	O
the	O
name	O
of	O
windows	O
in	O
their	O
title	O
bar	O
.	O
</s>
<s>
Some	O
types	O
of	O
inter-client	O
communication	O
use	O
properties	O
of	O
the	O
root	B-Device
window	I-Device
.	O
</s>
<s>
For	O
example	O
,	O
according	O
to	O
the	O
freedesktop	B-Application
window	B-Application
manager	I-Application
specification	O
,	O
window	B-Application
managers	I-Application
should	O
store	O
the	O
identifier	O
of	O
the	O
currently	O
active	O
window	O
in	O
the	O
property	O
named	O
_NET_ACTIVE_WINDOW	O
of	O
the	O
root	B-Device
window	I-Device
.	O
</s>
<s>
The	O
X	B-Device
resources	I-Device
,	O
which	O
contain	O
parameters	O
of	O
programs	O
,	O
are	O
also	O
stored	O
in	O
properties	O
of	O
the	O
root	B-Device
window	I-Device
;	O
this	O
way	O
,	O
all	O
clients	B-Protocol
can	O
access	O
them	O
,	O
even	O
if	O
running	O
on	O
different	O
computers	O
.	O
</s>
<s>
The	O
xprop	O
program	B-Application
prints	O
the	O
properties	O
of	O
a	O
given	O
window	O
;	O
xprop	O
-root	O
prints	O
the	O
name	O
,	O
type	O
,	O
and	O
value	O
of	O
each	O
property	O
of	O
the	O
root	B-Device
window	I-Device
.	O
</s>
<s>
In	O
the	O
X	B-Operating_System
Window	I-Operating_System
System	I-Operating_System
,	O
every	O
individual	O
,	O
physical	O
key	O
is	O
associated	O
a	O
number	O
in	O
the	O
range	O
8	O
–	O
255	O
,	O
called	O
its	O
keycode	O
.	O
</s>
<s>
While	O
a	O
keycode	O
only	O
depends	O
on	O
the	O
actual	O
key	O
that	O
is	O
pressed	O
,	O
a	O
keysym	O
may	O
depend	O
,	O
for	O
example	O
,	O
on	O
whether	O
the	O
Shift	B-Device
key	I-Device
or	O
another	O
modifier	B-Device
was	O
also	O
pressed	O
.	O
</s>
<s>
When	O
a	O
key	O
is	O
pressed	O
or	O
released	O
,	O
the	O
server	B-Application
sends	O
events	O
of	O
type	O
KeyPress	O
or	O
KeyRelease	O
to	O
the	O
appropriate	O
clients	B-Protocol
.	O
</s>
<s>
The	O
server	B-Application
therefore	O
sends	O
the	O
keycode	O
and	O
the	O
modifier	B-Device
state	O
without	O
attempting	O
to	O
translate	O
them	O
into	O
a	O
specific	O
character	O
.	O
</s>
<s>
It	O
is	O
a	O
responsibility	O
of	O
the	O
client	B-Protocol
to	O
do	O
this	O
conversion	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
client	B-Protocol
may	O
receive	O
an	O
event	O
stating	O
that	O
a	O
given	O
key	O
has	O
been	O
pressed	O
while	O
the	O
Shift	O
modifier	B-Device
was	O
down	O
.	O
</s>
<s>
If	O
this	O
key	O
would	O
normally	O
generate	O
the	O
character	O
"	O
a	O
"	O
,	O
the	O
client	B-Protocol
(	O
and	O
not	O
the	O
server	B-Application
)	O
associates	O
this	O
event	O
to	O
the	O
character	O
"	O
A	O
"	O
.	O
</s>
<s>
While	O
the	O
translation	O
from	O
keycodes	O
to	O
keysyms	O
is	O
done	O
by	O
the	O
client	B-Protocol
,	O
the	O
table	O
that	O
represents	O
this	O
association	O
is	O
maintained	O
by	O
the	O
server	B-Application
.	O
</s>
<s>
Storing	O
this	O
table	O
in	O
a	O
centralized	O
place	O
makes	O
it	O
accessible	O
to	O
all	O
clients	B-Protocol
.	O
</s>
<s>
Typical	O
clients	B-Protocol
only	O
request	O
this	O
mapping	O
and	O
use	O
it	O
for	O
decoding	O
the	O
keycode	O
and	O
modifiers	O
field	O
of	O
a	O
key	O
event	O
into	O
a	O
keysym	O
.	O
</s>
<s>
However	O
,	O
clients	B-Protocol
can	O
also	O
change	O
this	O
mapping	O
at	O
will	O
.	O
</s>
<s>
A	O
modifier	B-Device
is	O
a	O
key	O
that	O
,	O
when	O
pressed	O
,	O
changes	O
the	O
interpretation	O
of	O
other	O
keys	O
.	O
</s>
<s>
A	O
common	O
modifier	B-Device
is	O
the	O
Shift	B-Device
key	I-Device
:	O
when	O
the	O
key	O
that	O
normally	O
produces	O
a	O
lowercase	O
"	O
a	O
"	O
is	O
pressed	O
together	O
with	O
Shift	O
,	O
it	O
produces	O
an	O
uppercase	O
"	O
A	O
"	O
.	O
</s>
<s>
The	O
X	B-Operating_System
server	B-Application
works	O
with	O
at	O
most	O
eight	O
modifiers	O
.	O
</s>
<s>
However	O
,	O
each	O
modifier	B-Device
can	O
be	O
associated	O
with	O
more	O
than	O
one	O
key	O
.	O
</s>
<s>
This	O
is	O
necessary	O
because	O
many	O
keyboards	B-Device
have	O
duplicated	O
keys	O
for	O
some	O
modifiers	O
.	O
</s>
<s>
For	O
example	O
,	O
many	O
keyboards	B-Device
have	O
two	O
"	O
Shift	O
"	O
keys	O
(	O
one	O
on	O
the	O
left	O
and	O
one	O
on	O
the	O
right	O
)	O
.	O
</s>
<s>
These	O
two	O
keys	O
produce	O
two	O
different	O
keycodes	O
when	O
pressed	O
,	O
but	O
the	O
X	B-Operating_System
server	B-Application
associates	O
both	O
with	O
the	O
"	O
Shift	O
"	O
modifier	B-Device
.	O
</s>
<s>
For	O
each	O
of	O
the	O
eight	O
modifiers	O
,	O
the	O
X	B-Operating_System
server	B-Application
maintains	O
a	O
list	O
of	O
the	O
keycodes	O
that	O
it	O
consider	O
to	O
be	O
that	O
modifier	B-Device
.	O
</s>
<s>
As	O
an	O
example	O
,	O
if	O
the	O
list	O
of	O
the	O
first	O
modifier	B-Device
(	O
the	O
"	O
Shift	O
"	O
modifier	B-Device
)	O
contains	O
the	O
keycode	O
0x37	O
,	O
then	O
the	O
key	O
that	O
produces	O
the	O
keycode	O
0x37	O
is	O
considered	O
a	O
shift	B-Device
key	I-Device
by	O
the	O
X	B-Operating_System
server	B-Application
.	O
</s>
<s>
The	O
lists	O
of	O
modifier	B-Device
mappings	O
is	O
maintained	O
by	O
the	O
X	B-Operating_System
server	B-Application
but	O
can	O
be	O
changed	O
by	O
every	O
client	B-Protocol
.	O
</s>
<s>
For	O
example	O
,	O
a	O
client	B-Protocol
can	O
request	O
the	O
"	O
F1	B-Application
key	I-Application
"	O
to	O
be	O
added	O
to	O
the	O
list	O
of	O
"	O
Shift	O
"	O
modifiers	O
.	O
</s>
<s>
From	O
this	O
point	O
on	O
,	O
this	O
key	O
behaves	O
like	O
another	O
shift	O
modifier	B-Device
.	O
</s>
<s>
As	O
a	O
result	O
,	O
F1	O
operates	O
as	O
it	O
did	O
before	O
(	O
for	O
example	O
,	O
a	O
help	O
window	O
may	O
be	O
opened	O
when	O
it	O
is	O
pressed	O
)	O
,	O
but	O
also	O
operates	O
like	O
the	O
shift	B-Device
key	I-Device
(	O
pressing	O
"	O
a	O
"	O
in	O
a	O
text	O
editor	O
while	O
F1	O
is	O
down	O
adds	O
"	O
A	O
"	O
to	O
the	O
current	O
text	O
)	O
.	O
</s>
<s>
The	O
X	B-Operating_System
server	B-Application
maintains	O
and	O
uses	O
a	O
modifier	B-Device
mapping	O
for	O
the	O
mouse	B-Device
buttons	O
.	O
</s>
<s>
However	O
,	O
the	O
buttons	O
can	O
only	O
be	O
permuted	B-Algorithm
.	O
</s>
<s>
The	O
xmodmap	O
program	B-Application
shows	O
and	O
changes	O
the	O
key	O
,	O
modifier	B-Device
,	O
and	O
mouse	B-Device
button	O
mappings	O
.	O
</s>
<s>
A	O
grab	O
is	O
a	O
condition	O
in	O
which	O
all	O
keyboard	B-Device
or	O
mouse	B-Device
events	O
are	O
sent	O
to	O
a	O
single	O
client	B-Protocol
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
request	O
a	O
grab	O
of	O
the	O
keyboard	B-Device
,	O
the	O
mouse	B-Device
,	O
or	O
both	O
:	O
if	O
the	O
request	O
is	O
fulfilled	O
by	O
the	O
server	B-Application
,	O
all	O
keyboard/mouse	O
events	O
are	O
sent	O
to	O
the	O
grabbing	O
client	B-Protocol
until	O
the	O
grab	O
is	O
released	O
.	O
</s>
<s>
The	O
other	O
clients	B-Protocol
will	O
not	O
receive	O
these	O
events	O
.	O
</s>
<s>
When	O
requesting	O
a	O
grab	O
,	O
a	O
client	B-Protocol
specifies	O
a	O
grab	O
window	O
:	O
all	O
events	O
are	O
sent	O
to	O
the	O
grabbing	O
client	B-Protocol
as	O
if	O
they	O
were	O
relative	O
to	O
the	O
grab	O
window	O
.	O
</s>
<s>
However	O
,	O
the	O
other	O
clients	B-Protocol
do	O
not	O
receive	O
events	O
even	O
if	O
they	O
have	O
selected	O
them	O
in	O
the	O
grab	O
window	O
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
establish	O
a	O
grab	O
over	O
the	O
keyboard	B-Device
,	O
the	O
pointer	B-Device
,	O
or	O
both	O
.	O
</s>
<s>
A	O
request	O
for	O
grabbing	O
can	O
include	O
a	O
request	O
for	O
freezing	O
the	O
keyboard	B-Device
or	O
the	O
pointer	B-Device
.	O
</s>
<s>
When	O
a	O
device	O
is	O
frozen	O
,	O
the	O
events	O
it	O
generates	O
are	O
stored	O
in	O
a	O
queue	B-Application
to	O
be	O
delivered	O
as	O
usual	O
when	O
the	O
freeze	O
is	O
over	O
.	O
</s>
<s>
For	O
pointer	B-Device
events	O
,	O
an	O
additional	O
parameter	O
affects	O
the	O
delivery	O
of	O
events	O
:	O
an	O
event	O
mask	O
,	O
which	O
specifies	O
which	O
types	O
of	O
events	O
are	O
to	O
be	O
delivered	O
and	O
which	O
ones	O
are	O
to	O
be	O
discarded	O
.	O
</s>
<s>
The	O
requests	O
for	O
grabbing	O
include	O
a	O
field	O
for	O
specifying	O
what	O
happens	O
to	O
events	O
that	O
would	O
be	O
sent	O
to	O
the	O
grabbing	O
client	B-Protocol
even	O
if	O
it	O
had	O
not	O
established	O
the	O
grab	O
.	O
</s>
<s>
In	O
particular	O
,	O
the	O
client	B-Protocol
can	O
request	O
them	O
to	O
be	O
sent	O
as	O
usual	O
or	O
according	O
to	O
the	O
grab	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
client	B-Protocol
that	O
would	O
normally	O
receive	O
the	O
keyboard	B-Device
events	O
on	O
a	O
first	O
window	O
may	O
request	O
the	O
keyboard	B-Device
to	O
be	O
grabbed	O
by	O
a	O
second	O
window	O
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
also	O
request	O
the	O
grab	O
of	O
the	O
entire	O
server	B-Application
.	O
</s>
<s>
In	O
this	O
case	O
,	O
no	O
request	O
will	O
be	O
processed	O
by	O
the	O
server	B-Application
except	O
the	O
ones	O
coming	O
from	O
the	O
grabbing	O
client	B-Protocol
.	O
</s>
<s>
The	O
first	O
kind	O
of	O
requests	O
is	O
relative	O
to	O
the	O
parent	O
relationship	O
between	O
windows	O
:	O
a	O
client	B-Protocol
can	O
request	O
to	O
change	O
the	O
parent	O
of	O
a	O
window	O
,	O
or	O
can	O
request	O
information	O
about	O
the	O
parenthood	O
of	O
windows	O
.	O
</s>
<s>
Other	O
requests	O
are	O
relative	O
to	O
the	O
selection	B-Device
,	O
which	O
is	O
however	O
mostly	O
governed	O
by	O
other	O
protocols	O
.	O
</s>
<s>
Other	O
requests	O
are	O
about	O
the	O
input	B-Application
focus	I-Application
and	O
the	O
shape	O
of	O
the	O
pointer	B-Device
.	O
</s>
<s>
A	O
client	B-Protocol
can	O
also	O
request	O
the	O
owner	O
of	O
a	O
resource	O
(	O
window	O
,	O
pixmap	O
,	O
etc	O
.	O
)	O
</s>
<s>
to	O
be	O
killed	O
,	O
which	O
causes	O
the	O
server	B-Application
to	O
terminate	O
the	O
connection	O
with	O
it	O
.	O
</s>
<s>
Finally	O
,	O
a	O
client	B-Protocol
can	O
send	O
a	O
no-operation	B-Language
request	O
to	O
the	O
server	B-Application
.	O
</s>
<s>
The	O
X	B-Device
Window	I-Device
core	I-Device
protocol	I-Device
was	O
designed	O
to	O
be	O
extensible	O
.	O
</s>
<s>
In	O
particular	O
,	O
a	O
client	B-Protocol
can	O
request	O
the	O
list	O
of	O
all	O
available	O
extensions	O
for	O
data	O
relative	O
to	O
a	O
specific	O
extension	O
.	O
</s>
<s>
When	O
the	O
client	B-Protocol
initially	O
establishes	O
a	O
connection	O
with	O
the	O
server	B-Application
,	O
the	O
server	B-Application
can	O
reply	O
by	O
either	O
accepting	O
the	O
connection	O
,	O
refusing	O
it	O
,	O
or	O
requesting	O
authentication	O
.	O
</s>
<s>
The	O
core	O
protocol	O
does	O
not	O
specify	O
the	O
authentication	O
process	O
,	O
which	O
depends	O
on	O
the	O
kind	O
of	O
authentication	O
used	O
,	O
other	O
than	O
it	O
ends	O
with	O
the	O
server	B-Application
either	O
sending	O
an	O
acceptance	O
or	O
a	O
refusal	O
packet	O
.	O
</s>
<s>
During	O
the	O
regular	O
interaction	O
between	O
a	O
client	B-Protocol
and	O
a	O
server	B-Application
,	O
the	O
only	O
requests	O
related	O
to	O
authentication	O
are	O
about	O
the	O
host-based	O
access	O
method	O
.	O
</s>
<s>
In	O
particular	O
,	O
a	O
client	B-Protocol
can	O
request	O
this	O
method	O
to	O
be	O
enabled	O
and	O
can	O
request	O
reading	O
and	O
changing	O
the	O
list	O
of	O
hosts	O
(	O
clients	B-Protocol
)	O
that	O
are	O
authorized	O
to	O
connect	O
.	O
</s>
<s>
Typical	O
applications	O
do	O
not	O
use	O
these	O
requests	O
;	O
they	O
are	O
used	O
by	O
the	O
xhost	O
program	B-Application
to	O
give	O
a	O
user	O
or	O
a	O
script	B-Language
access	O
to	O
the	O
host	O
access	O
list	O
.	O
</s>
<s>
Most	O
client	B-Protocol
programs	I-Protocol
communicate	O
with	O
the	O
server	B-Application
via	O
the	O
Xlib	B-Language
client	B-Protocol
library	O
.	O
</s>
<s>
In	O
particular	O
,	O
most	O
clients	B-Protocol
use	O
libraries	O
such	O
as	O
Xaw	B-Library
,	O
Motif	B-Application
,	O
GTK+	B-Application
,	O
or	O
Qt	B-Language
which	O
in	O
turn	O
use	O
Xlib	B-Language
for	O
interacting	O
with	O
the	O
server	B-Application
.	O
</s>
<s>
The	O
use	O
of	O
Xlib	B-Language
has	O
the	O
following	O
effects	O
:	O
</s>
<s>
Xlib	B-Language
makes	O
the	O
client	B-Protocol
synchronous	O
with	O
respect	O
to	O
replies	O
and	O
events	O
:	O
</s>
<s>
the	O
Xlib	B-Language
functions	O
that	O
send	O
requests	O
block	O
until	O
the	O
appropriate	O
replies	O
,	O
if	O
any	O
is	O
expected	O
,	O
are	O
received	O
;	O
in	O
other	O
words	O
,	O
an	O
X	B-Operating_System
Window	I-Operating_System
client	B-Protocol
not	O
using	O
Xlib	B-Language
can	O
send	O
a	O
request	O
to	O
the	O
server	B-Application
and	O
then	O
do	O
other	O
operations	O
while	O
waiting	O
for	O
the	O
reply	O
,	O
but	O
a	O
client	B-Protocol
using	O
Xlib	B-Language
can	O
only	O
call	O
an	O
Xlib	B-Language
function	O
that	O
sends	O
the	O
request	O
and	O
wait	O
for	O
the	O
reply	O
,	O
thus	O
blocking	O
the	O
client	B-Protocol
while	O
waiting	O
for	O
the	O
reply	O
(	O
unless	O
the	O
client	B-Protocol
starts	O
a	O
new	O
thread	O
before	O
calling	O
the	O
function	O
)	O
;	O
</s>
<s>
while	O
the	O
server	B-Application
sends	O
events	O
asynchronously	O
,	O
Xlib	B-Language
stores	O
events	O
received	O
by	O
the	O
client	B-Protocol
in	O
a	O
queue	B-Application
;	O
the	O
client	B-Protocol
program	I-Protocol
can	O
only	O
access	O
them	O
by	O
explicitly	O
calling	O
functions	O
of	O
the	O
X11	B-Operating_System
library	O
;	O
in	O
other	O
words	O
,	O
the	O
client	B-Protocol
is	O
forced	O
to	O
block	O
or	O
busy-wait	B-Operating_System
if	O
expecting	O
an	O
event	O
.	O
</s>
<s>
Xlib	B-Language
does	O
not	O
send	O
requests	O
to	O
the	O
server	B-Application
immediately	O
,	O
but	O
stores	O
them	O
in	O
a	O
queue	B-Application
,	O
called	O
the	O
output	O
buffer	O
;	O
the	O
requests	O
in	O
the	O
output	O
buffer	O
are	O
actually	O
sent	O
when	O
:	O
</s>
<s>
the	O
program	B-Application
explicitly	O
requests	O
so	O
by	O
calling	O
a	O
library	O
function	O
such	O
as	O
XFlush	O
;	O
</s>
<s>
the	O
program	B-Application
calls	O
a	O
function	O
that	O
gives	O
as	O
a	O
result	O
something	O
that	O
involve	O
a	O
reply	O
from	O
the	O
server	B-Application
,	O
such	O
as	O
XGetWindowAttributes	O
;	O
</s>
<s>
the	O
program	B-Application
asks	O
for	O
an	O
event	O
in	O
the	O
event	O
queue	B-Application
(	O
for	O
example	O
,	O
by	O
calling	O
XNextEvent	O
)	O
and	O
the	O
call	O
blocks	O
(	O
for	O
example	O
,	O
XNextEvent	O
blocks	O
if	O
the	O
queue	B-Application
is	O
empty	O
.	O
)	O
</s>
<s>
Higher-level	O
libraries	O
such	O
as	O
Xt	B-Language
(	O
which	O
is	O
in	O
turn	O
used	O
by	O
Xaw	B-Library
and	O
Motif	B-Application
)	O
allow	O
the	O
client	B-Protocol
program	I-Protocol
to	O
specify	O
the	O
callback	O
functions	O
associated	O
with	O
some	O
events	O
;	O
the	O
library	O
takes	O
care	O
of	O
polling	O
the	O
event	O
queue	B-Application
and	O
calling	O
the	O
appropriate	O
function	O
when	O
required	O
;	O
some	O
events	O
such	O
as	O
those	O
indicating	O
the	O
need	O
of	O
redrawing	O
a	O
window	O
are	O
handled	O
internally	O
by	O
Xt	B-Language
.	O
</s>
<s>
Lower-level	O
libraries	O
,	O
such	O
as	O
XCB	B-Language
,	O
provide	O
asynchronous	O
access	O
to	O
the	O
protocol	O
,	O
allowing	O
better	O
latency	O
hiding	O
.	O
</s>
<s>
The	O
X	B-Device
Window	I-Device
System	I-Device
core	I-Device
protocol	I-Device
does	O
not	O
mandate	O
over	O
inter-client	O
communication	O
and	O
does	O
not	O
specify	O
how	O
windows	O
are	O
used	O
to	O
form	O
the	O
visual	O
elements	O
that	O
are	O
common	O
in	O
graphical	B-Application
user	I-Application
interfaces	I-Application
(	O
buttons	O
,	O
menus	O
,	O
etc	O
.	O
)	O
.	O
</s>
<s>
Graphical	B-Application
user	I-Application
interface	I-Application
elements	O
are	O
defined	O
by	O
client	B-Protocol
libraries	O
realizing	O
widget	B-Library
toolkits	I-Library
.	O
</s>
<s>
Inter-client	O
communication	O
is	O
covered	O
by	O
other	O
standards	O
such	O
as	O
the	O
ICCCM	B-Operating_System
and	O
freedesktop	B-Application
specifications	O
.	O
</s>
<s>
Inter-client	O
communication	O
is	O
relevant	O
to	O
selections	B-Device
,	I-Device
cut	I-Device
buffers	I-Device
,	I-Device
and	I-Device
drag-and-drop	I-Device
,	O
which	O
are	O
the	O
methods	O
used	O
by	O
a	O
user	O
to	O
transfer	O
data	O
from	O
a	O
window	O
to	O
another	O
.	O
</s>
<s>
Inter-client	O
communication	O
is	O
also	O
relevant	O
to	O
X	B-Application
window	I-Application
managers	I-Application
,	O
which	O
are	O
programs	O
that	O
control	O
the	O
appearance	O
of	O
the	O
windows	O
and	O
the	O
general	O
look-and-feel	B-Application
of	O
the	O
graphical	B-Application
user	I-Application
interface	I-Application
.	O
</s>
<s>
Yet	O
another	O
issue	O
where	O
inter-client	O
communication	O
is	O
to	O
some	O
extent	O
relevant	O
is	O
that	O
of	O
session	B-Device
management	I-Device
.	O
</s>
<s>
Usually	O
,	O
this	O
is	O
done	O
automatically	O
by	O
the	O
X	B-Device
display	I-Device
manager	I-Device
.	O
</s>
<s>
The	O
user	O
can	O
however	O
also	O
start	O
a	O
session	O
manually	O
running	O
the	O
xinit	B-Device
or	O
startx	B-Device
programs	O
.	O
</s>
