• No results found

Mouse actions ;md keystrokes :�re received by the e Xcursion server as Win32 messages Each message

In document dtj v08 01 1996 pdf (Page 39-43)

comains i n f(mll;ltion about the window th:1r received

the input and the rime of rhe

in put.

For

mouse

moves

�md clicks,

the scn·er

u ses the \\'indo\\'

intorm�uion

to

locate the

corresponding

X wi ndow

and forwards an

X el'e nt ro th:lt winclo\1'. Keyboard input is t(xwarded

to the window th:-tt

currently

has X foc us.

3:-l

Table 1

Plane Mask Optim izations

Requested X Raster src 0 0 1 Modified Source Color and

Operation dst 0 1 0 Notes Raster Operations

GXclear 0 0 0 0 4 src <----p m, rop <--- a nd GXand 0 0 0 1 1 src <---src I - p m GXand Reverse 0 0 0 6 src <---src I -pm src <----p m, rop <---xor GXcopy 0 0 8 src <---- p m, rop <--- a nd src <---src & pm, rop <--- or GXcopy 0 0 8 src <---pm, rop <---or (src & pm) = pm GXcopy 0 0 8 src <-src I -pm, rop <--- a n d (src & pm) = 0

GXandl nverted 0 0 0 2 src <---src & pm

GXnoop 0 0 1 1 0 GXxor 0 1 0 2 s rc <---src & pm GXor 0 1 1 1 2 s rc <---src & pm GXnor 0 0 0 7 src src & pm src <----p m, rop <---xor GXeq u i v 0 0 1 src <-src I - p m

GXinvert 0 0 5 src <-pm, rop <---xor

GXorReverse 0 7 src <---src & pm

src <----pm, rop <--- xor

GXcopyl nverted 0 0 9 src <---- pm, rop <--- a nd

src <----src & pm, rop <--- or GXorlnverted 0 1 src <---src I - p m GXnand 0 6 src <---src I -pm src <----pm, rop <---xor GXset 3 src <---pm, rop <--- or Notes:

1 . dst is uncha nged when src equals 1 for these raster operat ions. Th erefore, to preserve the va l u e of dst when pm eq u a l s 0, set src equal to 1 .

2. dst is un cha nged when src eq uals 0 for th ese raster operat ions. The refore, to p reserve the va lue of dst when pm equals 0, set src equal to 0.

3. This operation sets all dst bits to 1 except where the plane mask equals 0. This can be done s i m ply by ORing pm i nto dst.

4. T h i s operation clears a l l dst bits except where the plane mask equa l s 0 . This ca n be done s i mply by ANDing pm into dst.

5. XORing with 1 has the effect of invert i n g . To invert only where pm eq uals 1, XOR pm with dst.

6. These operations a re performed in two steps. Note that dst is i nverted when src equals 1 . F i rst perform the operation with src set to 1 where pm equals 0 . dst is now correct except that it is i n verted where pm equals 0. The second operation of XORing with the i nvert of pm cor rects this.

7. Th ese operati ons a re perfo rmed in two steps. Note that dst i s i nverted when src equals 0. Fi rst perform the operation with src set to 0 where pm equals 0 . dst is now correct except that it is inverted where pm equals 0. The second operation of XORing with the i nvert of pm corrects t h i s .

8 . T h i s operation is performed in two steps. Fi rst d s t is set to 0 whenever pm e q u a l s 1 . Then dst is set t o 1 when­ ever both pm and src eq u a l 1 . The two spec i a l cases can be redu ced to operations that use GXset and GXcl ear.

9. T h i s operation is performed in two steps. F i rst dst is set to 0 whenever pm eq u a ls 1 . Then dst is set to 1 when­ ever pm equals 1 a n d src equals 0.

1 0. dst is unchanged; therefore, no operation is req u i red .

The X server is a single Jppl ication in the vVin32 cn\·iron ment rh�H "owns" a l l rile X windO\\'S it crcltcs. from rhe user's perspective, though

,

there 111�1y appear

to be more than one

X

Jpplicarion running, each with its own col

l

ection of windows. The user expects to be a b le to shift the kevbo:1rd t(>eus tl·om one win dow to another i n rhe s:1me tlshion that focus is shitrcd bct\\'ccn other :1ppl ications. \t\fben an external \\'indo\\' m:1nager is i n usc, focus comrol is straightt(xward. The \\'indow manJger, usi ng \\'harever sem:mric it

\\·as designed tor, mon i tors mouse events Jnd shifts t(>eus accordingly. H owever, the semantic model for this may or may not be consistent with the Win32 mod e l . ln either case

,

the window decorations, e.g., borders, title bars, and menus, arc al most guaranteed to be different. A user who wants a consistcnr user

in tcrhce model across Jl! applications must emplov

the interna l \\'indo\\' m:.n:1ger.

Ar Jll\' given rime, one wind o\\' on the screen Ius

Win32 focus and one X window has X focus. The two windows are not necessarily the same. Since the X server cre:Jtcs and owns J l l the X windows in use, the server receives keyboJrd input when any one of irs windmvs has \t\fi n 32 t(xus. The keystrokes are nor

necessarilv sent to rhe undcrlving X window, however.

Thcv arc sent to rhe window that has

X

tocus. The internal \\'ind o\\' 111<1ll:tgcr Jssigns X tocus to the

X

\\'i n­

dow rhat receives Win32 toCLis. The client receives noti tication of this event :tnd may decide to :tssign X

t(xus to some other window, perhaps a child window. The server m ust therctore

k

eep track of both the

X

window rhat cu rrcmly has focus and the stare of Win32 foc us. When the server loses Win32 focus, the

X

rixus is assigned ro the root wi ndow. ·when the

Ser\·cr rceei\·es Win32 focus

,

X tocus is assigned to the

X wi ndow that previous!\· hJd it. \Nhenever

X

tixus is

ch�mgcd bv :tn application

or Lw

the wi ndow ma nager, the cu rrent X focus state is c:tchcd so that i t can be restored later, if necessary.

Font Management

fonts and text fu nction�1lity make up a significant por­

tion

of

anv graphics <1rchitccture. Both

the X

and the Win32 S\'Stcms dctinc :1 rich set of text-rendering opcrJtions and can process sc\·er:tl tont tormats. X and Win32 Fonts The

X tont ma

n

a

gement libr:try is :1 mod u lar arch itectu re th:tt detines an API t(x reading and writing i n d ivid u•1 l rcmt tormats. The mod ule that implements the API for :1 given font format is cztl led a ren derer. This approach al lows X to support several tc>llt tormats: tl1e l i brarv's renderer modules com·ert

external formats to J single, internal

b

itmap format,

which is used tor all dr:twing oper:ttions. The term

X./ollt refers to tont

data in

this internal tormat.

The font management library supports both bitmap and scalable outline tonrs. Bitmap t()llt glyphs arc si m­ ply retormatted :md used . Scalable tcm11:1ts, such as

Adobe Type

1 ,

JI-e rasterized on demand i n to the X

font tormat.

For maximum performance, the server drJws text with native Win32 toms using the Win32 A P I . Win32 fonts are bitmap fonts in the FON f(mnat. Win32

functional irv covers the great majority of text-drawing

operations, but there are a tew cases i n which it is either not possib

le

or not efficient to usc Win32 toms.

The server can also d r:tw d i rectly with the

X

tonts to provide fu ll

X

t()llt support and complete text-drawing

functionality. This method uses Win32 Bit Bit

( )

opera­ tions to copv the ch�1racter glyp hs to the d isplay as bitmaps. Drawi ng speed with this method is :tccepr­ able but not maximu m .

Therefore, both X Jnd Wi n 3 2 fonts :tre used . The

Win32 fonts nuy be thought of as optional acce lera­

tors: the server uses them whenever possible and falls back to the X t(mts when necessJry. The decision to fall back can be made on a variety of conditions. This technique has also proved usefu l in working around

problems such as text-drawing bugs in i n d ividual

video drivers .

Since scalable tont outli nes arc rJstcrized into

bitmaps at run time, they are generally d rawn directly with the i n ternJ! X font format. The extrJ work of

compiling a comp:1nion vVin 3 2 tont at run rime gener­ ally outweighs its value as an accelerator.

X bitmap tonts are most commonly distributed in

the Bitmap Distribution Format ( BDl-"), an ASCII text sou rce fi l e . The eXcu rsion team wrote a t(m t compiler tool that generates native Win32 ( FON t(xmat) fonts fl·om the

B

Df sources. The fonts created can be used

by any Win32 appl ication.

The compi ler can generate either the com mon ly

used version 2 t(mnat or the extended version 3 tor­

mat, which is ncccssJry tor large tcm ts that require

more than 64 ki

lobytes ( KB) of glyph storage. figure 3 i l l ustrates the process of generati ng equivalent

X

and Win32 f(>nts ti·om �1 common source.

The X font tonn:1t con tains extra i n tormJtion (e.g., metrics and properties) thar cannot be derived from

BDF FONT

Figure 3

Font

Conversion

Digi r,ll T�(hnical journ.1l

X FONT

WINDOWS (FON) FONT

40

rhe vVi n32 font. Therdon:, the X and Wi n32 tonts arc used rogether; the X i n t(mnation comes tl·om the X font and the Win32 r(mt is used Lw the Win32 API .

Real izing Win32 and X Fonts When the X server fi rst opens a font, it invokes the function RealizeFont( ) . This ti.mction gives the server a n opportunity to initial ­ ize d:.1ta structu res

�1nd ped(mn

any format-specific operations necessarv to make the ti.lnt <l\'ailab l c .

To make a W

i

n32 t(mt <1\":lii:Jble tor dr,m·i ng, the server retrie,·es the

t

ilcn:un

e

of the font from the

scnu's l ook- up table �md registers it "·ith the Wi n 3 2 API using the function Add Font Resource( ). A h:mdlc ro th

e font is obtained from CrcatcFontl ndircct( ), �111d

the reafter the handle is selected i nto the desired DC f(x d rawing operations.

H " the

Win32 realization hils

t

(Jr any reason,

the

code simply re1lizcs the X fon t instead . Failing to re:1lize a VVin32 font docs not neces­ sarily imply an error conditi on. Such t

a

il ure happens in any case i n which the sen'Cr decides that it is best to use the X font d i rectJv.

The int ernal X tonr ti.m1ut is <1 set ofLhta structures.

The glyphs are stored in coll\'Cntioml arra\'S in user memory. To improve perti.mn<1ncc, the server realizes

:.1n X font by writing a l l gln1hs ro a Win32 bitmap in

off-screen memory. CrcatcBitmap( ) returns a lund lc

f(ll· later reference, and the glyphs in the bitmap arc indexed tor use in drawing operations.

Drawing with Win32 and X Fonts The glyphs in X text strings are often kerned,

that

is, mnlapped tor best

rvpogr<1phic appearance. To draw with Wi n32 fonts,

the SCITer emulates the way X draws text by using

Ex rTextOut( ) , which uses an interch<1racter spacing vector to place the individual glyphs. The

f

ont's

X met­

rics are used directly to calculate this vector.

Glyphs tl·om X tonts arc dr:.1wn by performi ng

BitBits tl-om the Win32 bitmap to the t:trget window

or bitmap. The server places the glyphs using

the r(m

t's

X metrics as d escribed in the previous paragrap h . Color Resource Management

Although some X Window Svstem concepts and struc­

tures 111:1p fairlv c lose ly to th

os

e in the \�Ti n 3 2 S\'Ste m,

color resou rce management is handled ,·crv differ­

en

t

ly. The difference is most

evidem

when dealing

with pseudocolor video systems.

C

onsequently, this paper describes only this case .

The X Wi ndow Sys

t

e

m

environment shares 256 col­

ornnp cells among :t i l appl i cations that use the defa u l t col ormap ( i . e . , those th<H do not have a pri,·are col ­

onll<1 p ) .

A

pplications can allocate cel ls i n the defau lt

c

olormap

to

protect them

tt·om

modi fication Lw other applications. In contrast, the Win32 S\'Stem allows

each appl ication comp lete access to the S\'Stem palette

while the application h

a

s

t(Kus

and maps the palettes of the windows without t(Kus as best it can .

Digir,11 T<:(hni(a] )oum.d Vol . 8 No. I 1 9')6

In the X vVindow Svstem CIWironment, when an appliution n:serves a colormap cel l , it references the

cell with a pixel \·a lu e . This value is an index into the

colonnap and is used to

look

up the val ue that will

<1ctu<1ily be stored in screen memory when that pixel

value is used in a d rawing

opnation .

In document dtj v08 01 1996 pdf (Page 39-43)